Skip to content

Commit

Permalink
Merge pull request #39 from boly38/feature/website
Browse files Browse the repository at this point in the history
improve WebSite context
  • Loading branch information
Torann authored Jun 27, 2018
2 parents 9d85b71 + edf2607 commit eb7456d
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 5 deletions.
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/[email protected]',
'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'));
}
}

0 comments on commit eb7456d

Please sign in to comment.