/** * @param string $className * @param bool $hasEntityConfig * @param array $fieldNames * @param array $fieldNamesMapping * @param bool $expected * * @dataProvider entityProvider */ public function testIsIgnoredEntity($className, $hasEntityConfig, array $fieldNames, array $fieldNamesMapping, $expected) { $config = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface'); $this->configProvider->expects($this->at(0))->method('getConfig')->with($this->equalTo($className))->will($this->returnValue($config)); $config->expects($this->at(0))->method('has')->with($this->equalTo('contact_information'))->will($this->returnValue($hasEntityConfig)); if (!$hasEntityConfig) { $om = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ObjectManager')->disableOriginalConstructor()->getMock(); $om->expects($this->once())->method('getClassMetadata')->with($this->equalTo($className))->will($this->returnValue($this->metadata)); $this->metadata->expects($this->once())->method('getFieldNames')->will($this->returnValue($fieldNames)); if (!empty($fieldNames)) { $i = 1; foreach ($fieldNames as $fieldName) { $this->configProvider->expects($this->at($i))->method('getConfig')->with($this->equalTo($className), $this->equalTo($fieldName))->will($this->returnValue($config)); $config->expects($this->at($i))->method('has')->with($this->equalTo('contact_information'))->will($this->returnValue($fieldNamesMapping[$fieldName])); $i++; } } $this->registry->expects($this->once())->method('getManagerForClass')->with($this->equalTo($className))->will($this->returnValue($om)); } $result = $this->provider->isIgnoredEntity($className); $this->assertEquals($expected, $result); }
public function testNonConfigurableIgnored() { $class = 'stdClass'; $this->configProvider->expects($this->once())->method('hasConfig')->with($class)->will($this->returnValue(false)); $this->assertTrue($this->provider->isIgnoredEntity($class)); }