addTranslation() public method

public addTranslation ( Sulu\Bundle\CategoryBundle\Entity\CategoryTranslationInterface $translations )
$translations Sulu\Bundle\CategoryBundle\Entity\CategoryTranslationInterface
コード例 #1
0
ファイル: CategoryListTest.php プロジェクト: Silwereth/sulu
 public function testGetContentData()
 {
     $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');
     $categoryManager = $this->prophesize(CategoryManagerInterface::class);
     $categoryManager->findByIds([1, 2])->willReturn([$categoryEntity1, $categoryEntity2]);
     $categoryManager->getApiObjects([$categoryEntity1, $categoryEntity2], 'de')->willReturn([$category1, $category2]);
     $categoryList = new CategoryList($categoryManager->reveal(), '');
     $structure = $this->prophesize(StructureInterface::class);
     $structure->getLanguageCode()->willReturn('de');
     $property = $this->prophesize(Property::class);
     $property->getValue()->willReturn([1, 2]);
     $property->getStructure()->willReturn($structure->reveal());
     $result = $categoryList->getContentData($property->reveal());
     $this->assertEquals([$category1->toArray(), $category2->toArray()], $result);
     $categoryManager->findByIds([1, 2])->shouldBeCalled();
     $categoryManager->getApiObjects([$categoryEntity1, $categoryEntity2], 'de')->shouldBeCalled();
 }
コード例 #2
0
ファイル: CategoryListTest.php プロジェクト: kriswillis/sulu
 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);
 }