protected function setUp() { parent::setUp(); $this->fields = array(); $this->values = array(); $this->attributes = array(); $this->metadata->expects($this->any())->method('hasField')->will($this->returnCallback(function ($propertyPath) { return in_array($propertyPath, $this->fields); })); $this->product = $this->getMockBuilder('Pim\\Bundle\\CatalogBundle\\Model\\Product')->setMockClassName('product_class')->getMock(); $this->product->expects($this->any())->method('getReference')->will($this->returnValue('id')); $this->productRepository = $this->getMock('Pim\\Bundle\\CatalogBundle\\Repository\\ReferableEntityRepositoryInterface', ['getReferenceProperties', 'findByReference']); $this->productManager = $this->getMockBuilder('Pim\\Bundle\\CatalogBundle\\Manager\\ProductManager')->disableOriginalConstructor()->getMock(); $this->productManager->expects($this->any())->method('createProduct')->will($this->returnValue($this->product)); $this->productManager->expects($this->any())->method('getProductRepository')->will($this->returnValue($this->productRepository)); $this->productManager->expects($this->any())->method('getProductValueName')->will($this->returnValue('product_value_class')); $this->productManager->expects($this->any())->method('createProductValue')->will($this->returnCallback(array($this, 'createValue'))); $this->attributeCache = $this->getMockBuilder('Pim\\Bundle\\TransformBundle\\Cache\\AttributeCache')->disableOriginalConstructor()->getMock(); $this->attributeCache->expects($this->any())->method('getAttributes')->will($this->returnCallback(array($this, 'getAttributes'))); $this->attributeCache->expects($this->any())->method('getRequiredAttributeCodes')->will($this->returnValue(array('required'))); $this->associationsReader = $this->getMock('Pim\\Bundle\\BaseConnectorBundle\\Reader\\CachedReader'); $this->addAttribute('identifier', ProductTransformer::IDENTIFIER_ATTRIBUTE_TYPE); $this->addColumn('identifier', true, false); $this->transformer = new ProductTransformer($this->doctrine, $this->propertyAccessor, $this->guesser, $this->columnInfoTransformer, $this->productManager, $this->attributeCache, $this->associationsReader); }
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 setUp() { parent::setUp(); $this->transformer = new EntityTransformer($this->doctrine, $this->propertyAccessor, $this->guesser, $this->columnInfoTransformer); $this->addColumn('code'); }