Skip to content

Commit

Permalink
OXDEV-8489: Add a few argument checks to tests and integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelOxid committed Aug 14, 2024
1 parent fb30707 commit 574c975
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
33 changes: 33 additions & 0 deletions tests/Integration/Service/ModuleBlockListServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Integration\Infrastructure;

use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Dao\ProjectYamlDaoInterface;
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;
use OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleBlocklistService;
use Symfony\Component\Yaml\Yaml;

class ModuleBlockListServiceTest extends IntegrationTestCase
{
public function testLoadYamlList(): void
{
$moduleServices = Yaml::parseFile(dirname(__FILE__) . '/../../../src/Module/services.yaml');
$blockedListYamlPathParameterName = 'oxidesales.graphqlconfigurationaccess.modules_block_list_path';
$blockedListYamlPath = $moduleServices['parameters'][$blockedListYamlPathParameterName];

$sut = new ModuleBlocklistService(
moduleBlocklistPath: $blockedListYamlPath,
projectYamlDao: $this->get(ProjectYamlDaoInterface::class)
);

$this->assertTrue($sut->isModuleBlocked('oe_graphql_base'));
$this->assertTrue($sut->isModuleBlocked('oe_graphql_configuration_access'));
}
}
6 changes: 5 additions & 1 deletion tests/Unit/Module/Service/ModuleActivationsServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ public function testModuleActivationAndDeactivationExceptions(
$moduleActivationBridgeMock = $this->createMock(ModuleActivationBridgeInterface::class);
$moduleActivationBridgeMock
->method($method)
->with($moduleId, 1)
->willThrowException(new \Exception());

$this->expectException($exceptionClass);

$sut = $this->getSut(
$this->getContextMock(),
moduleActivationBridge: $moduleActivationBridgeMock
);

Expand All @@ -76,17 +78,19 @@ public function testModuleActivationAndDeactivationExceptions(

public function testModuleDeactivationBlockedException()
{
$moduleId = uniqid();
$moduleBlockListServiceMock = $this->createMock(ModuleBlocklistServiceInterface::class);
$moduleBlockListServiceMock
->method('isModuleBlocked')
->with($moduleId)
->willReturn(true);

$sut = $this->getSut(
moduleBlocklistService: $moduleBlockListServiceMock
);

$this->expectException(ModuleDeactivationBlockedException::class);
$sut->deactivateModule(uniqid());
$sut->deactivateModule($moduleId);
}

public static function activationDataProvider(): \Generator
Expand Down

0 comments on commit 574c975

Please sign in to comment.