Skip to content

activity definition properties are optional #7

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
Apr 11, 2016
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CHANGELOG
=========

* all values of an activity definition are optional, pass `null` to omit them

* all values of a result are optional, pass `null` to omit them

* throw an exception when not existing document data is accessed instead of
Expand Down
45 changes: 45 additions & 0 deletions spec/DefinitionSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/*
* This file is part of the xAPI package.
*
* (c) Christian Flothmann <christian.flothmann@xabbuh.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace spec\Xabbuh\XApi\Model;

use PhpSpec\ObjectBehavior;

class DefinitionSpec extends ObjectBehavior
{
function its_properties_can_be_read()
{
$this->beConstructedWith(
array('en-US' => 'test'),
array('en-US' => 'test'),
'http://id.tincanapi.com/activitytype/unit-test'
);

$name = $this->getName();
$name->shouldBeArray();
$name->shouldHaveCount(1);
$name->shouldHaveKeyWithValue('en-US', 'test');

$description = $this->getName();
$description->shouldBeArray();
$description->shouldHaveCount(1);
$description->shouldHaveKeyWithValue('en-US', 'test');

$this->getType()->shouldReturn('http://id.tincanapi.com/activitytype/unit-test');
}

function it_can_be_empty()
{
$this->getName()->shouldReturn(null);
$this->getDescription()->shouldReturn(null);
$this->getType()->shouldReturn(null);
}
}
7 changes: 6 additions & 1 deletion src/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ final class Definition
*/
private $type;

public function __construct(array $name, array $description, $type)
/**
* @param array|null $name
* @param array|null $description
* @param string|null $type
*/
public function __construct(array $name = null, array $description = null, $type = null)
{
$this->name = $name;
$this->description = $description;
Expand Down