This commit is contained in:
Xes
2025-08-14 22:41:49 +02:00
parent 2de81ccc46
commit 8ce45119b6
39774 changed files with 4309466 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\ChoiceInteractionDefinition;
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
class ChoiceInteractionDefinitionSpec extends InteractionDefinitionSpec
{
public function it_returns_a_new_instance_with_choices()
{
$choices = array(new InteractionComponent('test'));
$interaction = $this->withChoices($choices);
$this->getChoices()->shouldBeNull();
$interaction->shouldNotBe($this);
$interaction->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Interaction\ChoiceInteractionDefinition');
$interaction->getChoices()->shouldReturn($choices);
}
function it_is_not_equal_if_only_other_interaction_has_choices()
{
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withChoices(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_only_this_interaction_has_choices()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$this->equals($this->createEmptyDefinition())->shouldReturn(false);
}
function it_is_not_equal_if_number_of_choices_differs()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withChoices(array(new InteractionComponent('test'), new InteractionComponent('foo')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_choices_differ()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('foo')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withChoices(array(new InteractionComponent('bar')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_equal_if_choices_are_equal()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withChoices(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(true);
}
protected function createEmptyDefinition()
{
return new ChoiceInteractionDefinition();
}
}

View File

@@ -0,0 +1,22 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\FillInInteractionDefinition;
class FillInInteractionDefinitionSpec extends InteractionDefinitionSpec
{
protected function createEmptyDefinition()
{
return new FillInInteractionDefinition();
}
}

View File

@@ -0,0 +1,81 @@
<?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\Interaction;
use PhpSpec\ObjectBehavior;
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
use Xabbuh\XApi\Model\LanguageMap;
class InteractionComponentSpec extends ObjectBehavior
{
function its_properties_can_be_read()
{
$description = LanguageMap::create(array('en-US' => 'test'));
$this->beConstructedWith('test', $description);
$this->getId()->shouldReturn('test');
$this->getDescription()->shouldReturn($description);
}
function it_is_not_equal_with_other_interaction_component_if_ids_differ()
{
$description = LanguageMap::create(array('en-US' => 'test'));
$this->beConstructedWith('test', $description);
$interactionComponent = new InteractionComponent('Test', $description);
$this->equals($interactionComponent)->shouldReturn(false);
}
function it_is_not_equal_with_other_interaction_component_if_descriptions_differ()
{
$this->beConstructedWith('test', LanguageMap::create(array('en-US' => 'test')));
$interactionComponent = new InteractionComponent('test', LanguageMap::create(array('en-GB' => 'test')));
$this->equals($interactionComponent)->shouldReturn(false);
}
function it_is_not_equal_with_other_interaction_component_if_other_interaction_component_does_not_have_a_description()
{
$this->beConstructedWith('test', LanguageMap::create(array('en-US' => 'test')));
$interactionComponent = new InteractionComponent('test');
$this->equals($interactionComponent)->shouldReturn(false);
}
function it_is_not_equal_with_other_interaction_component_if_only_the_other_interaction_component_does_have_a_description()
{
$this->beConstructedWith('test');
$interactionComponent = new InteractionComponent('test', LanguageMap::create(array('en-US' => 'test')));
$this->equals($interactionComponent)->shouldReturn(false);
}
function it_is_equal_with_other_interaction_component_if_ids_and_descriptions_are_equal()
{
$this->beConstructedWith('test', LanguageMap::create(array('en-US' => 'test')));
$interactionComponent = new InteractionComponent('test', LanguageMap::create(array('en-US' => 'test')));
$this->equals($interactionComponent)->shouldReturn(true);
}
function it_is_equal_with_other_interaction_component_if_ids_are_equal_and_descriptions_are_not_present()
{
$this->beConstructedWith('test');
$this->equals(new InteractionComponent('test'))->shouldReturn(true);
}
}

View File

@@ -0,0 +1,79 @@
<?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\Interaction;
use spec\Xabbuh\XApi\Model\DefinitionSpec;
use Xabbuh\XApi\Model\Definition;
use Xabbuh\XApi\Model\Interaction\InteractionDefinition;
abstract class InteractionDefinitionSpec extends DefinitionSpec
{
function it_is_a_definition()
{
$this->shouldHaveType(Definition::class);
}
function it_is_an_interaction()
{
$this->shouldHaveType(InteractionDefinition::class);
}
function it_is_not_equal_to_generic_definition()
{
$this->equals(new Definition())->shouldReturn(false);
}
function it_is_not_equal_if_only_other_interaction_has_correct_responses_pattern()
{
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withCorrectResponsesPattern(array('test'));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_only_this_interaction_has_correct_responses_pattern()
{
$this->beConstructedWith(null, null, null, null, null, array('test'));
$this->equals($this->createEmptyDefinition())->shouldReturn(false);
}
function it_is_not_equal_if_number_of_correct_responses_pattern_differs()
{
$this->beConstructedWith(null, null, null, null, null, array('test'));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withCorrectResponsesPattern(array('test', 'foo'));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_correct_responses_pattern_values_differ()
{
$this->beConstructedWith(null, null, null, null, null, array('foo'));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withCorrectResponsesPattern(array('bar'));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_equal_if_correct_responses_pattern_values_are_equal()
{
$this->beConstructedWith(null, null, null, null, null, array('test'));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withCorrectResponsesPattern(array('test'));
$this->equals($interaction)->shouldReturn(true);
}
}

View File

@@ -0,0 +1,80 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
use Xabbuh\XApi\Model\Interaction\LikertInteractionDefinition;
class LikertInteractionDefinitionSpec extends InteractionDefinitionSpec
{
public function it_returns_a_new_instance_with_scale()
{
$scale = array(new InteractionComponent('test'));
$interaction = $this->withScale($scale);
$this->getScale()->shouldBeNull();
$interaction->shouldNotBe($this);
$interaction->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Interaction\LikertInteractionDefinition');
$interaction->getScale()->shouldReturn($scale);
}
function it_is_not_equal_if_only_other_interaction_has_scale()
{
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withScale(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_only_this_interaction_has_scale()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$this->equals($this->createEmptyDefinition())->shouldReturn(false);
}
function it_is_not_equal_if_number_of_scale_differs()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withScale(array(new InteractionComponent('test'), new InteractionComponent('foo')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_scale_differ()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('foo')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withScale(array(new InteractionComponent('bar')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_equal_if_scales_are_equal()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withScale(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(true);
}
protected function createEmptyDefinition()
{
return new LikertInteractionDefinition();
}
}

View File

@@ -0,0 +1,22 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\LongFillInInteractionDefinition;
class LongFillInInteractionDefinitionSpec extends InteractionDefinitionSpec
{
protected function createEmptyDefinition()
{
return new LongFillInInteractionDefinition();
}
}

View File

@@ -0,0 +1,137 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
use Xabbuh\XApi\Model\Interaction\MatchingInteractionDefinition;
class MatchingInteractionDefinitionSpec extends InteractionDefinitionSpec
{
public function it_returns_a_new_instance_with_source()
{
$source = array(new InteractionComponent('test'));
$interaction = $this->withSource($source);
$this->getSource()->shouldBeNull();
$interaction->shouldNotBe($this);
$interaction->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Interaction\MatchingInteractionDefinition');
$interaction->getSource()->shouldReturn($source);
}
public function it_returns_a_new_instance_with_target()
{
$target = array(new InteractionComponent('test'));
$interaction = $this->withTarget($target);
$this->getTarget()->shouldBeNull();
$interaction->shouldNotBe($this);
$interaction->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Interaction\MatchingInteractionDefinition');
$interaction->getTarget()->shouldReturn($target);
}
function it_is_not_equal_if_only_other_interaction_has_source()
{
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withSource(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_only_this_interaction_has_source()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$this->equals($this->createEmptyDefinition())->shouldReturn(false);
}
function it_is_not_equal_if_number_of_source_differs()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withSource(array(new InteractionComponent('test'), new InteractionComponent('foo')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_source_differ()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('foo')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withSource(array(new InteractionComponent('bar')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_equal_if_sources_are_equal()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withSource(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(true);
}
function it_is_not_equal_if_only_other_interaction_has_target()
{
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withTarget(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_only_this_interaction_has_target()
{
$this->beConstructedWith(null, null, null, null, null, null, null, array(new InteractionComponent('test')));
$this->equals($this->createEmptyDefinition())->shouldReturn(false);
}
function it_is_not_equal_if_number_of_target_differs()
{
$this->beConstructedWith(null, null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withTarget(array(new InteractionComponent('test'), new InteractionComponent('foo')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_target_differ()
{
$this->beConstructedWith(null, null, null, null, null, null, null, array(new InteractionComponent('foo')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withTarget(array(new InteractionComponent('bar')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_equal_if_targets_are_equal()
{
$this->beConstructedWith(null, null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withTarget(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(true);
}
protected function createEmptyDefinition()
{
return new MatchingInteractionDefinition();
}
}

View File

@@ -0,0 +1,22 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\NumericInteractionDefinition;
class NumericInteractionDefinitionSpec extends InteractionDefinitionSpec
{
protected function createEmptyDefinition()
{
return new NumericInteractionDefinition();
}
}

View File

@@ -0,0 +1,22 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\OtherInteractionDefinition;
class OtherInteractionDefinitionSpec extends InteractionDefinitionSpec
{
protected function createEmptyDefinition()
{
return new OtherInteractionDefinition();
}
}

View File

@@ -0,0 +1,80 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
use Xabbuh\XApi\Model\Interaction\PerformanceInteractionDefinition;
class PerformanceInteractionDefinitionSpec extends InteractionDefinitionSpec
{
public function it_returns_a_new_instance_with_steps()
{
$steps = array(new InteractionComponent('test'));
$interaction = $this->withSteps($steps);
$this->getSteps()->shouldBeNull();
$interaction->shouldNotBe($this);
$interaction->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Interaction\PerformanceInteractionDefinition');
$interaction->getSteps()->shouldReturn($steps);
}
function it_is_not_equal_if_only_other_interaction_has_steps()
{
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withSteps(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_only_this_interaction_has_steps()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$this->equals($this->createEmptyDefinition())->shouldReturn(false);
}
function it_is_not_equal_if_number_of_steps_differs()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withSteps(array(new InteractionComponent('test'), new InteractionComponent('foo')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_steps_differ()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('foo')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withSteps(array(new InteractionComponent('bar')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_equal_if_steps_are_equal()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withSteps(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(true);
}
protected function createEmptyDefinition()
{
return new PerformanceInteractionDefinition();
}
}

View File

@@ -0,0 +1,80 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
use Xabbuh\XApi\Model\Interaction\SequencingInteractionDefinition;
class SequencingInteractionDefinitionSpec extends InteractionDefinitionSpec
{
public function it_returns_a_new_instance_with_choices()
{
$choices = array(new InteractionComponent('test'));
$interaction = $this->withChoices($choices);
$this->getChoices()->shouldBeNull();
$interaction->shouldNotBe($this);
$interaction->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\Interaction\SequencingInteractionDefinition');
$interaction->getChoices()->shouldReturn($choices);
}
function it_is_not_equal_if_only_other_interaction_has_choices()
{
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withChoices(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_only_this_interaction_has_choices()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$this->equals($this->createEmptyDefinition())->shouldReturn(false);
}
function it_is_not_equal_if_number_of_choices_differs()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withChoices(array(new InteractionComponent('test'), new InteractionComponent('foo')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_not_equal_if_choices_differ()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('foo')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withChoices(array(new InteractionComponent('bar')));
$this->equals($interaction)->shouldReturn(false);
}
function it_is_equal_if_choices_are_equal()
{
$this->beConstructedWith(null, null, null, null, null, null, array(new InteractionComponent('test')));
$interaction = $this->createEmptyDefinition();
$interaction = $interaction->withChoices(array(new InteractionComponent('test')));
$this->equals($interaction)->shouldReturn(true);
}
protected function createEmptyDefinition()
{
return new SequencingInteractionDefinition();
}
}

View File

@@ -0,0 +1,22 @@
<?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\Interaction;
use Xabbuh\XApi\Model\Interaction\TrueFalseInteractionDefinition;
class TrueFalseInteractionDefinitionSpec extends InteractionDefinitionSpec
{
protected function createEmptyDefinition()
{
return new TrueFalseInteractionDefinition();
}
}