Skip to content

Commit edb5f7e

Browse files
committed
Merge branch 'b-7.5.x-phpunit12-OXDEV-9641' into b-7.5.x
2 parents 8af954a + 1c9dc12 commit edb5f7e

43 files changed

Lines changed: 136 additions & 104 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG-v13.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Changed
1010
- Update module to work with OXID eShop 7.5
1111
- Minimum PHP version is now 8.3, tested up to PHP 8.5
12+
- Upgraded PHPUnit from 11 to 12

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"myclabs/php-enum": "^1.8"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^11.4",
19+
"phpunit/phpunit": "^12.0",
2020
"ext-xdebug": "*",
2121
"oxid-esales/oxideshop-ce": "dev-b-7.5.x",
2222
"phpstan/phpstan": "^1.10",

tests/Integration/Infrastructure/LegacyTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use OxidEsales\GraphQL\Base\Exception\InvalidLogin;
1717
use OxidEsales\GraphQL\Base\Infrastructure\Legacy;
1818
use OxidEsales\GraphQL\Base\Tests\Integration\TestCase;
19+
use PHPUnit\Framework\Attributes\DataProvider;
1920

2021
class LegacyTest extends TestCase
2122
{
@@ -50,9 +51,7 @@ public function testInvalidLogin(): void
5051
);
5152
}
5253

53-
/**
54-
* @dataProvider loginResponseTestDataProvider
55-
*/
54+
#[DataProvider('loginResponseTestDataProvider')]
5655
public function testLoginResponseIsAnonymousOnLoginMissing(
5756
?string $login,
5857
?string $password,

tests/Integration/Infrastructure/RefreshTokenRepositoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ private function checkRefreshTokenWithIdExists(string $oxid): bool
195195
public function addToken(
196196
string $oxid,
197197
string $expires,
198-
string $userId = null,
199-
string $token = null,
198+
?string $userId = null,
199+
?string $token = null,
200200
): void {
201201
$insertTokensQuery = "insert into `oegraphqlrefreshtoken` (OXID, OXUSERID, TOKEN, EXPIRES_AT)
202202
values (:oxid, :oxuserid, :token, :expires)";

tests/Integration/Infrastructure/RepositoryTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
use OxidEsales\GraphQL\Base\DataType\Pagination\Pagination;
1515
use OxidEsales\GraphQL\Base\DataType\Sorting\Sorting as BaseSorting;
1616
use OxidEsales\GraphQL\Base\Infrastructure\Repository;
17+
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
18+
use PHPUnit\Framework\Attributes\CoversClass;
1719
use PHPUnit\Framework\TestCase;
1820

19-
/**
20-
* @covers OxidEsales\GraphQL\Base\Infrastructure\Repository
21-
*/
21+
#[AllowMockObjectsWithoutExpectations]
22+
#[CoversClass(\OxidEsales\GraphQL\Base\Infrastructure\Repository::class)]
2223
final class RepositoryTest extends TestCase
2324
{
2425
public function testFatalErrorOnWrongClassById(): void

tests/Integration/Infrastructure/TokenTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
use OxidEsales\GraphQL\Base\Infrastructure\Token as TokenInfrastructure;
2222
use OxidEsales\GraphQL\Base\Service\Token;
2323
use OxidEsales\GraphQL\Base\Service\Token as TokenService;
24+
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
2425

26+
#[AllowMockObjectsWithoutExpectations]
2527
class TokenTest extends IntegrationTestCase
2628
{
2729
private const TEST_TOKEN_ID = '_my_test_token';

tests/Integration/TestCase.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
use OxidEsales\GraphQL\Base\Service\Authorization;
2828
use OxidEsales\GraphQL\Base\Service\ModuleConfiguration;
2929
use OxidEsales\GraphQL\Base\Service\Token;
30+
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
3031
use Psr\Log\LoggerInterface;
3132
use ReflectionClass;
3233
use Symfony\Component\DependencyInjection\ContainerBuilder;
3334

35+
#[AllowMockObjectsWithoutExpectations]
3436
abstract class TestCase extends IntegrationTestCase
3537
{
3638
protected static $queryResult;
@@ -126,25 +128,21 @@ protected function setAuthToken(string $token): void
126128
$tokenService = static::$container->get(Token::class);
127129
$refClass = new ReflectionClass(Token::class);
128130
$prop = $refClass->getProperty('token');
129-
$prop->setAccessible(true);
130131
$prop->setValue($tokenService, $authToken);
131132

132133
$authentication = static::$container->get(Authentication::class);
133134
$refClass = new ReflectionClass(Authentication::class);
134135
$prop = $refClass->getProperty('tokenService');
135-
$prop->setAccessible(true);
136136
$prop->setValue($authentication, $tokenService);
137137

138138
$authorization = static::$container->get(Authorization::class);
139139
$refClass = new ReflectionClass(Authorization::class);
140140
$prop = $refClass->getProperty('tokenService');
141-
$prop->setAccessible(true);
142141
$prop->setValue($authorization, $tokenService);
143142

144143
$schema = static::$container->get(SchemaFactory::class);
145144
$refClass = new ReflectionClass(SchemaFactory::class);
146145
$prop = $refClass->getProperty('schema');
147-
$prop->setAccessible(true);
148146
$prop->setValue($schema, null);
149147
}
150148

@@ -217,7 +215,6 @@ protected function uploadFile(
217215
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
218216

219217
$response = curl_exec($ch);
220-
curl_close($ch);
221218

222219
return json_decode($response, true) ?: [];
223220
}

tests/Unit/BaseTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
use OxidEsales\GraphQL\Base\Service\Token;
2525
use OxidEsales\GraphQL\Base\Service\Token as TokenService;
2626
use OxidEsales\GraphQL\Base\Service\TokenValidator;
27+
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
2728
use PHPUnit\Framework\TestCase;
2829
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2930

31+
#[AllowMockObjectsWithoutExpectations]
3032
abstract class BaseTestCase extends TestCase
3133
{
3234
protected function getModuleConfigurationMock(string $lifetime = '+8 hours'): ModuleConfiguration

tests/Unit/Controller/LoginTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
use OxidEsales\GraphQL\Base\Service\LoginServiceInterface;
2020
use OxidEsales\GraphQL\Base\Service\Token as TokenService;
2121
use OxidEsales\GraphQL\Base\Tests\Unit\BaseTestCase;
22+
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
2223
use PHPUnit\Framework\MockObject\MockObject;
2324
use Symfony\Component\EventDispatcher\EventDispatcher;
2425

26+
#[AllowMockObjectsWithoutExpectations]
2527
class LoginTest extends BaseTestCase
2628
{
2729
/** @var Legacy|MockObject */

tests/Unit/Controller/TokenTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
use OxidEsales\GraphQL\Base\Service\Token as TokenService;
2424
use OxidEsales\GraphQL\Base\Service\TokenAdministration as TokenAdministration;
2525
use OxidEsales\GraphQL\Base\Tests\Unit\BaseTestCase;
26+
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
2627
use TheCodingMachine\GraphQLite\Types\ID;
2728

2829
//todo: tests do not do any assertions, fix it.
30+
#[AllowMockObjectsWithoutExpectations]
2931
class TokenTest extends BaseTestCase
3032
{
3133
public function testTokensQueryWithDefaultFilters(): void
@@ -123,11 +125,11 @@ public function testRefreshGivesStringValueOfNewToken(): void
123125
}
124126

125127
private function getTokenController(
126-
TokenAdministration $tokenAdministration = null,
127-
Authentication $authentication = null,
128-
Authorization $authorization = null,
129-
TokenService $tokenService = null,
130-
RefreshTokenServiceInterface $refreshTokenService = null,
128+
?TokenAdministration $tokenAdministration = null,
129+
?Authentication $authentication = null,
130+
?Authorization $authorization = null,
131+
?TokenService $tokenService = null,
132+
?RefreshTokenServiceInterface $refreshTokenService = null,
131133
): TokenController {
132134
return new TokenController(
133135
tokenAdministration: $tokenAdministration ?? $this->createStub(TokenAdministration::class),

0 commit comments

Comments
 (0)