Skip to content

Commit dea3c74

Browse files
committed
Run with shop 8.0.x and facts spike
1 parent e15cf86 commit dea3c74

File tree

10 files changed

+110
-44
lines changed

10 files changed

+110
-44
lines changed

.github/workflows/dispatch_module.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- 'PHP8.3/MySQL5.7'
1414
- 'PHP8.3/MySQL8.0'
1515
- 'PHP8.3/MariaDb11'
16-
default: 'PHP8.2/MySQL5.7'
16+
default: 'PHP8.3/MySQL8.0'
1717
description: 'Limit to one PHP/MySQL combination'
1818

1919
jobs:
@@ -40,7 +40,7 @@ jobs:
4040
;;
4141
esac
4242
# shellcheck disable=SC2088
43-
TESTPLAN="~/defaults/7.3.x.yaml,${LIMIT}~/graphql-base.yaml"
43+
TESTPLAN="~/defaults/8.0.x.yaml,${LIMIT}~/graphql-base.yaml"
4444
echo "testplan=${TESTPLAN}" | tee -a "${GITHUB_OUTPUT}"
4545
4646
dispatch_stable:

CHANGELOG-v10.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Undecided] - unrelreased
7+
## [Undecided] - unreleased
8+
9+
## Changed
10+
- Update module to work with OXID eShop 8.0
11+
12+
## [Undecided] - unreleased
813

914
## Changed
1015
- Update module to work with OXID eShop 7.3

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
"symfony/cache": "*",
1414
"ecodev/graphql-upload": "^7.0.0",
1515
"laminas/laminas-diactoros": "^2.5",
16-
"myclabs/php-enum": "^1.8"
16+
"myclabs/php-enum": "^1.8",
17+
"oxid-esales/oxideshop-facts": "dev-b-8.0.x-compatibility-OXDEV-7248"
1718
},
1819
"require-dev": {
1920
"phpunit/phpunit": "^10.4",
2021
"ext-xdebug": "*",
21-
"oxid-esales/oxideshop-ce": "dev-b-7.3.x",
22+
"oxid-esales/oxideshop-ce": "dev-b-8.0.x",
2223
"phpstan/phpstan": "^1.10",
2324
"squizlabs/php_codesniffer": "3.*",
2425
"phpmd/phpmd": "^2.11",
@@ -27,7 +28,7 @@
2728
"codeception/module-phpbrowser": "*",
2829
"codeception/module-db": "*",
2930
"codeception/codeception": "^5.0",
30-
"oxid-esales/codeception-modules": "dev-b-7.3.x",
31+
"oxid-esales/codeception-modules": "dev-b-8.0.x",
3132
"codeception/module-asserts": "^3.0"
3233
},
3334
"conflict": {

tests/Codeception/Acceptance.suite.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# suite config
22
actor: AcceptanceTester
33
path: Acceptance
4+
bootstrap: _bootstrap.php
5+
46
modules:
57
enabled:
68
- Asserts

tests/Codeception/Config/CodeceptionParametersProvider.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99

1010
namespace OxidEsales\GraphQL\Base\Tests\Codeception\Config;
1111

12+
use OxidEsales\Codeception\Module\Database;
1213
use OxidEsales\Codeception\Module\Database\DatabaseDefaultsFileGenerator;
13-
use OxidEsales\Facts\Config\ConfigFile;
1414
use OxidEsales\Facts\Facts;
1515
use Symfony\Component\Filesystem\Path;
1616

17-
if ($shopRootPath = getenv('SHOP_ROOT_PATH')) {
18-
require_once(Path::join($shopRootPath, 'source', 'bootstrap.php'));
19-
}
20-
2117
class CodeceptionParametersProvider {
2218

2319
public function getParameters(): array
@@ -35,7 +31,7 @@ public function getParameters(): array
3531
'DB_HOST' => $facts->getDatabaseHost(),
3632
'DB_PORT' => $facts->getDatabasePort(),
3733
'MODULE_DUMP_PATH' => $this->getModuleTestDataDumpFilePath(),
38-
'MYSQL_CONFIG_PATH' => $this->getMysqlConfigPath(),
34+
'MYSQL_CONFIG_PATH' => $this->generateMysqlStarUpConfigurationFile(),
3935
'PHP_BIN' => $php,
4036
];
4137
}
@@ -45,14 +41,16 @@ private function getModuleTestDataDumpFilePath()
4541
return Path::join(__DIR__, '..', 'Support', 'Data', 'dump.sql');
4642
}
4743

48-
private function getMysqlConfigPath()
44+
private function generateMysqlStarUpConfigurationFile(): string
4945
{
5046
$facts = new Facts();
51-
$configFile = new ConfigFile($facts->getSourcePath() . '/config.inc.php');
52-
53-
$generator = new DatabaseDefaultsFileGenerator($configFile);
5447

55-
return $generator->generate();
48+
return Database::generateStartupOptionsFile(
49+
$facts->getDatabaseUserName(),
50+
$facts->getDatabasePassword(),
51+
$facts->getDatabaseHost(),
52+
$facts->getDatabasePort(),
53+
);
5654
}
5755
}
5856

tests/Integration/Framework/GraphQLQueryHandlerFileUploadTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace OxidEsales\GraphQL\Base\Tests\Integration\Framework;
1111

12+
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
1213
use OxidEsales\EshopCommunity\Internal\Container\BootstrapContainerFactory;
1314
use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Dao\ProjectYamlDao;
1415
use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Service\ProjectYamlImportService;
@@ -34,6 +35,8 @@ public static function tearDownAfterClass(): void
3435

3536
public function testFileUpload(): void
3637
{
38+
ContainerFactory::resetContainer();
39+
3740
$expected = file_get_contents(self::UPLOAD_FILE);
3841
$result = $this->uploadFile(self::UPLOAD_FILE, $this->getMutationData());
3942

tests/Integration/Infrastructure/RefreshTokenRepositoryTest.php

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
use DateTime;
1313
use DateTimeImmutable;
14-
use Doctrine\DBAL\Connection;
15-
use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionProviderInterface;
14+
use OxidEsales\EshopCommunity\Core\Di\ContainerFacade;
15+
use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionFactoryInterface;
1616
use OxidEsales\GraphQL\Base\DataType\UserInterface;
1717
use OxidEsales\GraphQL\Base\Exception\InvalidRefreshToken;
1818
use OxidEsales\GraphQL\Base\Infrastructure\RefreshTokenRepository;
@@ -23,6 +23,13 @@
2323
#[CoversClass(RefreshTokenRepository::class)]
2424
class RefreshTokenRepositoryTest extends TestCase
2525
{
26+
protected function tearDown(): void
27+
{
28+
$this->cleanUp();
29+
30+
parent::tearDown();
31+
}
32+
2633
public function testGetNewRefreshTokenGivesCorrectlyFilledDataType(): void
2734
{
2835
$sut = $this->getSut();
@@ -172,21 +179,18 @@ public function testInvalidateRefreshTokensWrongUserId(): void
172179
$this->assertTrue($sut->getTokenUser($token) instanceof UserInterface);
173180
}
174181

175-
private function getDbConnection(): Connection
176-
{
177-
return $this->get(ConnectionProviderInterface::class)->get();
178-
}
179-
180182
public function getSut(): RefreshTokenRepositoryInterface
181183
{
182-
return $this->get(RefreshTokenRepositoryInterface::class);
184+
return self::$container->get(RefreshTokenRepositoryInterface::class);
183185
}
184186

185187
private function checkRefreshTokenWithIdExists(string $oxid): bool
186188
{
187-
$result = $this->getDbConnection()->executeQuery(
188-
"select count(*) from `oegraphqlrefreshtoken` where OXID=:oxid",
189-
['oxid' => $oxid]
189+
$result = ContainerFacade::get(ConnectionFactoryInterface::class)
190+
->create()
191+
->executeQuery(
192+
"select count(*) from `oegraphqlrefreshtoken` where OXID=:oxid",
193+
['oxid' => $oxid]
190194
);
191195

192196
return $result->fetchOne() > 0;
@@ -200,11 +204,22 @@ public function addToken(
200204
): void {
201205
$insertTokensQuery = "insert into `oegraphqlrefreshtoken` (OXID, OXUSERID, TOKEN, EXPIRES_AT)
202206
values (:oxid, :oxuserid, :token, :expires)";
203-
$this->getDbConnection()->executeQuery($insertTokensQuery, [
207+
ContainerFacade::get(ConnectionFactoryInterface::class)
208+
->create()
209+
->executeQuery($insertTokensQuery, [
204210
"oxid" => $oxid,
205211
"oxuserid" => $userId ?? uniqid(),
206212
'token' => $token ?? uniqid(),
207213
"expires" => $expires,
208214
]);
209215
}
216+
217+
private function cleanUp(): void
218+
{
219+
ContainerFacade::get(ConnectionFactoryInterface::class)
220+
->create()
221+
->executeQuery(
222+
'truncate table `oegraphqlrefreshtoken`'
223+
);
224+
}
210225
}

tests/Integration/Infrastructure/TokenTest.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@
1313
use Lcobucci\JWT\Token\DataSet;
1414
use Lcobucci\JWT\UnencryptedToken;
1515
use OxidEsales\Eshop\Application\Model\User;
16-
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;
16+
use OxidEsales\EshopCommunity\Core\Di\ContainerFacade;
17+
use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionFactoryInterface;
1718
use OxidEsales\EshopCommunity\Tests\TestContainerFactory;
1819
use OxidEsales\GraphQL\Base\DataType\Token as TokenDataType;
1920
use OxidEsales\GraphQL\Base\DataType\User as UserDataType;
2021
use OxidEsales\GraphQL\Base\Infrastructure\Model\Token as TokenModel;
2122
use OxidEsales\GraphQL\Base\Infrastructure\Token as TokenInfrastructure;
2223
use OxidEsales\GraphQL\Base\Service\Token;
2324
use OxidEsales\GraphQL\Base\Service\Token as TokenService;
25+
use OxidEsales\EshopCommunity\Tests\ContainerTrait;
26+
use PHPUnit\Framework\TestCase;
2427

25-
class TokenTest extends IntegrationTestCase
28+
class TokenTest extends TestCase
2629
{
2730
private const TEST_TOKEN_ID = '_my_test_token';
2831

@@ -31,15 +34,33 @@ class TokenTest extends IntegrationTestCase
3134
/** @var TokenInfrastructure */
3235
private $tokenInfrastructure;
3336

34-
public function setUp(): void
37+
protected function setUp(): void
3538
{
3639
parent::setUp();
3740
$containerFactory = new TestContainerFactory();
3841
$container = $containerFactory->create();
42+
43+
$container->setParameter(
44+
'oxid_esales.db.replicate',
45+
false
46+
);
47+
$container->setParameter(
48+
'oxid_esales.db.replicas',
49+
[]
50+
);
51+
3952
$container->compile();
4053
$this->tokenInfrastructure = $container->get(TokenInfrastructure::class);
4154
}
4255

56+
protected function tearDown(): void
57+
{
58+
$this->cleanUp();
59+
60+
parent::tearDown();
61+
}
62+
63+
4364
public function testRegisterToken(): void
4465
{
4566
$this->tokenInfrastructure->registerToken(
@@ -311,7 +332,7 @@ public function testUserHasToken(): void
311332
public function testInvalidateTokenAfterDeleteUser(): void
312333
{
313334
$userModel = oxNew(User::class);
314-
$userModel->setId('_testUser');
335+
$userModel->setId(self::TEST_USER_ID);
315336
$userModel->setPassword('_testPassword');
316337
$userModel->assign(['oxusername' => '_testUsername']);
317338
$userModel->save();
@@ -379,4 +400,13 @@ private function getTokenMock(
379400

380401
return $token;
381402
}
403+
404+
private function cleanUp(): void
405+
{
406+
ContainerFacade::get(ConnectionFactoryInterface::class)
407+
->create()
408+
->executeQuery(
409+
'truncate table `oegraphqltoken`'
410+
);
411+
}
382412
}

tests/Integration/TestCase.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use DateTimeImmutable;
1313
use Lcobucci\JWT\UnencryptedToken;
1414
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
15-
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
16-
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;
15+
use OxidEsales\EshopCommunity\Core\Di\ContainerFacade;
16+
use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionFactoryInterface;
1717
use OxidEsales\EshopCommunity\Tests\TestContainerFactory;
1818
use OxidEsales\Facts\Facts;
1919
use OxidEsales\GraphQL\Base\DataType\UserInterface;
@@ -30,8 +30,10 @@
3030
use Psr\Log\LoggerInterface;
3131
use ReflectionClass;
3232
use Symfony\Component\DependencyInjection\ContainerBuilder;
33+
use PHPUnit\Framework\TestCase as FrameworkTestCase;
3334

34-
abstract class TestCase extends IntegrationTestCase
35+
36+
abstract class TestCase extends FrameworkTestCase
3537
{
3638
protected static $queryResult;
3739

@@ -42,17 +44,13 @@ abstract class TestCase extends IntegrationTestCase
4244

4345
protected static $query;
4446

45-
public function setUp(): void
47+
protected function setUp(): void
4648
{
4749
parent::setUp();
4850

49-
$connection = ContainerFactory::getInstance()
50-
->getContainer()
51-
->get(QueryBuilderFactoryInterface::class)
51+
ContainerFacade::get(ConnectionFactoryInterface::class)
5252
->create()
53-
->getConnection();
54-
55-
$connection->executeStatement(
53+
->executeStatement(
5654
file_get_contents(
5755
__DIR__ . '/../Fixtures/dump.sql'
5856
)
@@ -63,6 +61,9 @@ public function setUp(): void
6361
if (static::$container !== null) {
6462
return;
6563
}
64+
65+
# ContainerFactory::resetContainer();
66+
6667
$containerFactory = new TestContainerFactory();
6768
static::$container = $containerFactory->create();
6869

@@ -97,13 +98,21 @@ public function setUp(): void
9798
'oxidesales.graphqlbase.cacheadapter',
9899
$cache
99100
);
101+
static::$container->setParameter(
102+
'oxid_esales.db.replicate',
103+
false
104+
);
105+
static::$container->setParameter(
106+
'oxid_esales.db.replicas',
107+
[]
108+
);
100109

101110
static::beforeContainerCompile();
102111

103112
static::$container->compile();
104113
}
105114

106-
public function tearDown(): void
115+
protected function tearDown(): void
107116
{
108117
parent::tearDown();
109118
static::$queryResult = null;
@@ -116,6 +125,8 @@ public function tearDown(): void
116125
}
117126
unset($_SERVER['HTTP_AUTHORIZATION']);
118127
}
128+
129+
# ContainerFactory::resetContainer();
119130
}
120131

121132
protected function setAuthToken(string $token): void

tests/phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
cacheDirectory=".phpunit.cache"
66
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
77
displayDetailsOnTestsThatTriggerWarnings="true"
8+
processIsolation="true"
89
>
910
<testsuites>
1011
<testsuite name="Unit">

0 commit comments

Comments
 (0)