Example #1
0
 /**
  * It should get a legacy structure bridge.
  */
 public function testGetStructure()
 {
     $structureType = 'content';
     $documentType = 'page';
     $this->factory->getStructureMetadata($documentType, $structureType)->willReturn($this->structure->reveal());
     $bridge = $this->structureManager->getStructure($structureType, $documentType);
     $this->assertInstanceOf(StructureBridge::class, $bridge);
 }
 /**
  * It returns all structures that are available.
  */
 public function testGetStructures()
 {
     $this->loader->load($this->mappingFile, 'page')->willReturn($this->structure->reveal());
     $this->loader->load($this->mappingFile, 'page')->shouldBeCalledTimes(1);
     $structures = $this->factory->getStructures('page');
     $this->assertEquals($this->structure->reveal(), $structures[0]);
 }
 /**
  * It returns all structures that are available.
  */
 public function testGetStructures()
 {
     $this->loader->load($this->somethingMappingFile, 'page')->willReturn($this->somethingStructure->reveal());
     $this->loader->load($this->defaultMappingFile, 'page')->willReturn($this->defaultStructure->reveal());
     $this->loader->load($this->somethingMappingFile, 'page')->shouldBeCalledTimes(1);
     $this->loader->load($this->defaultMappingFile, 'page')->shouldBeCalledTimes(1);
     $structures = $this->factory->getStructures('page');
     $this->assertCount(3, $structures);
     $this->assertEquals($this->defaultStructure->reveal(), $structures[0]);
     $this->assertEquals($this->somethingStructure->reveal(), $structures[1]);
     $this->assertEquals($this->defaultStructure->reveal(), $structures[2]);
 }
Example #4
0
 public function setUp()
 {
     $this->contentTypeManager = $this->prophesize(ContentTypeManagerInterface::class);
     $this->node = $this->prophesize(NodeInterface::class);
     $this->structureMetadata = $this->prophesize(StructureMetadata::class);
     $this->document = $this->prophesize(StructureBehavior::class);
     $this->contentType = $this->prophesize(ContentTypeInterface::class);
     $this->encoder = $this->prophesize(PropertyEncoder::class);
     $this->propertyMetadata = $this->prophesize(PropertyMetadata::class);
     $this->propertyFactory = $this->prophesize(LegacyPropertyFactory::class);
     $this->inspector = $this->prophesize(DocumentInspector::class);
     $this->legacyProperty = $this->prophesize(PropertyInterface::class);
     $this->structure = new ManagedStructure($this->contentTypeManager->reveal(), $this->propertyFactory->reveal(), $this->inspector->reveal(), $this->document->reveal());
     $this->inspector->getNode($this->document->reveal())->willReturn($this->node->reveal());
     $this->inspector->getStructureMetadata($this->document->reveal())->willReturn($this->structureMetadata->reveal());
 }
 /**
  * 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());
 }