Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ContextTypes/WebSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ class WebSite extends AbstractContext
'image' => null,
'name' => null,
'url' => null,
'publisher' => Organization::class,
'keywords' => null,
'inLanguage' => null,
'dateCreated' => null,
'dateModified' => null,
'datePublished' => null,
'sameAs' => null,
];
}
22 changes: 22 additions & 0 deletions tests/ContextTypes/ArticleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class ArticleTest extends TestCase
'height' => 60,
]
],
'keywords' => 'Lorem,ipsum,dolor',
'inLanguage' => 'en',
'dateCreated' => '2013-10-04T00:00',
'dateModified' => '2013-10-04T00:00',
'datePublished' => '2013-10-04T00:00',
Expand Down Expand Up @@ -130,6 +132,26 @@ public function shouldHavePublisherObject()
], $context->getProperty('publisher'));
}

/**
* @test
*/
public function shouldHaveKeywords()
{
$context = $this->make();

$this->assertEquals('Lorem,ipsum,dolor', $context->getProperty('keywords'));
}

/**
* @test
*/
public function shouldHaveInLanguage()
{
$context = $this->make();

$this->assertEquals('en', $context->getProperty('inLanguage'));
}

/**
* @test
*/
Expand Down
74 changes: 69 additions & 5 deletions tests/ContextTypes/WebSiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@ class WebSiteTest extends TestCase

protected $attributes = [
'about' => 'The subject matter of the content.',
'headline' => 'Headline of the article.',
'headline' => 'Headline of the website.',
'image' => 'https://og.github.com/mark/github-mark@1200x630.png',
'name' => 'The name of the item.',
'url' => 'https://schema.org/WebSite',
'publisher' => [
'name' => 'Google',
'logo' => [
'@type' => 'ImageObject',
'url' => 'https://google.com/logo.jpg',
'width' => 600,
'height' => 60,
]
],
'keywords' => 'about,headline,image,name,url',
'inLanguage' => 'en',
'dateCreated' => '2013-10-04T00:00',
'dateModified' => '2013-10-04T00:00',
'datePublished' => '2013-10-04T00:00',
'sameAs' => 'https://schema.org/sameAs',
];

Expand All @@ -25,9 +38,60 @@ public function shouldGetProperties()
{
$context = $this->make();

$this->assertEquals(array_merge([
'@context' => 'http://schema.org',
'@type' => 'WebSite',
], $this->attributes), $context->getProperties());
$attributesPlus = $this->attributes;
$attributesPlus['@context'] = 'http://schema.org';
$attributesPlus["@type"] = 'WebSite';
$attributesPlus["publisher"]["@type"] = 'Organization';

$this->assertEquals($context->getProperties(), $attributesPlus);
}

/**
* @test
*/
public function shouldHaveHeadline()
{
$context = $this->make();

$this->assertEquals('Headline of the website.', $context->getProperty('headline'));
}

/**
* @test
*/
public function shouldHavePublisherObject()
{
$context = $this->make();

$this->assertEquals([
'@type' => 'Organization',
'name' => 'Google',
'logo' => [
'@type' => 'ImageObject',
'url' => 'https://google.com/logo.jpg',
'height' => 60,
'width' => 600,
],
], $context->getProperty('publisher'));
}

/**
* @test
*/
public function shouldHaveKeywords()
{
$context = $this->make();

$this->assertEquals('about,headline,image,name,url', $context->getProperty('keywords'));
}

/**
* @test
*/
public function shouldHaveInLanguage()
{
$context = $this->make();

$this->assertEquals('en', $context->getProperty('inLanguage'));
}
}