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,40 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
use Xabbuh\XApi\DataFixtures\AccountFixtures;
use Xabbuh\XApi\Model\IRL;
use XApi\Fixtures\Json\AccountJsonFixtures;
class AccountNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
function it_supports_normalizing_accounts()
{
$this->supportsNormalization(AccountFixtures::getTypicalAccount())->shouldBe(true);
}
function it_denormalizes_accounts()
{
$account = $this->denormalize(array('homePage' => 'https://tincanapi.com', 'name' => 'test'), 'Xabbuh\XApi\Model\Account');
$account->shouldBeAnInstanceOf('Xabbuh\XApi\Model\Account');
$account->getHomePage()->equals(IRL::fromString('https://tincanapi.com'))->shouldReturn(true);
$account->getName()->shouldReturn('test');
}
function it_supports_denormalizing_accounts()
{
$this->supportsDenormalization(AccountJsonFixtures::getTypicalAccount(), 'Xabbuh\XApi\Model\Account')->shouldBe(true);
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
use Xabbuh\XApi\DataFixtures\ActorFixtures;
use XApi\Fixtures\Json\ActorJsonFixtures;
class ActorNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
function it_requires_an_iri_when_denormalizing_an_agent()
{
$this
->shouldThrow('\Symfony\Component\Serializer\Exception\InvalidArgumentException')
->during('denormalize', array(
array('objectType' => 'Agent'),
'Xabbuh\XApi\Model\Actor',
))
;
}
function it_can_denormalize_agents_with_mbox_sha1_sum()
{
$data = array(
'mbox_sha1sum' => 'db77b9104b531ecbb0b967f6942549d0ba80fda1',
);
$agent = $this->denormalize($data, 'Xabbuh\XApi\Model\Actor');
$agent->shouldBeAnInstanceOf('Xabbuh\XApi\Model\Agent');
$agent->getInverseFunctionalIdentifier()->getMboxSha1Sum()->shouldReturn('db77b9104b531ecbb0b967f6942549d0ba80fda1');
}
function it_supports_normalizing_agents()
{
$this->supportsNormalization(ActorFixtures::getTypicalAgent())->shouldBe(true);
}
function it_supports_normalizing_groups()
{
$this->supportsNormalization(ActorFixtures::getTypicalGroup())->shouldBe(true);
}
function it_supports_denormalizing_agents()
{
$this->supportsDenormalization(ActorJsonFixtures::getTypicalAgent(), 'Xabbuh\XApi\Model\Actor')->shouldBe(true);
}
function it_supports_denormalizing_groups()
{
$this->supportsDenormalization(ActorJsonFixtures::getTypicalGroup(), 'Xabbuh\XApi\Model\Actor')->shouldBe(true);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
use Xabbuh\XApi\Model\Attachment;
use Xabbuh\XApi\Model\IRI;
use Xabbuh\XApi\Model\LanguageMap;
class AttachmentNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_supports_normalizing_attachment_objects()
{
$attachment = new Attachment(
IRI::fromString('http://id.tincanapi.com/attachment/supporting_media'),
'text/plain',
18,
'bd1a58265d96a3d1981710dab8b1e1ed04a8d7557ea53ab0cf7b44c04fd01545',
LanguageMap::create(array('en-US' => 'Text attachment')),
null,
null,
'some text content'
);
$this->supportsNormalization($attachment)->shouldReturn(true);
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
function it_supports_denormalizing_to_attachment_objects()
{
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Attachment')->shouldReturn(true);
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
use Xabbuh\XApi\Model\Definition;
class DefinitionNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_supports_normalizing_definition_objects()
{
$this->supportsNormalization(new Definition())->shouldReturn(true);
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
function it_supports_denormalizing_to_definition_objects()
{
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Definition')->shouldReturn(true);
}
function it_supports_denormalizing_to_interaction_definition_objects()
{
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\ChoiceInteractionDefinition')->shouldReturn(true);
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\FillInInteractionDefinition')->shouldReturn(true);
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\LikertInteractionDefinition')->shouldReturn(true);
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\LongFillInInteractionDefinition')->shouldReturn(true);
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\MatchingInteractionDefinition')->shouldReturn(true);
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\NumericInteractionDefinition')->shouldReturn(true);
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\OtherInteractionDefinition')->shouldReturn(true);
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\PerformanceInteractionDefinition')->shouldReturn(true);
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\SequencingInteractionDefinition')->shouldReturn(true);
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\TrueFalseInteractionDefinition')->shouldReturn(true);
}
function it_throws_an_exception_when_an_unknown_interaction_type_should_be_denormalized()
{
$this->shouldThrow('Symfony\Component\Serializer\Exception\InvalidArgumentException')->during('denormalize', array(
array('interactionType' => 'foo'),
'Xabbuh\XApi\Model\Definition'
));
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
class DocumentDataNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
class InteractionComponentNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_supports_normalizing_interaction_component_objects()
{
$this->supportsNormalization(new InteractionComponent('test'))->shouldReturn(true);
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
function it_supports_denormalizing_to_interaction_component_objects()
{
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Interaction\InteractionComponent')->shouldReturn(true);
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
use Xabbuh\XApi\Model\LanguageMap;
class LanguageMapNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
function it_supports_normalizing_language_map_objects()
{
$this->supportsNormalization(new LanguageMap())->shouldReturn(true);
}
function it_normalizes_language_map_instances_to_arrays()
{
$map = array(
'de-DE' => 'teilgenommen',
'en-GB' => 'attended',
'en-US' => 'attended',
);
$normalizedMap = $this->normalize(LanguageMap::create($map));
$normalizedMap->shouldBeArray();
$normalizedMap->shouldHaveCount(3);
$normalizedMap->shouldHaveKeyWithValue('de-DE', 'teilgenommen');
$normalizedMap->shouldHaveKeyWithValue('en-GB', 'attended');
$normalizedMap->shouldHaveKeyWithValue('en-US', 'attended');
}
function it_supports_denormalizing_to_language_map_objects()
{
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\LanguageMap')->shouldReturn(true);
}
function it_denormalizes_arrays_to_language_map_instances()
{
$map = array(
'de-DE' => 'teilgenommen',
'en-GB' => 'attended',
'en-US' => 'attended',
);
$languageMap = LanguageMap::create($map);
$this->denormalize($map, 'Xabbuh\XApi\Model\LanguageMap')->equals($languageMap)->shouldReturn(true);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
class ObjectNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
class ResultNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
use Xabbuh\XApi\DataFixtures\StatementFixtures;
use XApi\Fixtures\Json\StatementJsonFixtures;
class StatementNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
function it_supports_normalizing_statements()
{
$this->supportsNormalization(StatementFixtures::getMinimalStatement())->shouldBe(true);
}
function it_supports_denormalizing_statements()
{
$this->supportsDenormalization(StatementJsonFixtures::getMinimalStatement(), 'Xabbuh\XApi\Model\Statement')->shouldBe(true);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
class StatementResultNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
class TimestampNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_can_normalize_datetime_objects()
{
$this->supportsNormalization(new \DateTime())->shouldBe(true);
}
function it_cannot_normalize_datetime_like_string()
{
$this->supportsNormalization('2004-02-12T15:19:21+00:00')->shouldBe(false);
}
function it_normalizes_datetime_objects_as_iso_8601_formatted_strings()
{
$date = new \DateTime();
$date->setTimezone(new \DateTimeZone('UTC'));
$date->setDate(2004, 2, 12);
$date->setTime(15, 19, 21);
$this->normalize($date)->shouldReturn('2004-02-12T15:19:21+00:00');
}
function it_throws_an_exception_when_data_other_than_datetime_objects_are_passed()
{
$this->shouldThrow('Symfony\Component\Serializer\Exception\InvalidArgumentException')->during('normalize', array('2004-02-12T15:19:21+00:00'));
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
function it_can_denormalize_to_datetime_objects()
{
$this->supportsDenormalization('2004-02-12T15:19:21+00:00', 'DateTime')->shouldBe(true);
}
function it_denormalizes_iso_8601_formatted_strings_to_datetime_objects()
{
$date = $this->denormalize('2004-02-12T15:19:21+00:00', 'DateTime');
$date->getTimezone()->shouldBeLike(new \DateTimeZone('UTC'));
$date->format('Y-m-d H:i:s')->shouldReturn('2004-02-12 15:19:21');
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony\Normalizer;
use PhpSpec\ObjectBehavior;
use Xabbuh\XApi\Model\IRI;
use Xabbuh\XApi\Model\Verb;
class VerbNormalizerSpec extends ObjectBehavior
{
function it_is_a_normalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
}
function it_supports_normalizing_verb_objects()
{
$this->supportsNormalization(new Verb(IRI::fromString('http://tincanapi.com/conformancetest/verbid')))->shouldReturn(true);
}
function it_is_a_denormalizer()
{
$this->shouldHaveType('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
}
function it_supports_denormalizing_to_verb_objects()
{
$this->supportsDenormalization(array(), 'Xabbuh\XApi\Model\Verb')->shouldReturn(true);
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony;
use spec\Xabbuh\XApi\Serializer\SerializerFactoryInterfaceSpec;
class SerializerFactorySpec extends SerializerFactoryInterfaceSpec
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace spec\Xabbuh\XApi\Serializer\Symfony;
use PhpSpec\ObjectBehavior;
class SerializerSpec extends ObjectBehavior
{
function it_creates_a_serializer()
{
self::createSerializer()->shouldBeAnInstanceOf('Symfony\Component\Serializer\SerializerInterface');
}
}