From 785aca67bce345bd99e8407e3ec9bc2c307e3230 Mon Sep 17 00:00:00 2001
From: Dale Sikkema <dsikkema@ebay.com>
Date: Tue, 23 Jun 2015 11:23:06 -0500
Subject: [PATCH] MAGETWO-37848: Generate data fails when table prefix exceeds
 length of 5  - add unit test

---
 .../Magento/Framework/App/Resource.php        |  1 -
 .../Framework/App/Test/Unit/ResourceTest.php  | 19 ++++++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/internal/Magento/Framework/App/Resource.php b/lib/internal/Magento/Framework/App/Resource.php
index faf59ba520b..fae3cdb761c 100644
--- a/lib/internal/Magento/Framework/App/Resource.php
+++ b/lib/internal/Magento/Framework/App/Resource.php
@@ -160,7 +160,6 @@ class Resource
      * @param string $time  Either "before" or "after"
      * @param string $event  The DB level event which activates the trigger, i.e. "update" or "insert"
      * @return string
-     * @codeCoverageIgnore
      */
     public function getTriggerName($tableName, $time, $event)
     {
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ResourceTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ResourceTest.php
index a92a9eb7343..86fc5bf7ac9 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/ResourceTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/ResourceTest.php
@@ -14,7 +14,7 @@ use Magento\Framework\Config\ConfigOptionsListConstants;
 class ResourceTest extends \PHPUnit_Framework_TestCase
 {
     const RESOURCE_NAME = \Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE;
-    const CONNECTION_NAME = 'Connection Name';
+    const CONNECTION_NAME = 'connection-name';
     const TABLE_PREFIX = 'prefix_';
 
     /**
@@ -197,4 +197,21 @@ class ResourceTest extends \PHPUnit_Framework_TestCase
 
         $this->assertEquals('fkName', $this->resource->getFkName($table, $columnName, $refTable, $refColumnName));
     }
+
+    public function testGetTriggerName()
+    {
+        $tableName = 'subject_table';
+        $time = 'before';
+        $event = 'insert';
+        $triggerName = 'trg_subject_table_before_insert';
+
+        $this->_connectionFactory->expects($this->once())
+            ->method('create')
+            ->will($this->returnValue($this->connection));
+        $this->connection->expects($this->once())
+            ->method('getTriggerName')
+            ->with($tableName, $time, $event)
+            ->willReturn($triggerName);
+        $this->assertSame($triggerName, $this->resource->getTriggerName($tableName, $time, $event));
+    }
 }
-- 
GitLab