/** * @covers Contentful\Delivery\ContentType::__construct * @covers Contentful\Delivery\ContentType::getId * @covers Contentful\Delivery\ContentType::getName * @covers Contentful\Delivery\ContentType::getDescription * @covers Contentful\Delivery\ContentType::getSpace * @covers Contentful\Delivery\ContentType::getDisplayField * @covers Contentful\Delivery\ContentType::getCreatedAt * @covers Contentful\Delivery\ContentType::getUpdatedAt * @covers Contentful\Delivery\ContentType::getRevision * @covers Contentful\Delivery\ContentType::getField * @covers Contentful\Delivery\ContentType::getFields * * @uses Contentful\Delivery\SystemProperties::__construct * @uses Contentful\Delivery\SystemProperties::getId * @uses Contentful\Delivery\SystemProperties::getSpace * @uses Contentful\Delivery\SystemProperties::getCreatedAt * @uses Contentful\Delivery\SystemProperties::getUpdatedAt * @uses Contentful\Delivery\SystemProperties::getRevision * * @uses Contentful\Delivery\ContentTypeField::__construct * @uses Contentful\Delivery\ContentTypeField::getId * @uses Contentful\Delivery\ContentTypeField::getName */ public function testGetter() { $space = $this->getMockBuilder(Space::class)->disableOriginalConstructor()->getMock(); $displayField = new ContentTypeField('name', 'Name', 'Text', null, null, null, true); $contentType = new ContentType('Human', 'Also called h**o sapien', [$displayField, new ContentTypeField('likes', 'Likes', 'Array', null, 'Symbol', null), new ContentTypeField('image', 'Image', 'Array', null, 'Link', 'Asset', false, false, true)], $displayField->getId(), new SystemProperties('human', 'ContentType', $space, null, 3, new \DateTimeImmutable('2013-06-27T22:46:14.133Z'), new \DateTimeImmutable('2013-09-02T15:10:26.818Z'))); $this->assertEquals('human', $contentType->getId()); $this->assertEquals('Human', $contentType->getName()); $this->assertEquals('Also called h**o sapien', $contentType->getDescription()); $this->assertEquals($space, $contentType->getSpace()); $this->assertEquals($displayField, $contentType->getDisplayField()); $this->assertEquals(new \DateTimeImmutable('2013-06-27T22:46:14.133Z'), $contentType->getCreatedAt()); $this->assertEquals(new \DateTimeImmutable('2013-09-02T15:10:26.818Z'), $contentType->getUpdatedAt()); $this->assertEquals(3, $contentType->getRevision()); $this->assertEquals('Likes', $contentType->getField('likes')->getName()); $fields = $contentType->getFields(); $this->assertInternalType('array', $fields); $this->assertCount(3, $fields); $this->assertArrayHasKey('name', $fields); $this->assertEquals($displayField, $fields['name']); }
/** * 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()); }