Skip to content

Commit

Permalink
zendframework#186 filled test for reusing implicit sequence name gene…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
alextech committed Dec 25, 2016
1 parent ca17575 commit a4b00d3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/TableGateway/Feature/SequenceFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,32 @@ public function testSequenceNameQueriedWhenTooLong()
*/
public function testCacheSequenceName()
{
$adapter = $this->getMock('Zend\Db\Adapter\Adapter', ['getPlatform', 'createStatement'], [], '', false);
$adapter->expects($this->any())
->method('getPlatform')
->will($this->returnValue(new TrustingPostgresqlPlatform()));
$result = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\ResultInterface', [], '', false, true, true, ['current']);
$result->expects($this->once())
->method('current')
->will($this->returnValue(['pg_get_serial_sequence' => 'table_name_column_very_long_name_causing_postgresql_to_trun_seq']));
$statement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\StatementInterface', [], '', false, true, true, ['prepare', 'execute']);
$statement->expects($this->once())
->method('execute')
->with(['table' => 'table_name', 'column' => 'column_very_long_name_causing_postgresql_to_truncate'])
->will($this->returnValue($result));
$statement->expects($this->once())
->method('prepare')
->with('SELECT pg_get_serial_sequence(:table, :column)');
$adapter->expects($this->once())
->method('createStatement')
->will($this->returnValue($statement));
$this->tableGateway = $this->getMockForAbstractClass('Zend\Db\TableGateway\TableGateway', ['table_name', $adapter], '', true);

$sequence = new SequenceFeature('column_very_long_name_causing_postgresql_to_truncate');
$sequence->setTableGateway($this->tableGateway);

$this->assertEquals('table_name_column_very_long_name_causing_postgresql_to_trun_seq', $sequence->getSequenceName());
$this->assertEquals('table_name_column_very_long_name_causing_postgresql_to_trun_seq', $sequence->getSequenceName());
}

/**
Expand Down

0 comments on commit a4b00d3

Please sign in to comment.