Inheritance: extends Sulu\Component\Content\ComplexContentType, implements Sulu\Component\Content\ContentTypeExportInterface
Ejemplo n.º 1
0
 public function testGetContentDataNullPropertyValue()
 {
     $categoryManager = $this->prophesize(CategoryManagerInterface::class);
     $categoryList = new CategoryList($categoryManager->reveal(), '');
     $property = $this->prophesize(Property::class);
     $property->getValue()->willReturn(null);
     $result = $categoryList->getContentData($property->reveal());
     $this->assertEquals([], $result);
     $categoryManager->findByIds(Argument::any())->shouldNotBeCalled();
     $categoryManager->getApiObjects(Argument::any(), Argument::any())->shouldNotBeCalled();
 }
Ejemplo n.º 2
0
 public function testRead()
 {
     $categoryEntity1 = new CategoryEntity();
     $categoryTranslation1 = new CategoryTranslationEntity();
     $categoryTranslation1->setLocale('en');
     $categoryTranslation1->setTranslation('Category 1');
     $categoryEntity1->addTranslation($categoryTranslation1);
     $categoryEntity2 = new CategoryEntity();
     $categoryTranslation2 = new CategoryTranslationEntity();
     $categoryTranslation2->setLocale('en');
     $categoryTranslation2->setTranslation('Category 2');
     $categoryEntity2->addTranslation($categoryTranslation2);
     $category1 = new Category($categoryEntity1, 'en');
     $category2 = new Category($categoryEntity2, 'en');
     $this->categoryManager->expects($this->any())->method('findByIds')->will($this->returnValueMap([[[1, 2], [$categoryEntity1, $categoryEntity2]]]));
     $this->categoryManager->expects($this->any())->method('getApiObjects')->will($this->returnValueMap([[[$categoryEntity1, $categoryEntity2], 'en', [$category1, $category2]]]));
     $node = $this->getMockBuilder('PHPCR\\NodeInterface')->getMock();
     $node->expects($this->any())->method('getPropertyValueWithDefault')->will($this->returnValueMap([['property', [], [1, 2]]]));
     $property = $this->getMockBuilder('Sulu\\Component\\Content\\Compat\\PropertyInterface')->getMock();
     $property->expects($this->any())->method('getName')->willReturn('property');
     $property->expects($this->any())->method('setValue')->with([$category1->toArray(), $category2->toArray()]);
     $this->categoryManager->expects($this->once())->method('findByIds');
     $this->categoryList->read($node, $property, null, 'en', null);
 }