示例#1
0
 public function testResolve()
 {
     $this->contentTypeManager->get('content_type')->willReturn($this->contentType);
     $this->contentType->getViewData(Argument::any())->willReturn('view');
     $this->contentType->getContentData(Argument::any())->willReturn('content');
     $excerptExtension = $this->prophesize('Sulu\\Component\\Content\\Extension\\ExtensionInterface');
     $excerptExtension->getContentData(['test1' => 'test1'])->willReturn(['test1' => 'test1']);
     $this->structureManager->getExtension('test', 'excerpt')->willReturn($excerptExtension);
     $property = $this->prophesize('Sulu\\Component\\Content\\Compat\\PropertyInterface');
     $property->getName()->willReturn('property');
     $property->getContentTypeName()->willReturn('content_type');
     $structure = $this->prophesize('Sulu\\Component\\Content\\Compat\\Structure\\PageBridge');
     $structure->getKey()->willReturn('test');
     $structure->getExt()->willReturn(new ExtensionContainer(['excerpt' => ['test1' => 'test1']]));
     $structure->getUuid()->willReturn('some-uuid');
     $structure->getProperties(true)->willReturn([$property->reveal()]);
     $structure->getCreator()->willReturn(1);
     $structure->getChanger()->willReturn(1);
     $structure->getCreated()->willReturn('date');
     $structure->getChanged()->willReturn('date');
     $structure->getPublished()->willReturn('date');
     $structure->getPath()->willReturn('test-path');
     $structure->getUrls()->willReturn(['en' => '/description', 'de' => '/beschreibung', 'es' => null]);
     $structure->getShadowBaseLanguage()->willReturn('en');
     $expected = ['extension' => ['excerpt' => ['test1' => 'test1']], 'uuid' => 'some-uuid', 'view' => ['property' => 'view'], 'content' => ['property' => 'content'], 'creator' => 1, 'changer' => 1, 'created' => 'date', 'changed' => 'date', 'published' => 'date', 'template' => 'test', 'urls' => ['en' => '/description', 'de' => '/beschreibung', 'es' => null], 'path' => 'test-path', 'shadowBaseLocale' => 'en'];
     $this->assertEquals($expected, $this->structureResolver->resolve($structure->reveal()));
 }
示例#2
0
 public function testRemove()
 {
     $this->property->expects($this->any())->method('getName')->will($this->returnValue('i18n:de-hotels'));
     $pageNode = $this->session->getNode('/cmf/sulu_io/contents/hotels');
     $this->contentType->remove($pageNode, $this->property, 'sulu_io', 'de', null);
     $this->session->save();
     $this->assertFalse($pageNode->hasProperty('i18n:de-hotels'));
 }
示例#3
0
 private function doGetProperty($name, $contentTypeName, $locale)
 {
     $this->propertyMetadata->getType()->willReturn($contentTypeName);
     $this->structureMetadata->getProperty($name)->willReturn($this->propertyMetadata);
     $this->contentTypeManager->get($contentTypeName)->willReturn($this->contentType->reveal());
     if ($locale) {
         $this->propertyFactory->createTranslatedProperty($this->propertyMetadata->reveal(), $locale, Argument::type(StructureBridge::class))->willReturn($this->legacyProperty->reveal());
     } else {
         $this->propertyFactory->createProperty($this->propertyMetadata->reveal(), $locale)->willReturn($this->legacyProperty->reveal());
     }
     $this->contentType->read($this->node->reveal(), $this->legacyProperty->reveal(), null, null, null)->shouldBeCalledTimes(1);
     $property = $this->structure->getProperty($name);
     $this->assertInstanceOf(PropertyValue::class, $property);
     $this->assertEquals($name, $property->getName());
 }
 /**
  * It should set the structure type and map the content to thethe node.
  */
 public function testPersist()
 {
     $document = new TestContentDocument($this->structure->reveal());
     $document->setStructureType('foobar');
     $this->persistEvent->getDocument()->willReturn($document);
     // map the structure type
     $this->persistEvent->getLocale()->willReturn('fr');
     $this->encoder->contentName('template')->willReturn('i18n:fr-template');
     $this->node->setProperty('i18n:fr-template', 'foobar')->shouldBeCalled();
     // map the content
     $this->inspector->getStructureMetadata($document)->willReturn($this->structureMetadata->reveal());
     $this->inspector->getWebspace($document)->willReturn('webspace');
     $this->structureMetadata->getProperties()->willReturn(['prop1' => $this->structureProperty->reveal()]);
     $this->structureProperty->isRequired()->willReturn(true);
     $this->structureProperty->getContentTypeName()->willReturn('content_type');
     $this->contentTypeManager->get('content_type')->willReturn($this->contentType->reveal());
     $this->propertyFactory->createTranslatedProperty($this->structureProperty->reveal(), 'fr')->willReturn($this->legacyProperty->reveal());
     $this->structure->getProperty('prop1')->willReturn($this->propertyValue->reveal());
     $this->propertyValue->getValue()->willReturn('test');
     $this->contentType->remove($this->node->reveal(), $this->legacyProperty->reveal(), 'webspace', 'fr', null)->shouldBeCalled();
     $this->contentType->write($this->node->reveal(), $this->legacyProperty->reveal(), null, 'webspace', 'fr', null)->shouldBeCalled();
     $this->subscriber->handlePersist($this->persistEvent->reveal());
 }