Skip to content

Commit

Permalink
Clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
liulka-oxid committed Dec 6, 2024
1 parent 0fd478b commit 2c5680a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
19 changes: 8 additions & 11 deletions tests/Integration/Legacy/Modules/ModuleInheritanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@
use PHPUnit\Framework\Attributes\DataProvider;
use Psr\Container\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

use function Symfony\Component\String\u;

/**
* Test, that the inheritance of modules and the shop works as expected.
*
* See also OxidEsales\EshopCommunity\Tests\Integration\Modules\BCModuleInheritanceTest
*
* Below, there are listed all possible combinations which are possible. You have to read the tables as follows:
* E.g. Test Case 1.1 is: A "plain module class" "extends via PHP" a "Plain shop class"
*
Expand All @@ -61,10 +60,10 @@
* +--------------------------------------------------------------+--------------------+-------------------------+
* | extends via PHP | plain module class | namespaced module class |
* +--------------------------------------------------------------+--------------------+-------------------------+
* | plain module class which extends an other class | 2.1 | 2.3 |
* | namespaced module class which extends an other class | 2.2 | 2.4 |
* | plain module class which extends another class | 2.1 | 2.3 |
* | namespaced module class which extends another class | 2.2 | 2.4 |
* | plain module class which chain extends a shop class | 2.5 | 2.7 |
* | namespaced module class which does not extend an other class | 2.6 | 2.8 |
* | namespaced module class which does not extend another class | 2.6 | 2.8 |
* +--------------------------------------------------------------+--------------------+-------------------------+
*
* Together with "2. Simple extending module classes from other modules" we implemented some other test cases.
Expand Down Expand Up @@ -102,9 +101,6 @@ final class ModuleInheritanceTest extends IntegrationTestCase
{
use FilesystemTrait;

/**
* @var ContainerBuilder
*/
private ContainerInterface $container;

public function setUp(): void
Expand Down Expand Up @@ -170,7 +166,8 @@ public function testModuleInheritanceTestPhpInheritanceForbidden(
/**
* This test covers PHP inheritance between module classes.
*
* The tested module class extends the other module class directly like '<module anotherclass> extends <module class>'
* The tested module class extends the other module class directly
* like '<module anotherclass> extends <module class>'
* or '<moduleA class> extends <moduleB class>'
* In this case the parent class of the module class must be the parent module class as instantiated with oxNew
*
Expand Down Expand Up @@ -252,7 +249,7 @@ public static function dataProviderTestModuleInheritanceTestPhpInheritance(): ar
return [
'case_1_6' => [
'moduleToActivate' => ['Vendor1/ModuleInheritance16'],
'moduleClassName' => \OxidEsales\EshopCommunity\Tests\Integration\Legacy\Modules\TestDataInheritance\modules\Vendor1\ModuleInheritance16\MyClass::class,
'moduleClassName' => TestDataInheritance\modules\Vendor1\ModuleInheritance16\MyClass::class,
'shopClassNames' => [\OxidEsales\EshopCommunity\Application\Model\Article::class, 'oxArticle'],
],
'case_1_7' => [
Expand Down Expand Up @@ -316,7 +313,7 @@ public static function dataProviderTestMultiModuleInheritanceTestPhpInheritance(
'case_2_8' => [
// Test case 2.8 namespaced module_2 extends namespaced module_1
'modulesToActivate' => ['Vendor1/ModuleInheritance28a', 'Vendor2/ModuleInheritance28b'],
'moduleClassName' => \OxidEsales\EshopCommunity\Tests\Integration\Legacy\Modules\TestDataInheritance\modules\Vendor2\ModuleInheritance28b\MyClass::class,
'moduleClassName' => TestDataInheritance\modules\Vendor2\ModuleInheritance28b\MyClass::class,
'shopClassNames' => [
MyClass::class,
],
Expand Down
18 changes: 1 addition & 17 deletions tests/Integration/Legacy/Modules/OnlineModuleNotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace OxidEsales\EshopCommunity\Tests\Integration\Legacy\Modules;

use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\OnlineModulesNotifierRequest;
use OxidEsales\Eshop\Core\OnlineModuleVersionNotifier;
use OxidEsales\Eshop\Core\OnlineModuleVersionNotifierCaller;
Expand All @@ -22,9 +21,6 @@
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface;
use OxidEsales\EshopCommunity\Tests\FilesystemTrait;
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;
use oxOnlineModulesNotifierRequest;
use oxOnlineModuleVersionNotifierCaller;
use PHPUnit\Framework\MockObject\MockObject;
use StdClass;
use Throwable;

Expand All @@ -40,7 +36,6 @@ public function setUp(): void

$this->installedModules = [];
$this->backupVarDirectory();
$this->truncateDatabase();
}

public function tearDown(): void
Expand All @@ -62,7 +57,6 @@ public function testVersionNotify(): void

$this->installModule('with_everything');

/** @var oxOnlineModuleVersionNotifierCaller|MockObject $oCaller */
$oCaller = $this->getMockBuilder(OnlineModuleVersionNotifierCaller::class)->disableOriginalConstructor()
->getMock();
$oCaller->expects($this->once())
Expand All @@ -73,12 +67,7 @@ public function testVersionNotify(): void
$oNotifier->versionNotify();
}

/**
* Returns formed request which should be returned during testing.
*
* @return oxOnlineModulesNotifierRequest
*/
private function getExpectedRequest()
private function getExpectedRequest(): OnlineModulesNotifierRequest
{
$request = oxNew(OnlineModulesNotifierRequest::class);

Expand Down Expand Up @@ -146,11 +135,6 @@ private function uninstallModule(string $moduleId): void
);
}

private function truncateDatabase(): void
{
DatabaseProvider::getDb()->execute('DELETE FROM `oxconfigdisplay`');
}

public function get(string $serviceId)
{
return ContainerFactory::getInstance()->getContainer()->get($serviceId);
Expand Down

0 comments on commit 2c5680a

Please sign in to comment.