Skip to content

Commit

Permalink
ci: commit oat-sa/environment-management#
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 11, 2024
1 parent 492b343 commit 0b6698a
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 49 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/sonar.yml

This file was deleted.

14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"ext-ctype": "*",
"ext-json": "*",
"ext-mbstring": "*",
"oat-sa/lib-lti1p3-ags": "^1.4",
"oat-sa/lib-lti1p3-basic-outcome": "^4.1",
"oat-sa/lib-lti1p3-core": "^6.6",
"oat-sa/lib-lti1p3-nrps": "^7.0",
"oat-sa/lib-lti1p3-proctoring": "^0.4",
"symfony/property-access": "^5.0",
"symfony/serializer": "^5.0"
"oat-sa/lib-lti1p3-ags": "^1.4 | ^2.0",
"oat-sa/lib-lti1p3-basic-outcome": "^4.1 | ^5.0",
"oat-sa/lib-lti1p3-core": "^6.6 | ^7.0",
"oat-sa/lib-lti1p3-nrps": "^7.0 | ^8.0",
"oat-sa/lib-lti1p3-proctoring": "^0.5 | ^1.0",
"symfony/property-access": "^5.0 | ^6.4 | ^7.0",
"symfony/serializer": "^5.0 | ^6.4 | ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
Expand Down
1 change: 0 additions & 1 deletion sonar-project.properties

This file was deleted.

5 changes: 4 additions & 1 deletion src/Factory/LtiSerializerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace OAT\Library\EnvironmentManagementLtiEvents\Factory;

use DateTimeInterface;
use OAT\Library\EnvironmentManagementLtiEvents\Normalizer\Ags\LineItemNormalizer;
use OAT\Library\EnvironmentManagementLtiEvents\Normalizer\Ags\ScoreNormalizer;
use OAT\Library\EnvironmentManagementLtiEvents\Normalizer\Ags\SubmissionReviewNormalizer;
Expand All @@ -15,6 +16,7 @@
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
Expand All @@ -34,7 +36,8 @@ public static function create(): SerializerInterface
new ScoreNormalizer(),
new AcsControlNormalizer(),
new ResourceLinkNormalizer(),
new DateTimeNormalizer(),
new JsonSerializableNormalizer(),
new DateTimeNormalizer([DateTimeNormalizer::FORMAT_KEY => DateTimeInterface::RFC3339_EXTENDED]),
new ObjectNormalizer($classMetaDataFactory, null, null, null, $classDiscriminator),
],
[
Expand Down
112 changes: 112 additions & 0 deletions tests/Unit/Factory/LtiSerializerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2022 (original work) Open Assessment Technologies SA;
*
* @author Sergei Mikhailov <[email protected]>
*/

declare(strict_types=1);

namespace OAT\Library\EnvironmentManagementLtiEvents\Tests\Unit\Factory;

use DateTimeImmutable;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Ags\CreateLineItemEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Ags\DeleteLineItemEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Ags\GetLineItemEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Ags\ListLineItemsEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Ags\ListResultsEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Ags\PublishScoreEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Ags\UpdateLineItemEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\BasicOutcome\DeleteResultEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\BasicOutcome\ReadResultEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\BasicOutcome\ReplaceResultEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\BasicOutcome\SendBasicOutcomeEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Core\RequestEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\EventInterface;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Nrps\GetContextMembershipEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Nrps\GetResourceLinkMembershipEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Event\Proctoring\SendControlEvent;
use OAT\Library\EnvironmentManagementLtiEvents\Factory\LtiSerializerFactory;
use OAT\Library\Lti1p3Ags\Model\LineItem\LineItem;
use OAT\Library\Lti1p3Ags\Model\Score\Score;
use OAT\Library\Lti1p3Core\Resource\LtiResourceLink\LtiResourceLink;
use OAT\Library\Lti1p3Proctoring\Model\AcsControl;
use OAT\Library\Lti1p3Proctoring\Model\AcsControlInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\SerializerInterface;

class LtiSerializerTest extends TestCase
{
private SerializerInterface $sut;

/**
* @before
*/
public function init(): void
{
$this->sut = LtiSerializerFactory::create();
}

/**
* @dataProvider dataProvider
*/
public function testEventSerialization(EventInterface $event): void
{
$this->assertEquals(
$event,
$this->sut->deserialize(
$this->sut->serialize($event, JsonEncoder::FORMAT),
EventInterface::class,
JsonEncoder::FORMAT
)
);
}

public function dataProvider(): array
{
return [
[new CreateLineItemEvent('test', new LineItem(1, 'test'), 'https://example.com')],
[new DeleteLineItemEvent('test', 'https://example.com')],
[new GetLineItemEvent('test', 'https://example.com')],
[new ListLineItemsEvent('test', 'https://example.com')],
[new ListResultsEvent('test', 'https://example.com')],
[new PublishScoreEvent('test', new Score('test'), 'https://example.com')],
[new UpdateLineItemEvent('test', new LineItem(1, 'test'))],
[new DeleteResultEvent('test', 'https://example.com', 'test')],
[new ReadResultEvent('test', 'https://example.com', 'test')],
[new ReplaceResultEvent('test', 'https://example.com', 'test', 1)],
[new SendBasicOutcomeEvent('test', 'https://example.com', '<xml/>')],
[new RequestEvent('test', 'GET', 'https://example.com')],
[new GetContextMembershipEvent('test', 'https://example.com')],
[new GetResourceLinkMembershipEvent('test', 'https://example.com', 'test')],
[
new SendControlEvent(
'test',
new AcsControl(
new LtiResourceLink('https://example.com'),
'test',
AcsControlInterface::ACTION_PAUSE,
DateTimeImmutable::createFromFormat('U.u', sprintf('%.3f', microtime(true)))
),
'https://example.com'
),
],
];
}
}

0 comments on commit 0b6698a

Please sign in to comment.