protected function setUp() { parent::setUp(); $this->transformer = new JobInstanceTransformer($this->doctrine, $this->propertyAccessor, $this->guesser, $this->columnInfoTransformer); $this->addColumn('code'); $this->repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock(); $this->doctrine->expects($this->any())->method('getRepository')->with($this->equalTo('stdClass'))->will($this->returnValue($this->repository)); }
protected function setUp() { parent::setUp(); $this->familyFactory = $this->getMockBuilder('Pim\\Bundle\\CatalogBundle\\Factory\\FamilyFactory')->disableOriginalConstructor()->getMock(); $this->transformerRegistry = $this->getMock('Pim\\Bundle\\TransformBundle\\Transformer\\EntityTransformerInterface'); $this->transformerRegistry->expects($this->any())->method('transform')->will($this->returnCallback(function ($class, $data) { $this->assertEquals('Pim\\Bundle\\CatalogBundle\\Entity\\AttributeRequirement', $class); $option = $this->getMock($class); foreach ($data as $key => $value) { $option->expects($this->any())->method('get' . ucfirst($key))->will($this->returnValue($value)); } return $option; })); $this->transformer = new FamilyTransformer($this->doctrine, $this->propertyAccessor, $this->guesser, $this->columnInfoTransformer, $this->transformerRegistry, $this->familyFactory, 'Pim\\Bundle\\CatalogBundle\\Entity\\AttributeRequirement'); $this->addColumn('code'); $this->setupRepositories(); $this->family = $this->getMock('Pim\\Bundle\\CatalogBundle\\Entity\\Family'); $this->familyFactory->expects($this->any())->method('createFamily')->will($this->returnValue($this->family)); }
protected function setUp() { parent::setUp(); $this->attribute = $this->getMock('Pim\\Bundle\\CatalogBundle\\Entity\\Attribute'); $this->attributeManager = $this->getMockBuilder('Pim\\Bundle\\CatalogBundle\\Manager\\AttributeManager')->disableOriginalConstructor()->getMock(); $this->attributeManager->expects($this->any())->method('getAttributeClass')->will($this->returnValue('Pim\\Bundle\\CatalogBundle\\Entity\\Attribute')); $this->attributeManager->expects($this->any())->method('getAttributeOptionClass')->will($this->returnValue('Pim\\Bundle\\CatalogBundle\\Entity\\AttributeOption')); $this->doctrineCache = $this->getMockBuilder('Pim\\Bundle\\TransformBundle\\Cache\\DoctrineCache')->disableOriginalConstructor()->getMock(); $this->attributeManager->expects($this->any())->method('createAttribute')->with($this->equalTo('type'))->will($this->returnValue($this->attribute)); $this->transformerRegistry = $this->getMock('Pim\\Bundle\\TransformBundle\\Transformer\\EntityTransformerInterface'); $this->transformer = new AttributeTransformer($this->doctrine, $this->propertyAccessor, $this->guesser, $this->columnInfoTransformer, $this->transformerRegistry, $this->attributeManager, $this->doctrineCache); $this->addColumn('code'); $this->transformerRegistry->expects($this->any())->method('transform')->will($this->returnCallback(function ($class, $data) { $this->assertEquals('Pim\\Bundle\\CatalogBundle\\Entity\\AttributeOption', $class); $option = $this->getMock($class); foreach ($data as $key => $value) { $option->expects($this->any())->method('get' . ucfirst($key))->will($this->returnValue($value)); } return $option; })); }
protected function addColumn($name, $addTransformer = true, $addField = true, $skip = false, $failing = false, $suffixes = array()) { $label = implode('_', array_merge(array($name), $suffixes)); $column = parent::addColumn($label, $addTransformer, $skip, $failing, $suffixes); $column->expects($this->any())->method('getName')->will($this->returnValue($name)); if ($addField) { $this->fields[] = $column->getPropertyPath(); } else { $column->expects($this->any())->method('setAttribute')->with($this->equalTo($this->attributes[$label])); } }
protected function setUp() { parent::setUp(); $this->transformer = new EntityTransformer($this->doctrine, $this->propertyAccessor, $this->guesser, $this->columnInfoTransformer); $this->addColumn('code'); }