From 1f5514930ed461ef2b7c35e344dea8ecc62b0cbf Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Soares Date: Mon, 3 Apr 2023 17:26:15 +0200 Subject: [PATCH 01/11] feat: adding copy tests logic --- manifest.php | 4 + .../classes/Copier/CopierServiceProvider.php | 143 ++++++++++++++++++ models/classes/Copier/TestClassCopier.php | 76 ++++++++++ models/classes/Copier/TestContentCopier.php | 52 +++++++ 4 files changed, 275 insertions(+) create mode 100644 models/classes/Copier/CopierServiceProvider.php create mode 100644 models/classes/Copier/TestClassCopier.php create mode 100644 models/classes/Copier/TestContentCopier.php diff --git a/manifest.php b/manifest.php index e7f96021..81a14262 100755 --- a/manifest.php +++ b/manifest.php @@ -27,6 +27,7 @@ */ use oat\tao\model\user\TaoRoles; +use oat\taoTests\models\Copier\CopierServiceProvider; use oat\taoTests\scripts\update\Updater; use oat\taoTests\scripts\install\SetupProvider; use oat\taoTests\scripts\install\RegisterFrontendPaths; @@ -85,4 +86,7 @@ #BASE URL (usually the domain root) 'BASE_URL' => ROOT_URL . 'taoTests/', ], + 'containerServiceProviders' => [ + CopierServiceProvider::class, + ], ]; diff --git a/models/classes/Copier/CopierServiceProvider.php b/models/classes/Copier/CopierServiceProvider.php new file mode 100644 index 00000000..1f62ae0b --- /dev/null +++ b/models/classes/Copier/CopierServiceProvider.php @@ -0,0 +1,143 @@ +services(); + + $services + ->set(taoTests_models_classes_TestsService::class, taoTests_models_classes_TestsService::class) + ->factory(taoTests_models_classes_TestsService::class . '::singleton'); + + $services + ->get(InstanceMetadataCopier::class) + ->call( + 'addPropertyUriToBlacklist', + [ + taoTests_models_classes_TestsService::PROPERTY_TEST_CONTENT, + ] + ); + + $services + ->set(TestContentCopier::class, TestContentCopier::class) + ->args( + [ + service(FileReferenceSerializer::SERVICE_ID), + service(taoTests_models_classes_TestsService::class), + service(EventManager::SERVICE_ID), + ] + ); + + $services + ->set(InstanceCopier::class . '::TESTS', InstanceCopier::class) + ->args( + [ + service(InstanceMetadataCopier::class), + service(Ontology::SERVICE_ID) + ] + ) + ->call( + 'withInstanceContentCopier', + [ + service(TestContentCopier::class), + ] + ) + ->call( + 'withPermissionCopiers', + [ + tagged_iterator('tao.copier.permissions.instance.tests'), + ] + ); + + $services + ->set(ClassCopier::class . '::TESTS', ClassCopier::class) + ->share(false) + ->args( + [ + service(RootClassesListService::class), + service(ClassMetadataCopier::class), + service(InstanceCopier::class . '::TESTS'), + service(ClassMetadataMapper::class), + service(Ontology::SERVICE_ID), + ] + ) + ->call( + 'withPermissionCopiers', + [ + tagged_iterator('tao.copier.permissions.class.tests'), + ] + ); + + $services + ->set(TestClassCopier::class, TestClassCopier::class) + ->share(false) + ->args( + [ + service(ClassCopier::class . '::TESTS'), + service(Ontology::SERVICE_ID), + ] + ); + + $services + ->get(ClassCopierProxy::class) + ->call( + 'addClassCopier', + [ + TaoOntology::CLASS_URI_TEST, + service(TestClassCopier::class), + ] + ); + + $services + ->get(InstanceCopierProxy::class) + ->call( + 'addInstanceCopier', + [ + TaoOntology::CLASS_URI_TEST, + service(InstanceCopier::class . '::TESTS'), + ] + ); + } +} diff --git a/models/classes/Copier/TestClassCopier.php b/models/classes/Copier/TestClassCopier.php new file mode 100644 index 00000000..8f3a94cf --- /dev/null +++ b/models/classes/Copier/TestClassCopier.php @@ -0,0 +1,76 @@ +taoClassCopier = $taoClassCopier; + $this->ontology = $ontology; + } + + public function copy( + core_kernel_classes_Class $class, + core_kernel_classes_Class $destinationClass + ): core_kernel_classes_Class { + $this->assertRootClass($class); + + return $this->taoClassCopier->copy($class, $destinationClass); + } + + public function transfer(ResourceTransferCommand $command): ResourceTransferResult + { + $this->assertRootClass($this->ontology->getClass($command->getFrom())); + + return $this->taoClassCopier->transfer($command); + } + + private function assertRootClass(core_kernel_classes_Class $class): void + { + $rootClass = $class->getClass(TaoOntology::CLASS_URI_TEST); + + if (!$class->equals($rootClass) && !$class->isSubClassOf($rootClass)) { + throw new InvalidArgumentException( + sprintf( + 'Selected class (%s) is not supported because it is not part of the root class (%s).', + $class->getUri(), + TaoOntology::CLASS_URI_TEST + ) + ); + } + } +} diff --git a/models/classes/Copier/TestContentCopier.php b/models/classes/Copier/TestContentCopier.php new file mode 100644 index 00000000..3b117e18 --- /dev/null +++ b/models/classes/Copier/TestContentCopier.php @@ -0,0 +1,52 @@ +fileReferenceSerializer = $fileReferenceSerializer; + $this->testsService = $testsService; + $this->eventManager = $eventManager; + } + + public function copy( + core_kernel_classes_Resource $instance, + core_kernel_classes_Resource $destinationInstance + ): void { + } +} From 535f3db8a3313236511d1b01abce630c6b33ab92 Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Soares Date: Tue, 4 Apr 2023 15:18:36 +0200 Subject: [PATCH 02/11] feat: introce test content copier --- .../classes/Copier/CopierServiceProvider.php | 4 ++-- models/classes/Copier/TestContentCopier.php | 23 ++++++++++++------- models/classes/class.TestsService.php | 12 +++++++--- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/models/classes/Copier/CopierServiceProvider.php b/models/classes/Copier/CopierServiceProvider.php index 1f62ae0b..8221239b 100644 --- a/models/classes/Copier/CopierServiceProvider.php +++ b/models/classes/Copier/CopierServiceProvider.php @@ -23,6 +23,7 @@ namespace oat\taoTests\models\Copier; use oat\generis\model\data\Ontology; +use oat\generis\model\OntologyRdf; use oat\tao\model\resources\Service\InstanceCopierProxy; use oat\tao\model\TaoOntology; use oat\oatbox\event\EventManager; @@ -33,7 +34,6 @@ use oat\tao\model\resources\Service\ClassMetadataMapper; use oat\tao\model\resources\Service\InstanceMetadataCopier; use oat\tao\model\resources\Service\RootClassesListService; -use oat\generis\model\fileReference\FileReferenceSerializer; use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use taoTests_models_classes_TestsService; @@ -57,6 +57,7 @@ public function __invoke(ContainerConfigurator $configurator): void 'addPropertyUriToBlacklist', [ taoTests_models_classes_TestsService::PROPERTY_TEST_CONTENT, + OntologyRdf::RDF_TYPE, ] ); @@ -64,7 +65,6 @@ public function __invoke(ContainerConfigurator $configurator): void ->set(TestContentCopier::class, TestContentCopier::class) ->args( [ - service(FileReferenceSerializer::SERVICE_ID), service(taoTests_models_classes_TestsService::class), service(EventManager::SERVICE_ID), ] diff --git a/models/classes/Copier/TestContentCopier.php b/models/classes/Copier/TestContentCopier.php index 3b117e18..fa98ba82 100644 --- a/models/classes/Copier/TestContentCopier.php +++ b/models/classes/Copier/TestContentCopier.php @@ -24,22 +24,17 @@ use core_kernel_classes_Resource; use oat\oatbox\event\EventManager; -use oat\generis\model\fileReference\FileReferenceSerializer; use oat\tao\model\resources\Contract\InstanceContentCopierInterface; +use oat\taoTests\models\event\TestDuplicatedEvent; use taoTests_models_classes_TestsService; class TestContentCopier implements InstanceContentCopierInterface { - private FileReferenceSerializer $fileReferenceSerializer; private taoTests_models_classes_TestsService $testsService; private EventManager $eventManager; - public function __construct( - FileReferenceSerializer $fileReferenceSerializer, - taoTests_models_classes_TestsService $testsService, - EventManager $eventManager - ) { - $this->fileReferenceSerializer = $fileReferenceSerializer; + public function __construct(taoTests_models_classes_TestsService $testsService, EventManager $eventManager) + { $this->testsService = $testsService; $this->eventManager = $eventManager; } @@ -48,5 +43,17 @@ public function copy( core_kernel_classes_Resource $instance, core_kernel_classes_Resource $destinationInstance ): void { + $this->copyModel($instance, $destinationInstance); + $this->testsService->cloneContent($instance, $destinationInstance); + + $this->eventManager->trigger(new TestDuplicatedEvent($instance->getUri(), $destinationInstance->getUri())); + } + + private function copyModel(core_kernel_classes_Resource $from, core_kernel_classes_Resource $to): void + { + $modelProperty = $from->getProperty(taoTests_models_classes_TestsService::PROPERTY_TEST_TESTMODEL); + $model = $from->getOnePropertyValue($modelProperty); + + $to->editPropertyValues($modelProperty, $model instanceof core_kernel_classes_Resource ? $model : null); } } diff --git a/models/classes/class.TestsService.php b/models/classes/class.TestsService.php index 0e9613fc..13152062 100644 --- a/models/classes/class.TestsService.php +++ b/models/classes/class.TestsService.php @@ -21,6 +21,7 @@ * 2012-2021 (original work) Open Assessment Technologies SA; */ use oat\generis\model\OntologyRdf; +use oat\tao\model\resources\Service\InstanceCopier; use oat\tao\model\TaoOntology; use oat\taoTests\models\event\TestCreatedEvent; use oat\taoTests\models\event\TestDuplicatedEvent; @@ -142,6 +143,7 @@ public function onChangeTestLabel(core_kernel_classes_Resource $test = null) /** * @author Joel Bout, + * @deprecated Use service id 'oat\tao\model\resources\Service\InstanceCopier::TESTS' */ public function cloneInstance(core_kernel_classes_Resource $instance, core_kernel_classes_Class $clazz = null): ?core_kernel_classes_Resource { @@ -174,9 +176,7 @@ public function cloneInstance(core_kernel_classes_Resource $instance, core_kerne } $clone->setLabel($cloneLabel); - $impl = $this->getTestModelImplementation($this->getTestModel($instance)); - $impl->cloneContent($instance, $clone); - + $this->cloneContent($instance, $clone); $this->getEventManager()->trigger(new TestDuplicatedEvent($instance->getUri(), $clone->getUri())); $returnValue = $clone; @@ -185,6 +185,12 @@ public function cloneInstance(core_kernel_classes_Resource $instance, core_kerne return $returnValue; } + public function cloneContent(core_kernel_classes_Resource $original, core_kernel_classes_Resource $clone): void + { + $impl = $this->getTestModelImplementation($this->getTestModel($original)); + $impl->cloneContent($original, $clone); + } + /** * @author Lionel Lecaque, lionel@taotesting.com */ From 0d34fd591fee18730f525767fe8ba60c3a758d79 Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Soares Date: Tue, 4 Apr 2023 16:33:16 +0200 Subject: [PATCH 03/11] chore: remove unnecessary service mapping --- models/classes/Copier/CopierServiceProvider.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/models/classes/Copier/CopierServiceProvider.php b/models/classes/Copier/CopierServiceProvider.php index 8221239b..fb9066b8 100644 --- a/models/classes/Copier/CopierServiceProvider.php +++ b/models/classes/Copier/CopierServiceProvider.php @@ -24,6 +24,7 @@ use oat\generis\model\data\Ontology; use oat\generis\model\OntologyRdf; +use oat\generis\model\OntologyRdfs; use oat\tao\model\resources\Service\InstanceCopierProxy; use oat\tao\model\TaoOntology; use oat\oatbox\event\EventManager; @@ -54,10 +55,12 @@ public function __invoke(ContainerConfigurator $configurator): void $services ->get(InstanceMetadataCopier::class) ->call( - 'addPropertyUriToBlacklist', + 'addPropertyUrisToBlacklist', [ - taoTests_models_classes_TestsService::PROPERTY_TEST_CONTENT, - OntologyRdf::RDF_TYPE, + [ + taoTests_models_classes_TestsService::PROPERTY_TEST_CONTENT, + OntologyRdfs::RDFS_LABEL, + ] ] ); From 707ce3fbac29f0d5ecaa1dcc7005309deb3ad590 Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Wed, 5 Apr 2023 07:12:52 +0000 Subject: [PATCH 04/11] refactor: use another tag to retrieve permission copier --- models/classes/Copier/CopierServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/classes/Copier/CopierServiceProvider.php b/models/classes/Copier/CopierServiceProvider.php index fb9066b8..f55083cd 100644 --- a/models/classes/Copier/CopierServiceProvider.php +++ b/models/classes/Copier/CopierServiceProvider.php @@ -90,7 +90,7 @@ public function __invoke(ContainerConfigurator $configurator): void ->call( 'withPermissionCopiers', [ - tagged_iterator('tao.copier.permissions.instance.tests'), + tagged_iterator('tao.copier.permissions'), ] ); @@ -109,7 +109,7 @@ public function __invoke(ContainerConfigurator $configurator): void ->call( 'withPermissionCopiers', [ - tagged_iterator('tao.copier.permissions.class.tests'), + tagged_iterator('tao.copier.permissions'), ] ); From c86c256ece2977ab500fe62480b8c92e2b250cda Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Soares Date: Thu, 6 Apr 2023 11:23:41 +0200 Subject: [PATCH 05/11] chore: add unit tests base --- models/classes/Copier/TestClassCopier.php | 16 ++++-- .../classes/Copier/TestClassCopierTest.php | 50 +++++++++++++++++++ .../classes/Copier/TestContentCopierTest.php | 50 +++++++++++++++++++ 3 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 test/unit/models/classes/Copier/TestClassCopierTest.php create mode 100644 test/unit/models/classes/Copier/TestContentCopierTest.php diff --git a/models/classes/Copier/TestClassCopier.php b/models/classes/Copier/TestClassCopier.php index 8f3a94cf..fef9f74b 100644 --- a/models/classes/Copier/TestClassCopier.php +++ b/models/classes/Copier/TestClassCopier.php @@ -33,11 +33,10 @@ class TestClassCopier implements ClassCopierInterface, ResourceTransferInterface { - /** @var ClassCopierInterface|ResourceTransferInterface */ - private $taoClassCopier; + private ResourceTransferInterface $taoClassCopier; private Ontology $ontology; - public function __construct(ClassCopierInterface $taoClassCopier, Ontology $ontology) + public function __construct(ResourceTransferInterface $taoClassCopier, Ontology $ontology) { $this->taoClassCopier = $taoClassCopier; $this->ontology = $ontology; @@ -47,9 +46,16 @@ public function copy( core_kernel_classes_Class $class, core_kernel_classes_Class $destinationClass ): core_kernel_classes_Class { - $this->assertRootClass($class); + $result = $this->transfer( + new ResourceTransferCommand( + $class->getUri(), + $destinationClass->getUri(), + ResourceTransferCommand::ACL_KEEP_ORIGINAL, + ResourceTransferCommand::TRANSFER_MODE_COPY, + ) + ); - return $this->taoClassCopier->copy($class, $destinationClass); + return $this->ontology->getClass($result->getDestination()); } public function transfer(ResourceTransferCommand $command): ResourceTransferResult diff --git a/test/unit/models/classes/Copier/TestClassCopierTest.php b/test/unit/models/classes/Copier/TestClassCopierTest.php new file mode 100644 index 00000000..06424fbf --- /dev/null +++ b/test/unit/models/classes/Copier/TestClassCopierTest.php @@ -0,0 +1,50 @@ +classCopier = $this->createMock(ResourceTransferInterface::class); + $this->ontology = $this->createMock(Ontology::class); + $this->sut = new TestClassCopier($this->classCopier, $this->ontology); + } + + public function testTransfer(): void + { + //@TODO Finish test. + } +} diff --git a/test/unit/models/classes/Copier/TestContentCopierTest.php b/test/unit/models/classes/Copier/TestContentCopierTest.php new file mode 100644 index 00000000..157632f4 --- /dev/null +++ b/test/unit/models/classes/Copier/TestContentCopierTest.php @@ -0,0 +1,50 @@ +testsService = $this->createMock(taoTests_models_classes_TestsService::class); + $this->eventManager = $this->createMock(EventManager::class); + $this->sut = new TestContentCopier($this->testsService, $this->eventManager); + } + + public function testCopy(): void + { + //@TODO finish test + } +} From 94b03c44a966408f9b6712081f7376723d4a5069 Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Soares Date: Thu, 6 Apr 2023 11:46:11 +0200 Subject: [PATCH 06/11] chore: Cover TestClassCopier with tests --- .../classes/Copier/TestClassCopierTest.php | 69 ++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/test/unit/models/classes/Copier/TestClassCopierTest.php b/test/unit/models/classes/Copier/TestClassCopierTest.php index 06424fbf..9e03f102 100644 --- a/test/unit/models/classes/Copier/TestClassCopierTest.php +++ b/test/unit/models/classes/Copier/TestClassCopierTest.php @@ -22,9 +22,13 @@ namespace oat\taoTests\test\unit\models\classes\Copier; +use core_kernel_classes_Class; +use InvalidArgumentException; use oat\generis\model\data\Ontology; use oat\generis\test\MockObject; +use oat\tao\model\resources\Command\ResourceTransferCommand; use oat\tao\model\resources\Contract\ResourceTransferInterface; +use oat\tao\model\resources\ResourceTransferResult; use oat\taoTests\models\Copier\TestClassCopier; use PHPUnit\Framework\TestCase; @@ -45,6 +49,69 @@ public function setUp(): void public function testTransfer(): void { - //@TODO Finish test. + $result = new ResourceTransferResult('newClassUri'); + $command = new ResourceTransferCommand( + 'fromClassUri', + 'toClassUri', + ResourceTransferCommand::ACL_KEEP_ORIGINAL, + ResourceTransferCommand::TRANSFER_MODE_COPY + ); + + $rootClass = $this->createMock(core_kernel_classes_Class::class); + $fromClass = $this->createMock(core_kernel_classes_Class::class); + + $fromClass->method('equals') + ->with($rootClass) + ->willReturn(true); + + $fromClass->method('getClass') + ->willReturn($rootClass); + + $this->ontology->method('getClass') + ->willReturn($fromClass); + + $this->classCopier->method('transfer') + ->with($command) + ->willReturn($result); + + $this->assertSame($result, $this->sut->transfer($command)); + } + + public function testTransferWithInvalidClass(): void + { + $rootClass = $this->createMock(core_kernel_classes_Class::class); + $fromClass = $this->createMock(core_kernel_classes_Class::class); + + $fromClass->method('equals') + ->with($rootClass) + ->willReturn(false); + + $fromClass->method('getUri') + ->willReturn('fromClassUri'); + + $fromClass->method('isSubClassOf') + ->with($rootClass) + ->willReturn(false); + + $fromClass->method('getClass') + ->willReturn($rootClass); + + $this->ontology->method('getClass') + ->willReturn($fromClass); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage( + 'Selected class (fromClassUri) is not supported because it is not part of the root class ' . + '(http://www.tao.lu/Ontologies/TAOTest.rdf#Test)' + ); + + $this->sut->transfer( + new ResourceTransferCommand( + 'fromClassUri', + 'toClassUri', + ResourceTransferCommand::ACL_KEEP_ORIGINAL, + ResourceTransferCommand::TRANSFER_MODE_COPY + ) + ); } } From 7840b34ce8bb494e90f582c42bc7a84d0005ec75 Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Soares Date: Thu, 6 Apr 2023 13:03:23 +0200 Subject: [PATCH 07/11] chore: cover TestContentCopier with tests --- .../classes/Copier/TestContentCopierTest.php | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/test/unit/models/classes/Copier/TestContentCopierTest.php b/test/unit/models/classes/Copier/TestContentCopierTest.php index 157632f4..ee27adb0 100644 --- a/test/unit/models/classes/Copier/TestContentCopierTest.php +++ b/test/unit/models/classes/Copier/TestContentCopierTest.php @@ -22,8 +22,11 @@ namespace oat\taoTests\test\unit\models\classes\Copier; +use core_kernel_classes_Property; +use core_kernel_classes_Resource; use oat\oatbox\event\EventManager; use oat\taoTests\models\Copier\TestContentCopier; +use oat\taoTests\models\event\TestDuplicatedEvent; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use taoTests_models_classes_TestsService; @@ -45,6 +48,41 @@ public function setUp(): void public function testCopy(): void { - //@TODO finish test + $fromInstance = $this->createMock(core_kernel_classes_Resource::class); + $toInstance = $this->createMock(core_kernel_classes_Resource::class); + $modelProperty = $this->createMock(core_kernel_classes_Property::class); + $model = $this->createMock(core_kernel_classes_Resource::class); + + $fromInstance->expects($this->once()) + ->method('getUri') + ->willReturn('fromUri'); + + $fromInstance->expects($this->once()) + ->method('getProperty') + ->willReturn($modelProperty); + + $fromInstance->expects($this->once()) + ->method('getOnePropertyValue') + ->willReturn($model); + + $toInstance->expects($this->once()) + ->method('getUri') + ->willReturn('toUri'); + + $toInstance->expects($this->once()) + ->method('editPropertyValues') + ->with($modelProperty, $model); + + $this->testsService + ->expects($this->once()) + ->method('cloneContent') + ->with($fromInstance, $toInstance); + + $this->eventManager + ->expects($this->once()) + ->method('trigger') + ->with(new TestDuplicatedEvent('fromUri', 'toUri')); + + $this->sut->copy($fromInstance, $toInstance); } } From c8e031cfb0ce939f49b3ef56897e6d79a825dec7 Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Soares Date: Thu, 6 Apr 2023 14:12:12 +0200 Subject: [PATCH 08/11] chore: use mock version for CI tests --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index cb8e901f..bea66fa4 100644 --- a/composer.json +++ b/composer.json @@ -63,9 +63,9 @@ "require": { "oat-sa/oatbox-extension-installer": "~1.1||dev-master", "oat-sa/generis": ">=15.22", - "oat-sa/tao-core": ">=50.24.6", + "oat-sa/tao-core": "dev-feat/RFE-530/integration-branch as 52.0", "oat-sa/extension-tao-backoffice": ">=6.0.0", - "oat-sa/extension-tao-item": ">=11.0.0" + "oat-sa/extension-tao-item": "dev-feat/RFE-530/integration-branch as 12.0" }, "autoload": { "psr-4": { From 053c7937d8fe38bdac8523cb49205e121011722a Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Fri, 7 Apr 2023 09:23:30 +0000 Subject: [PATCH 09/11] refactor: fix cs --- manifest.php | 16 +++++---- models/classes/class.TestsService.php | 47 +++++++++++++++++++-------- 2 files changed, 44 insertions(+), 19 deletions(-) diff --git a/manifest.php b/manifest.php index 81a14262..ba9ca7a5 100755 --- a/manifest.php +++ b/manifest.php @@ -1,4 +1,5 @@ 'taoTests', 'label' => 'Test core extension', - 'description' => 'TAO Tests extension contains the abstraction of the test-runners, but requires an implementation in order to be able to run tests', + 'description' => 'TAO Tests extension contains the abstraction of the test-runners, but requires an implementation ' + . 'in order to be able to run tests', 'license' => 'GPL-2.0', 'author' => 'Open Assessment Technologies, CRP Henri Tudor', 'models' => [ diff --git a/models/classes/class.TestsService.php b/models/classes/class.TestsService.php index 13152062..7ed5c83d 100644 --- a/models/classes/class.TestsService.php +++ b/models/classes/class.TestsService.php @@ -15,11 +15,15 @@ * 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) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2); - * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER); - * 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV); + * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg + * (under the project TAO & TAO2); + * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung + * (under the project TAO-TRANSFER); + * 2009-2012 (update and modification) Public Research Centre Henri Tudor + * (under the project TAO-SUSTAIN & TAO-DEV); * 2012-2021 (original work) Open Assessment Technologies SA; */ + use oat\generis\model\OntologyRdf; use oat\tao\model\resources\Service\InstanceCopier; use oat\tao\model\TaoOntology; @@ -36,12 +40,14 @@ * Service methods to manage the Tests business models using the RDF API. * * @author Joel Bout, + * + * phpcs:disable Squiz.Classes.ValidClassName */ class taoTests_models_classes_TestsService extends OntologyClassService { - public const CLASS_TEST_MODEL = 'http://www.tao.lu/Ontologies/TAOTest.rdf#TestModel'; + // phpcs:ignore public const PROPERTY_TEST_MODEL_IMPLEMENTATION = 'http://www.tao.lu/Ontologies/TAOTest.rdf#TestModelImplementation'; public const PROPERTY_TEST_TESTMODEL = 'http://www.tao.lu/Ontologies/TAOTest.rdf#TestTestModel'; @@ -145,8 +151,10 @@ public function onChangeTestLabel(core_kernel_classes_Resource $test = null) * @author Joel Bout, * @deprecated Use service id 'oat\tao\model\resources\Service\InstanceCopier::TESTS' */ - public function cloneInstance(core_kernel_classes_Resource $instance, core_kernel_classes_Class $clazz = null): ?core_kernel_classes_Resource - { + public function cloneInstance( + core_kernel_classes_Resource $instance, + core_kernel_classes_Class $clazz = null + ): ?core_kernel_classes_Resource { $returnValue = null; //call the parent create instance to prevent useless process test to be created: @@ -258,8 +266,10 @@ public function setTestModel(core_kernel_classes_Resource $test, core_kernel_cla /** * Returns a compiler instance for a given test */ - public function getCompiler(core_kernel_classes_Resource $test, ServiceFileStorage $storage): tao_models_classes_Compiler - { + public function getCompiler( + core_kernel_classes_Resource $test, + ServiceFileStorage $storage + ): tao_models_classes_Compiler { $testModel = $this->getTestModelImplementation($this->getTestModel($test)); if ($testModel instanceof TestModel) { $compiler = $testModel->getCompiler($test, $storage); @@ -300,12 +310,17 @@ public function getTestModel(core_kernel_classes_Resource $test): core_kernel_cl /** * Returns the implementation of an items test model */ - public function getTestModelImplementation(core_kernel_classes_Resource $testModel): taoTests_models_classes_TestModel - { - $serviceId = (string)$testModel->getOnePropertyValue($this->getPropertyByUri(self::PROPERTY_TEST_MODEL_IMPLEMENTATION)); + public function getTestModelImplementation( + core_kernel_classes_Resource $testModel + ): taoTests_models_classes_TestModel { + $serviceId = (string) $testModel->getOnePropertyValue( + $this->getPropertyByUri(self::PROPERTY_TEST_MODEL_IMPLEMENTATION) + ); if (empty($serviceId)) { - throw new common_exception_NoImplementation('No implementation found for testmodel ' . $testModel->getUri()); + throw new common_exception_NoImplementation( + 'No implementation found for testmodel ' . $testModel->getUri() + ); } try { @@ -320,7 +335,13 @@ public function getTestModelImplementation(core_kernel_classes_Resource $testMod } if (!$testModelService instanceof \taoTests_models_classes_TestModel) { - throw new common_exception_Error('Test model service ' . get_class($testModelService) . ' not compatible for test model ' . $testModel->getUri()); + throw new common_exception_Error( + sprintf( + 'Test model service %s not compatible for test model %s', + get_class($testModelService), + $testModel->getUri() + ) + ); } return $testModelService; From 3a042531874f7c94b21c46a04646c8f3ae6cc137 Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Soares Date: Fri, 7 Apr 2023 13:16:50 +0200 Subject: [PATCH 10/11] chore: ignore provider coverage --- models/classes/Copier/CopierServiceProvider.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/classes/Copier/CopierServiceProvider.php b/models/classes/Copier/CopierServiceProvider.php index f55083cd..59bece0e 100644 --- a/models/classes/Copier/CopierServiceProvider.php +++ b/models/classes/Copier/CopierServiceProvider.php @@ -42,6 +42,9 @@ use function Symfony\Component\DependencyInjection\Loader\Configurator\service; use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator; +/** + * @codeCoverageIgnore + */ class CopierServiceProvider implements ContainerServiceProviderInterface { public function __invoke(ContainerConfigurator $configurator): void From 8c1799f8f30e968dcf7aada5b747e06ff321d124 Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Soares Date: Thu, 27 Apr 2023 16:31:09 +0200 Subject: [PATCH 11/11] chore: bum composer versions --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index bea66fa4..52621007 100644 --- a/composer.json +++ b/composer.json @@ -62,10 +62,10 @@ }, "require": { "oat-sa/oatbox-extension-installer": "~1.1||dev-master", - "oat-sa/generis": ">=15.22", - "oat-sa/tao-core": "dev-feat/RFE-530/integration-branch as 52.0", + "oat-sa/generis": ">=15.24", + "oat-sa/tao-core": ">=52.1", "oat-sa/extension-tao-backoffice": ">=6.0.0", - "oat-sa/extension-tao-item": "dev-feat/RFE-530/integration-branch as 12.0" + "oat-sa/extension-tao-item": ">=11.33" }, "autoload": { "psr-4": {