Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 2f365a8

Browse files
committed
Added unit test for #338
1 parent 94f2ce5 commit 2f365a8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/unit/TableGateway/AbstractTableGatewayTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ protected function setUp()
8484
->getMock()
8585
));
8686

87+
$this->mockFeatureSet = $this->getMockBuilder('Zend\Db\TableGateway\Feature\FeatureSet')->getMock();
88+
8789
$this->table = $this->getMockForAbstractClass(
8890
'Zend\Db\TableGateway\AbstractTableGateway'
8991
//array('getTable')
@@ -104,6 +106,9 @@ protected function setUp()
104106
case 'sql':
105107
$tgPropReflection->setValue($this->table, $this->mockSql);
106108
break;
109+
case 'featureSet':
110+
$tgPropReflection->setValue($this->table, $this->mockFeatureSet);
111+
break;
107112
}
108113
}
109114
}
@@ -369,6 +374,30 @@ public function testGetLastInsertValue()
369374
self::assertEquals(10, $this->table->getLastInsertValue());
370375
}
371376

377+
public function testInitializeBuildsAResultSet()
378+
{
379+
$stub = $this->getMockForAbstractClass(AbstractTableGateway::class);
380+
381+
$tgReflection = new \ReflectionClass('Zend\Db\TableGateway\AbstractTableGateway');
382+
foreach ($tgReflection->getProperties() as $tgPropReflection) {
383+
$tgPropReflection->setAccessible(true);
384+
switch ($tgPropReflection->getName()) {
385+
case 'table':
386+
$tgPropReflection->setValue($stub, 'foo');
387+
break;
388+
case 'adapter':
389+
$tgPropReflection->setValue($stub, $this->mockAdapter);
390+
break;
391+
case 'featureSet':
392+
$tgPropReflection->setValue($stub, $this->mockFeatureSet);
393+
break;
394+
}
395+
}
396+
397+
$stub->initialize();
398+
$this->assertInstanceOf(ResultSet::class, $stub->getResultSetPrototype());
399+
}
400+
372401
/**
373402
* @covers \Zend\Db\TableGateway\AbstractTableGateway::__get
374403
*/

0 commit comments

Comments
 (0)