Skip to content

Commit

Permalink
Merge branch 'release-16.4.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Dec 24, 2024
2 parents 9f2b6c9 + fb69a8a commit 37a0954
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"require": {
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"oat-sa/generis": ">=15.39.0",
"oat-sa/tao-core": ">=54.27.0",
"oat-sa/tao-core": ">=54.28.5",
"oat-sa/extension-tao-backoffice": ">=6.0.0",
"oat-sa/extension-tao-item": ">=12.5.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoTests\models\Translation\Service;

use core_kernel_classes_Resource;
use oat\oatbox\event\EventManager;
use oat\taoTests\models\event\TestUpdatedEvent;
use Psr\Log\LoggerInterface;

class TranslateIntoLanguagesHandler
{
private LoggerInterface $logger;
private EventManager $eventManager;

public function __construct(LoggerInterface $logger, EventManager $eventManager)
{
$this->logger = $logger;
$this->eventManager = $eventManager;
}

public function __invoke(core_kernel_classes_Resource $originalTest): void
{
$this->logger->debug(sprintf('Force original test sync %s at %s', $originalTest->getUri(), __METHOD__));

$this->eventManager->trigger(new TestUpdatedEvent($originalTest->getUri()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@

use oat\generis\model\data\Ontology;
use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\oatbox\event\EventManager;
use oat\oatbox\log\LoggerService;
use oat\tao\model\resources\Service\InstanceCopier;
use oat\tao\model\TaoOntology;
use oat\tao\model\featureFlag\FeatureFlagChecker;
use oat\tao\model\Translation\Form\Modifier\TranslationFormModifier as TaoTranslationFormModifier;
use oat\tao\model\Translation\Service\ResourceLanguageRetriever;
use oat\tao\model\Translation\Service\ResourceMetadataPopulateService;
use oat\tao\model\Translation\Service\TranslatedIntoLanguagesSynchronizer;
use oat\tao\model\Translation\Service\TranslationCreationService;
use oat\taoTests\models\TaoTestOntology;
use oat\taoTests\models\Translation\Form\Modifier\TranslationFormModifier;
use oat\taoTests\models\Translation\Form\Modifier\TranslationFormModifierProxy;
use oat\taoTests\models\Translation\Listener\TestCreatedEventListener;
use oat\taoTests\models\Translation\Service\TranslateIntoLanguagesHandler;
use oat\taoTests\models\Translation\Service\TranslationPostCreationService;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

Expand Down Expand Up @@ -99,6 +102,15 @@ public function __invoke(ContainerConfigurator $configurator): void
]
);

$services
->set(TranslateIntoLanguagesHandler::class, TranslateIntoLanguagesHandler::class)
->args(
[
service(LoggerService::SERVICE_ID),
service(EventManager::SERVICE_ID),
]
);

$services
->get(TranslationCreationService::class)
->call(
Expand All @@ -115,5 +127,15 @@ public function __invoke(ContainerConfigurator $configurator): void
service(TranslationPostCreationService::class)
]
);

$services
->get(TranslatedIntoLanguagesSynchronizer::class)
->call(
'addCallback',
[
TaoOntology::CLASS_URI_TEST,
service(TranslateIntoLanguagesHandler::class)
]
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?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) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace unit\models\classes\Translation\Service;

use core_kernel_classes_Resource;
use oat\oatbox\event\EventManager;
use oat\taoTests\models\Translation\Service\TranslateIntoLanguagesHandler;
use oat\taoTests\models\event\TestUpdatedEvent;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;

class TranslateIntoLanguagesHandlerTest extends TestCase
{
private TranslateIntoLanguagesHandler $handler;

/** @var LoggerInterface|MockObject */
private $logger;

/** @var EventManager|MockObject */
private $eventManager;

protected function setUp(): void
{
$this->logger = $this->createMock(LoggerInterface::class);
$this->eventManager = $this->createMock(EventManager::class);

$this->handler = new TranslateIntoLanguagesHandler($this->logger, $this->eventManager);
}

public function testInvoke(): void
{
$resourceUri = 'http://example.com/resource/1';
$resource = $this->createMock(core_kernel_classes_Resource::class);
$resource
->method('getUri')
->willReturn($resourceUri);

$this->eventManager
->expects($this->once())
->method('trigger')
->with(new TestUpdatedEvent($resourceUri));

$this->handler->__invoke($resource);
}
}

0 comments on commit 37a0954

Please sign in to comment.