Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
- ubuntu-latest

php:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
checks: write
strategy:
matrix:
php-versions: [ '8.2', '8.3', '8.4', '8.5' ]
php-versions: ['8.3', '8.4', '8.5' ]
steps:
- uses: actions/checkout@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
- ubuntu-latest

php:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/validate-database-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- ubuntu-latest

php:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 7.1.0 - 2026-04-22

### Changed

* Issue [#509](https://github.com/dotkernel/api/issues/509): Bump `PHPUnit` to version `12.5.23` by [@SergiuBota1](https://github.com/SergiuBota1) in [#510](https://github.com/dotkernel/admin/pull/510)

### Added

* Nothing

### Deprecated

* Nothing

### Removed

* Removed PHP `8.2` support

### Fixed

* Fixed PHPUnit notices caused by mock objects without expectations configured
* Fixed PHPUnit deprecation warnings caused by using `with()` on test stubs

## 7.0.0 - 2025-11-26

### Changed
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Documentation is available at: https://docs.dotkernel.org/api-documentation/

| Branch | Release | PSR-11 | OSS Lifecycle | PHP Version |
|--------|----------|--------|--------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
| 7.0 | `>= 7.0` | 1 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F7.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/7.0.0) |
| 7.0 | `>= 7.1` | 1 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F7.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/7.1.0) |
| 7.0 | `< 7.1` | 1 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F7.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/7.0.0) |
| 6.0 | `< 7.0` | 1 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F6.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/6.1.0) |
| 5.0 | `< 6.0` | 1 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F5.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/5.3.0) |
| 4.0 | `< 5.0` | 1 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F4.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/4.5.0) |
Expand All @@ -30,10 +31,10 @@ Documentation is available at: https://docs.dotkernel.org/api-documentation/
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/api)](https://github.com/dotkernel/api/stargazers)
[![GitHub license](https://img.shields.io/github/license/dotkernel/api)](https://github.com/dotkernel/api/blob/6.0/LICENSE.md)

[![Build Static](https://github.com/dotkernel/api/actions/workflows/continuous-integration.yml/badge.svg?branch=6.0)](https://github.com/dotkernel/api/actions/workflows/continuous-integration.yml)
[![Build Static](https://github.com/dotkernel/api/actions/workflows/continuous-integration.yml/badge.svg?branch=7.0)](https://github.com/dotkernel/api/actions/workflows/continuous-integration.yml)
[![codecov](https://codecov.io/gh/dotkernel/api/graph/badge.svg?token=53FN78G5CK)](https://codecov.io/gh/dotkernel/api)
[![Qodana](https://github.com/dotkernel/api/actions/workflows/qodana_code_quality.yml/badge.svg?branch=6.0)](https://github.com/dotkernel/api/actions/workflows/qodana_code_quality.yml)
[![PHPStan](https://github.com/dotkernel/api/actions/workflows/static-analysis.yml/badge.svg?branch=6.0)](https://github.com/dotkernel/api/actions/workflows/static-analysis.yml)
[![Qodana](https://github.com/dotkernel/api/actions/workflows/qodana_code_quality.yml/badge.svg?branch=7.0)](https://github.com/dotkernel/api/actions/workflows/qodana_code_quality.yml)
[![PHPStan](https://github.com/dotkernel/api/actions/workflows/static-analysis.yml/badge.svg?branch=7.0)](https://github.com/dotkernel/api/actions/workflows/static-analysis.yml)

## Getting Started

Expand Down
1 change: 1 addition & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

| Version | Supported | PHP Version |
|---------|--------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
| 7.1 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F7.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/7.1.0) |
| 7.0 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F7.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/7.0.0) |
| 6.0 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F6.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/6.1.0) |
| 5.0 | ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F5.0%2FOSSMETADATA) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/5.3.0) |
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}
},
"require": {
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
"ext-gd": "*",
"ext-json": "*",
"dotkernel/dot-cache": "^4.3",
Expand Down Expand Up @@ -89,7 +89,7 @@
"phpstan/phpstan": "^2.1.11",
"phpstan/phpstan-doctrine": "^2.0.2",
"phpstan/phpstan-phpunit": "^2.0.6",
"phpunit/phpunit": "^10.5.45",
"phpunit/phpunit": "^12.5.23",
"roave/security-advisories": "dev-latest",
"symfony/var-dumper": "^7.2.3"
},
Expand Down
5 changes: 4 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
bootstrap="vendor/autoload.php"
stopOnError="true"
stopOnFailure="true"
colors="true">
colors="true"
displayDetailsOnPhpunitNotices="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnPhpunitDeprecations="true">
<testsuites>
<testsuite name="UnitTests">
<directory>./test/Unit</directory>
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/App/src/Service/IpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class IpService
* @phpstan-param array{
* HTTP_X_FORWARDED_FOR?: string,
* HTTP_CLIENT_IP?: string,
* REMOTE_ADDR?: string,
* REMOTE_ADDR: string,
* } $server
*/
public static function getUserIp(array $server): mixed
Expand Down
2 changes: 1 addition & 1 deletion test/Functional/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public function testAdminCanCreateUserAccount(): void
$userRole = $userRoleRepository->findOneBy(['name' => UserRoleEnum::User]);
$this->assertInstanceOf(UserRole::class, $userRole);

$mailService = $this->createMock(MailService::class);
$mailService = $this->createStub(MailService::class);
$this->replaceService(MailService::class, $mailService);

$userData = [
Expand Down
24 changes: 12 additions & 12 deletions test/Functional/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testRegisterAccountDuplicateIdentity(): void
'status' => UserStatusEnum::Pending,
]);

$userAvatarService = $this->createMock(UserAvatarServiceInterface::class);
$userAvatarService = $this->createStub(UserAvatarServiceInterface::class);
$this->replaceService(UserAvatarServiceInterface::class, $userAvatarService);

$response = $this->post('/user/account', $this->getValidUserData(['status' => UserStatusEnum::Pending->value]));
Expand All @@ -71,7 +71,7 @@ public function testRegisterAccountDuplicateEmail(): void
'status' => UserStatusEnum::Pending,
]);

$userAvatarService = $this->createMock(UserAvatarServiceInterface::class);
$userAvatarService = $this->createStub(UserAvatarServiceInterface::class);
$this->replaceService(UserAvatarServiceInterface::class, $userAvatarService);

$response = $this->post('/user/account', $this->getValidUserData(['status' => UserStatusEnum::Pending->value]));
Expand All @@ -90,10 +90,10 @@ public function testRegisterAccountDuplicateEmail(): void
*/
public function testRegisterAccount(): void
{
$userAvatarService = $this->createMock(UserAvatarServiceInterface::class);
$userAvatarService = $this->createStub(UserAvatarServiceInterface::class);
$this->replaceService(UserAvatarServiceInterface::class, $userAvatarService);

$mailService = $this->createMock(MailService::class);
$mailService = $this->createStub(MailService::class);
$this->replaceService(MailService::class, $mailService);

$user = $this->getValidUserData([
Expand Down Expand Up @@ -121,7 +121,7 @@ public function testRegisterAccount(): void
public function testCreateMyAvatar(): void
{
$userAvatarRepository = $this->getEntityManager()->getRepository(UserAvatar::class);
$userAvatarService = $this->getMockBuilder(UserAvatarService::class)
$userAvatarService = $this->getStubBuilder(UserAvatarService::class)
->setConstructorArgs([
$userAvatarRepository,
[],
Expand All @@ -133,7 +133,7 @@ public function testCreateMyAvatar(): void
'createFileName',
'saveAvatarImage',
])
->getMock();
->getStub();
$this->replaceService(UserAvatarServiceInterface::class, $userAvatarService);

/** @var non-empty-string $identity */
Expand Down Expand Up @@ -274,7 +274,7 @@ public function testActivateAccountByEmail(): void
]);
$this->assertInstanceOf(UserDetail::class, $user->getDetail());

$mailService = $this->createMock(MailService::class);
$mailService = $this->createStub(MailService::class);
$this->replaceService(MailService::class, $mailService);

$response = $this->post('/user/account/activate', [
Expand Down Expand Up @@ -342,7 +342,7 @@ public function testRequestResetPasswordExpired(): void
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();

$mailService = $this->createMock(MailService::class);
$mailService = $this->createStub(MailService::class);
$this->replaceService(MailService::class, $mailService);

$response = $this->patch('/user/account/reset-password/' . $resetPassword->getHash(), [
Expand Down Expand Up @@ -376,7 +376,7 @@ public function testRequestResetPasswordAlreadyUsed(): void
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();

$mailService = $this->createMock(MailService::class);
$mailService = $this->createStub(MailService::class);
$this->replaceService(MailService::class, $mailService);

$response = $this->patch('/user/account/reset-password/' . $resetPassword->getHash(), [
Expand Down Expand Up @@ -410,7 +410,7 @@ public function testResetPassword(): void
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();

$mailService = $this->createMock(MailService::class);
$mailService = $this->createStub(MailService::class);
$this->replaceService(MailService::class, $mailService);

$response = $this->patch('/user/account/reset-password/' . $resetPassword->getHash(), [
Expand All @@ -433,7 +433,7 @@ public function testResetPassword(): void
*/
public function testResetPasswordByEmail(): void
{
$mailService = $this->createMock(MailService::class);
$mailService = $this->createStub(MailService::class);
$this->replaceService(MailService::class, $mailService);

$user = $this->createUser();
Expand Down Expand Up @@ -495,7 +495,7 @@ public function testRecoverAccountByIdentity(): void
$user = $this->createUser();
$this->assertInstanceOf(UserDetail::class, $user->getDetail());

$mailService = $this->createMock(MailService::class);
$mailService = $this->createStub(MailService::class);
$this->replaceService(MailService::class, $mailService);

$response = $this->post('/user/account/recover', [
Expand Down
10 changes: 5 additions & 5 deletions test/Unit/Admin/Service/AdminServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Core\Admin\Repository\AdminRepository;
use Core\Admin\Repository\AdminRoleRepository;
use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;

use function array_merge;
Expand All @@ -23,16 +23,16 @@
class AdminServiceTest extends TestCase
{
private AdminServiceInterface $adminService;
private AdminRepository&MockObject $adminRepository;
private AdminRoleRepository&MockObject $adminRoleRepository;
private AdminRepository&Stub $adminRepository;
private AdminRoleRepository&Stub $adminRoleRepository;

/**
* @throws \PHPUnit\Framework\MockObject\Exception
*/
public function setUp(): void
{
$this->adminRepository = $this->createMock(AdminRepository::class);
$this->adminRoleRepository = $this->createMock(AdminRoleRepository::class);
$this->adminRepository = $this->createStub(AdminRepository::class);
$this->adminRoleRepository = $this->createStub(AdminRoleRepository::class);
$this->adminService = new AdminService($this->adminRepository, $this->adminRoleRepository);
}

Expand Down
9 changes: 5 additions & 4 deletions test/Unit/App/Middleware/AuthenticationMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Mezzio\Authentication\UserInterface;
use PHPUnit\Framework\MockObject\Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand All @@ -19,19 +20,19 @@
class AuthenticationMiddlewareTest extends TestCase
{
private AuthenticationMiddleware $authenticationMiddleware;
private AuthenticationInterface&MockObject $auth;
private AuthenticationInterface&Stub $auth;
private ServerRequestInterface $request;
private RequestHandlerInterface&MockObject $handler;
private ResponseInterface&MockObject $response;
private ResponseInterface&Stub $response;

/**
* @throws Exception
*/
public function setUp(): void
{
$this->auth = $this->createMock(AuthenticationInterface::class);
$this->auth = $this->createStub(AuthenticationInterface::class);
$this->handler = $this->createMock(RequestHandlerInterface::class);
$this->response = $this->createMock(ResponseInterface::class);
$this->response = $this->createStub(ResponseInterface::class);
$this->request = new ServerRequest();

$this->authenticationMiddleware = new AuthenticationMiddleware($this->auth);
Expand Down
30 changes: 17 additions & 13 deletions test/Unit/App/Middleware/AuthorizationMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Mezzio\Authentication\UserInterface;
use Mezzio\Authorization\AuthorizationInterface;
use PHPUnit\Framework\MockObject\Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand All @@ -33,23 +33,23 @@
class AuthorizationMiddlewareTest extends TestCase
{
private AuthorizationMiddleware $authorizationMiddleware;
private UserRepository&MockObject $userRepository;
private AdminRepository&MockObject $adminRepository;
private AuthorizationInterface&MockObject $authorization;
private UserRepository&Stub $userRepository;
private AdminRepository&Stub $adminRepository;
private AuthorizationInterface&Stub $authorization;
private ServerRequestInterface $request;
private RequestHandlerInterface&MockObject $handler;
private ResponseInterface $response;
private RequestHandlerInterface&Stub $handler;
private ResponseInterface&Stub $response;

/**
* @throws Exception
*/
public function setUp(): void
{
$this->userRepository = $this->createMock(UserRepository::class);
$this->adminRepository = $this->createMock(AdminRepository::class);
$this->authorization = $this->createMock(AuthorizationInterface::class);
$this->handler = $this->createMock(RequestHandlerInterface::class);
$this->response = $this->createMock(ResponseInterface::class);
$this->userRepository = $this->createStub(UserRepository::class);
$this->adminRepository = $this->createStub(AdminRepository::class);
$this->authorization = $this->createStub(AuthorizationInterface::class);
$this->handler = $this->createStub(RequestHandlerInterface::class);
$this->response = $this->createStub(ResponseInterface::class);
$this->request = new ServerRequest();

$this->authorizationMiddleware = new AuthorizationMiddleware(
Expand Down Expand Up @@ -150,6 +150,9 @@ public function testAuthorizationNotGranted(): void
);
}

/**
* @throws Exception
*/
public function testAuthorizationAccessGranted(): void
{
$user = (new User())
Expand All @@ -162,7 +165,8 @@ public function testAuthorizationAccessGranted(): void
$identity = new UserIdentity('test@dotkernel.com', ['user'], ['oauth_client_id' => 'frontend']);
$this->request = $this->request->withAttribute(UserInterface::class, $identity);

$this->handler
$handler = $this->createMock(RequestHandlerInterface::class);
$handler
->expects($this->once())
->method('handle')
->willReturnCallback(function (ServerRequestInterface $request) use ($identity) {
Expand All @@ -173,6 +177,6 @@ public function testAuthorizationAccessGranted(): void
return $this->response;
});

$this->authorizationMiddleware->process($this->request, $this->handler);
$this->authorizationMiddleware->process($this->request, $handler);
}
}
Loading
Loading