Skip to content

Commit 785aca6

Browse files
author
Dale Sikkema
committed
MAGETWO-37848: Generate data fails when table prefix exceeds length of 5
- add unit test
1 parent 2334dde commit 785aca6

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/internal/Magento/Framework/App/Resource.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ public function getTableName($modelEntity, $connectionName = self::DEFAULT_READ_
160160
* @param string $time Either "before" or "after"
161161
* @param string $event The DB level event which activates the trigger, i.e. "update" or "insert"
162162
* @return string
163-
* @codeCoverageIgnore
164163
*/
165164
public function getTriggerName($tableName, $time, $event)
166165
{

lib/internal/Magento/Framework/App/Test/Unit/ResourceTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class ResourceTest extends \PHPUnit_Framework_TestCase
1515
{
1616
const RESOURCE_NAME = \Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE;
17-
const CONNECTION_NAME = 'Connection Name';
17+
const CONNECTION_NAME = 'connection-name';
1818
const TABLE_PREFIX = 'prefix_';
1919

2020
/**
@@ -197,4 +197,21 @@ public function testGetFkName()
197197

198198
$this->assertEquals('fkName', $this->resource->getFkName($table, $columnName, $refTable, $refColumnName));
199199
}
200+
201+
public function testGetTriggerName()
202+
{
203+
$tableName = 'subject_table';
204+
$time = 'before';
205+
$event = 'insert';
206+
$triggerName = 'trg_subject_table_before_insert';
207+
208+
$this->_connectionFactory->expects($this->once())
209+
->method('create')
210+
->will($this->returnValue($this->connection));
211+
$this->connection->expects($this->once())
212+
->method('getTriggerName')
213+
->with($tableName, $time, $event)
214+
->willReturn($triggerName);
215+
$this->assertSame($triggerName, $this->resource->getTriggerName($tableName, $time, $event));
216+
}
200217
}

0 commit comments

Comments
 (0)