Skip to content

According to https://schema.org/Event, Event should extend Thing #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2019
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
19 changes: 16 additions & 3 deletions src/ContextTypes/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace JsonLd\ContextTypes;

class Event extends AbstractContext
class Event extends Thing
{
/**
* Property structure
*
* @var array
*/
protected $structure = [
protected $extendedStructure = [
'name' => null,
'startDate' => null,
'endDate' => null,
Expand All @@ -18,7 +18,20 @@ class Event extends AbstractContext
'location' => Place::class,
];

/**
/**
* Constructor. Merges extendedStructure up
*
* @param array $attributes
* @param array $extendedStructure
*/
public function __construct(array $attributes, array $extendedStructure = [])
{
parent::__construct(
$attributes, array_merge($this->structure, $this->extendedStructure, $extendedStructure)
);
}

/**
* Set offers attributes.
*
* @param mixed $values
Expand Down
26 changes: 26 additions & 0 deletions tests/ContextTypes/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class EventTest extends TestCase
'postalCode' => '06514',
],
],
'image' => 'https://google.com/some_logo.png',
'description' => 'A description',
];

/**
Expand Down Expand Up @@ -64,4 +66,28 @@ public function shouldHaveLocationObject()
],
], $context->getProperty('location'));
}

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

$this->assertEquals(
'https://google.com/some_logo.png'
, $context->getProperty('image'));
}

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

$this->assertEquals(
'A description'
, $context->getProperty('description'));
}
}