isRequired() public method

public isRequired ( )
コード例 #1
0
 /**
  * It should create standard properties from "new" properties.
  */
 public function testCreateProperty()
 {
     $name = 'foo';
     $title = ['de' => 'Tite'];
     $description = ['de' => 'Description'];
     $placeholder = ['de' => 'Placehodler'];
     $type = 'type';
     $required = true;
     $localized = true;
     $maxOccurs = 1;
     $minOccurs = 1;
     $parameters = [['name' => 'prop', 'type' => 'type', 'value' => 'value', 'meta' => []], ['name' => 'propfoo', 'type' => 'type', 'value' => 'value', 'meta' => []]];
     $colSpan = 6;
     $this->property1->getType()->willReturn($type);
     $this->property1->getName()->willReturn($name);
     $this->property1->isRequired()->willReturn($required);
     $this->property1->isLocalized()->willReturn($required);
     $this->property1->getMaxOccurs()->willReturn($maxOccurs);
     $this->property1->getMinOccurs()->willReturn($minOccurs);
     $this->property1->getColSpan()->willReturn($colSpan);
     $this->property1->getParameters()->willReturn($parameters);
     $this->property1->title = $title;
     $this->property1->description = $description;
     $this->property1->placeholder = $placeholder;
     $legacyProperty = $this->factory->createProperty($this->property1->reveal());
     $this->assertInstanceOf(LegacyPropertyInterface::class, $legacyProperty);
     $this->assertEquals($legacyProperty->getContentTypeName(), $type);
     $this->assertEquals($legacyProperty->getName(), $name);
     $this->assertEquals($legacyProperty->getMandatory(), $required);
     $this->assertEquals($legacyProperty->getMultilingual(), $localized);
     $this->assertEquals($legacyProperty->getMaxOccurs(), $maxOccurs);
     $this->assertEquals($legacyProperty->getMinOccurs(), $minOccurs);
     $this->assertEquals($legacyProperty->getColspan(), $colSpan);
     $this->assertContainsOnlyInstancesOf(PropertyParameter::class, $legacyProperty->getParams());
     $this->assertArrayHasKey('prop', $legacyProperty->getParams());
     $this->assertArrayHasKey('propfoo', $legacyProperty->getParams());
     $this->assertEquals($title['de'], $legacyProperty->getTitle('de'));
     $this->assertEquals($description['de'], $legacyProperty->getInfoText('de'));
     $this->assertEquals($placeholder['de'], $legacyProperty->getPlaceholder('de'));
     return $this->property1;
 }
コード例 #2
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());
 }