/** * @covers Contentful\Delivery\ContentType::__construct * @covers Contentful\Delivery\ContentType::getDescription * @covers Contentful\Delivery\ContentType::getField * @covers Contentful\Delivery\ContentType::getDisplayField * * @uses Contentful\Delivery\SystemProperties::__construct * @uses Contentful\Delivery\SystemProperties::getId * * @uses Contentful\Delivery\ContentTypeField::__construct * @uses Contentful\Delivery\ContentTypeField::getId */ public function testGetterNotExisting() { $space = $this->getMockBuilder(Space::class)->disableOriginalConstructor()->getMock(); $contentType = new ContentType('Human', null, [new ContentTypeField('likes', 'Likes', 'Array', null, 'Symbol', null), new ContentTypeField('image', 'Image', 'Array', null, 'Link', 'Asset', false, false, true)], null, new SystemProperties('human', 'ContentType', $space, null, 3, new \DateTimeImmutable('2013-06-27T22:46:14.133Z'), new \DateTimeImmutable('2013-09-02T15:10:26.818Z'))); $this->assertNull($contentType->getDescription()); $this->assertNull($contentType->getField('notExisting')); $this->assertNull($contentType->getDisplayField()); }
/** * Get the class name for and entry of the provided ContentType. * * @param ContentType $contentType * * @return string * * @api */ public function getClassName(ContentType $contentType) { return 'Entry' . ucfirst($contentType->getId()); }
/** * @param ContentType $contentType * @param object $fields * * @return object */ private function buildFields(ContentType $contentType, $fields) { $result = new \stdClass(); foreach ($fields as $name => $fieldData) { $fieldConfig = $contentType->getField($name); if ($fieldConfig->isDisabled()) { continue; } $result->{$name} = $this->buildField($fieldConfig, $fieldData); } return $result; }