Пример #1
0
 /**
  * @group integration-test
  */
 public function testPostInitialize()
 {
     $tableGatewayMock = $this->getMockForAbstractClass('Zend\\Db\\TableGateway\\AbstractTableGateway');
     $metadataMock = $this->getMock('Zend\\Db\\Metadata\\MetadataInterface');
     $metadataMock->expects($this->any())->method('getColumnNames')->will($this->returnValue(array('id', 'name')));
     $constraintObject = new ConstraintObject('id_pk', 'table');
     $constraintObject->setColumns(array('id'));
     $constraintObject->setType('PRIMARY KEY');
     $metadataMock->expects($this->any())->method('getConstraints')->will($this->returnValue(array($constraintObject)));
     $feature = new MetadataFeature($metadataMock);
     $feature->setTableGateway($tableGatewayMock);
     $feature->postInitialize();
     $this->assertEquals(array('id', 'name'), $tableGatewayMock->getColumns());
 }
Пример #2
0
 /**
  * @cover FeatureSet::addFeature
  * @group ZF2-4993
  */
 public function testAddFeatureThatFeatureHasTableGatewayButFeatureSetDoesnotHas()
 {
     $tableGatewayMock = $this->getMockForAbstractClass('Zend\\Db\\TableGateway\\AbstractTableGateway');
     $metadataMock = $this->getMock('Zend\\Db\\Metadata\\MetadataInterface');
     $metadataMock->expects($this->any())->method('getColumnNames')->will($this->returnValue(array('id', 'name')));
     $constraintObject = new ConstraintObject('id_pk', 'table');
     $constraintObject->setColumns(array('id'));
     $constraintObject->setType('PRIMARY KEY');
     $metadataMock->expects($this->any())->method('getConstraints')->will($this->returnValue(array($constraintObject)));
     //feature have tableGateway, but FeatureSet doesn't has
     $feature = new MetadataFeature($metadataMock);
     $feature->setTableGateway($tableGatewayMock);
     $featureSet = new FeatureSet();
     $this->assertInstanceOf('Zend\\Db\\TableGateway\\Feature\\FeatureSet', $featureSet->addFeature($feature));
 }