예제 #1
0
 /**
  * It should create a translated property.
  *
  * @depends testCreateProperty
  */
 public function testCreateTranslated()
 {
     $this->setUpProperty($this->property1);
     $this->namespaceRegistry->getPrefix('content_localized')->willReturn('i18n');
     $translatedProperty = $this->factory->createTranslatedProperty($this->property1->reveal(), 'de');
     $this->assertEquals('de', $translatedProperty->getLocalization());
     $this->assertEquals('i18n:de-name', $translatedProperty->getName());
 }
예제 #2
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());
 }
예제 #3
0
 /**
  * It should throw an exception if the property is required but the value is null.
  *
  * @expectedException Sulu\Component\Content\Exception\MandatoryPropertyException
  */
 public function testThrowExceptionPropertyRequired()
 {
     $document = new TestContentDocument($this->structure->reveal());
     $document->setStructureType('foobar');
     $this->persistEvent->getDocument()->willReturn($document);
     // map the structure type
     $this->persistEvent->getLocale()->willReturn('fr');
     // 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->structure->getProperty('prop1')->willReturn($this->propertyValue->reveal());
     $this->propertyValue->getValue()->willReturn(null);
     $this->structureMetadata->getName()->willReturn('test');
     $this->structureMetadata->getResource()->willReturn('/path/to/resource.xml');
     $this->subscriber->handlePersist($this->persistEvent->reveal());
 }