chore: upgrade phpunit to 12.5

This commit is contained in:
fromme committed 2026-10-01 10:07:05 +02:00
1 parent da039d0527
commit 849da8d471
53 files changed
+832 -856

No files matched your search

@@ -22,9 +22,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/
class AbstractFilterHandlerTest extends TestCase
{
/**
* @dataProvider legacyCountries
*/
#[\PHPUnit\Framework\Attributes\DataProvider('legacyCountries')]
public function testALegacyCountryIsTranslatedToItsIsoCode(?string $stored, ?string $expected): void
{
$this->assertSame($expected, $this->handler()->translate($stored));
@@ -67,7 +65,7 @@ class AbstractFilterHandlerTest extends TestCase
private function handler(): object
{
return new class($this->createMock(RequestStack::class), $this->createMock(EntityManagerInterface::class)) extends AbstractFilterHandler {
return new class($this->createStub(RequestStack::class), $this->createStub(EntityManagerInterface::class)) extends AbstractFilterHandler {
protected string $modelClass = AssignmentFilterDto::class;
public function translate(?string $country): ?string
@@ -87,6 +87,6 @@ class TeamerFilterHandlerTest extends TestCase
$requestStack = new RequestStack();
$requestStack->push($request);
return new TeamerFilterHandler($requestStack, $this->createMock(EntityManagerInterface::class));
return new TeamerFilterHandler($requestStack, $this->createStub(EntityManagerInterface::class));
}
}
@@ -11,7 +11,7 @@ use App\Entity\Teamer;
use App\Repository\DispositionRepository;
use App\Service\Cron\DispositionStatusService;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
@@ -24,14 +24,14 @@ use Psr\Log\NullLogger;
*/
class DispositionStatusServiceTest extends TestCase
{
private DispositionRepository&MockObject $repository;
private DispositionRepository&Stub $repository;
private DispositionStatusService $service;
protected function setUp(): void
{
$this->repository = $this->createMock(DispositionRepository::class);
$this->repository = $this->createStub(DispositionRepository::class);
$entityManager = $this->createMock(EntityManagerInterface::class);
$entityManager = $this->createStub(EntityManagerInterface::class);
$entityManager
->method('getRepository')
->willReturn($this->repository)
@@ -17,6 +17,7 @@ use App\Repository\SeasonAssignmentTaskRepository;
use App\Service\Cron\SeasonTaskReminderService;
use App\Service\Season\SeasonAssignmentLabeler;
use App\Service\Season\SeasonTaskDeadlineResolver;
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
@@ -26,6 +27,7 @@ use Psr\Log\NullLogger;
* anyone twice. That property, and what does and does not silence a reminder, is what is pinned
* here - the queries behind them are asserted in the repository test.
*/
#[AllowMockObjectsWithoutExpectations]
class SeasonTaskReminderServiceTest extends TestCase
{
private SeasonAssignmentTaskRepository&MockObject $repository;
@@ -14,6 +14,7 @@ use App\Entity\Embeddable\Communication;
use App\Entity\Teamer;
use App\Repository\DispositionRepository;
use App\Service\Cron\UploadReminderService;
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
@@ -25,6 +26,7 @@ use Psr\Log\NullLogger;
* arithmetic the service hands over, because a reminder that asks for the wrong day is just as
* silent as the broken queries these replaced.
*/
#[AllowMockObjectsWithoutExpectations]
class UploadReminderServiceTest extends TestCase
{
private const CONTRACT_DEADLINE_DAYS = 5;
@@ -11,6 +11,7 @@ use App\Entity\Teamer;
use App\Entity\TeamerWorkMonth;
use App\Repository\TeamerWorkMonthRepository;
use App\Service\Cron\WorkMonthReminderService;
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
@@ -19,6 +20,7 @@ use Psr\Log\NullLogger;
* Pins the rules the reminder applies: which day it runs on, how long it waits after an
* import, and who it can actually reach. The query itself is the repository's business.
*/
#[AllowMockObjectsWithoutExpectations]
class WorkMonthReminderServiceTest extends TestCase
{
private TeamerWorkMonthRepository&MockObject $repository;
+8 -11
View File
@@ -12,10 +12,9 @@ use App\Entity\JobProfile;
use App\Entity\Teamer;
use App\Entity\Upload;
use App\Service\Pdf\InvoiceApprover;
use App\Service\Pdf\InvoiceRenderer;
use App\Service\Pdf\Pdf;
use App\Service\Upload\UploadHandler;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -27,7 +26,7 @@ class InvoiceApproverTest extends WebTestCase
private string $pdfPath;
private string $origPath;
private Filesystem $filesystem;
private UploadHandler&MockObject $uploadHandler;
private UploadHandler&Stub $uploadHandler;
protected function setUp(): void
{
@@ -38,7 +37,7 @@ class InvoiceApproverTest extends WebTestCase
$this->pdfPath = $this->invoiceDir.'/test_approver_backup.pdf';
$this->origPath = $this->invoiceDir.'/test_approver_backup.orig.pdf';
$this->filesystem = new Filesystem();
$this->uploadHandler = $this->createMock(UploadHandler::class);
$this->uploadHandler = $this->createStub(UploadHandler::class);
$this->filesystem->mkdir($this->invoiceDir);
}
@@ -81,10 +80,7 @@ class InvoiceApproverTest extends WebTestCase
private function createApprover(): InvoiceApprover
{
$translator = $this->createMock(TranslatorInterface::class);
/** @var TranslatorInterface $translator */
return new InvoiceApprover($translator, ['project_dir' => $this->projectDir], $this->uploadHandler);
return new InvoiceApprover($this->createStub(TranslatorInterface::class), ['project_dir' => $this->projectDir], $this->uploadHandler);
}
private function createDispositionWithInvoicePdf(): Disposition
@@ -109,7 +105,7 @@ class InvoiceApproverTest extends WebTestCase
$jobProfile->setName('Testprofil');
$jobProfile->setCostUnit('200');
$assignment = $this->createMock(Assignment::class);
$assignment = $this->createStub(Assignment::class);
$assignment->method('getDestination')->willReturn($destination);
$assignment->method('getJobProfile')->willReturn($jobProfile);
@@ -134,8 +130,9 @@ class InvoiceApproverTest extends WebTestCase
;
$disposition->addDocument($invoice);
$this->uploadHandler->method('getResolvedUploadFilepath')->with($invoice)->willReturn($this->pdfPath);
$this->uploadHandler->method('getUploadFilepath')->with($invoice)->willReturn($this->pdfPath);
$filepath = fn (Upload $upload): string => $invoice === $upload ? $this->pdfPath : throw new \LogicException('Unexpected upload');
$this->uploadHandler->method('getResolvedUploadFilepath')->willReturnCallback($filepath);
$this->uploadHandler->method('getUploadFilepath')->willReturnCallback($filepath);
return $disposition;
}
+6 -5
View File
@@ -25,7 +25,7 @@ class InvoiceRendererTest extends WebTestCase
public function testRendersInvoice(): void
{
$projectDir = static::getContainer()->getParameter('kernel.project_dir');
$translator = $this->createMock(TranslatorInterface::class);
$translator = $this->createStub(TranslatorInterface::class);
/** @var TranslatorInterface $translator */
$renderer = new InvoiceRenderer($translator, ['project_dir' => $projectDir]);
@@ -82,7 +82,7 @@ class InvoiceRendererTest extends WebTestCase
->setEmail('[email protected]')
;
$assignment = $this->createMock(Assignment::class);
$assignment = $this->createStub(Assignment::class);
$assignment->method('getId')->willReturn(1234);
$assignment->method('getDestination')->willReturn($destination);
$assignment->method('getJobProfile')->willReturn($jobProfile);
@@ -108,9 +108,10 @@ class InvoiceRendererTest extends WebTestCase
$disposition->addDocument($invoice);
$invoicePath = $projectDir.'/uploads/invoice/a/abcdef0123456789.pdf';
$uploadHandler = $this->createMock(UploadHandler::class);
$uploadHandler->method('getResolvedUploadFilepath')->with($invoice)->willReturn($invoicePath);
$uploadHandler->method('getUploadFilepath')->with($invoice)->willReturn($invoicePath);
$uploadHandler = $this->createStub(UploadHandler::class);
$filepath = static fn (Upload $upload): string => $invoice === $upload ? $invoicePath : throw new \LogicException('Unexpected upload');
$uploadHandler->method('getResolvedUploadFilepath')->willReturnCallback($filepath);
$uploadHandler->method('getUploadFilepath')->willReturnCallback($filepath);
/** @var TranslatorInterface $translator */
$approver = new InvoiceApprover($translator, ['project_dir' => $projectDir], $uploadHandler);
@@ -18,24 +18,27 @@ use App\Saas\Model\EmployeeDirectory;
use App\Saas\ResponseParser;
use App\Service\Saas\WorkHoursSynchronizer;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
#[AllowMockObjectsWithoutExpectations]
class WorkHoursSynchronizerTest extends TestCase
{
private ApiClient&MockObject $apiClient;
private EmployeeDataProvider&MockObject $employeeDataProvider;
private TeamerWorkMonthRepository&MockObject $workMonthRepository;
private EmployeeDataProvider&Stub $employeeDataProvider;
private TeamerWorkMonthRepository&Stub $workMonthRepository;
private EntityManagerInterface&MockObject $entityManager;
private WorkHoursSynchronizer $synchronizer;
protected function setUp(): void
{
$this->apiClient = $this->createMock(ApiClient::class);
$this->workMonthRepository = $this->createMock(TeamerWorkMonthRepository::class);
$this->workMonthRepository = $this->createStub(TeamerWorkMonthRepository::class);
$this->entityManager = $this->createMock(EntityManagerInterface::class);
$this->employeeDataProvider = $this->createMock(EmployeeDataProvider::class);
$this->employeeDataProvider = $this->createStub(EmployeeDataProvider::class);
// Registered by default; the tests that care say otherwise.
$this->employeeDataProvider->method('getDirectory')->willReturn(
@@ -48,7 +51,7 @@ class WorkHoursSynchronizerTest extends TestCase
$this->apiClient,
new ResponseParser(),
$this->employeeDataProvider,
$this->createMock(TeamerRepository::class),
$this->createStub(TeamerRepository::class),
$this->workMonthRepository,
$this->entityManager,
new NullLogger(),
@@ -85,7 +88,7 @@ class WorkHoursSynchronizerTest extends TestCase
*/
public function testATeamerMissingFromTheRosterIsSkippedWithoutAnyRequest(): void
{
$provider = $this->createMock(EmployeeDataProvider::class);
$provider = $this->createStub(EmployeeDataProvider::class);
$provider->method('getDirectory')->willReturn(
EmployeeDirectory::fromEmployees([new Employee('[email protected]', 'e-9', 'Service', false)])
);
@@ -97,7 +100,7 @@ class WorkHoursSynchronizerTest extends TestCase
$apiClient,
new ResponseParser(),
$provider,
$this->createMock(TeamerRepository::class),
$this->createStub(TeamerRepository::class),
$this->workMonthRepository,
$this->entityManager,
new NullLogger(),
@@ -115,7 +118,7 @@ class WorkHoursSynchronizerTest extends TestCase
*/
public function testAnUnreachableRosterDoesNotSkipEveryone(): void
{
$provider = $this->createMock(EmployeeDataProvider::class);
$provider = $this->createStub(EmployeeDataProvider::class);
$provider->method('getDirectory')->willReturn(EmployeeDirectory::fromEmployees([]));
$this->apiClient->method('getTimeAccount')->willReturn($this->payload());
@@ -125,7 +128,7 @@ class WorkHoursSynchronizerTest extends TestCase
$this->apiClient,
new ResponseParser(),
$provider,
$this->createMock(TeamerRepository::class),
$this->createStub(TeamerRepository::class),
$this->workMonthRepository,
$this->entityManager,
new NullLogger(),
@@ -29,7 +29,7 @@ class SeasonChecklistBuilderTest extends TestCase
->setDocument($document)
);
$builder = new SeasonChecklistBuilder($this->createMock(SeasonTaskDeadlineResolver::class));
$builder = new SeasonChecklistBuilder($this->createStub(SeasonTaskDeadlineResolver::class));
$rows = $builder->build($seasonAssignment);
@@ -44,7 +44,7 @@ class SeasonChecklistBuilderTest extends TestCase
(new SeasonAssignmentTask())->setTaskKey(SeasonTask::MASTER_DATA->value)
);
$builder = new SeasonChecklistBuilder($this->createMock(SeasonTaskDeadlineResolver::class));
$builder = new SeasonChecklistBuilder($this->createStub(SeasonTaskDeadlineResolver::class));
$rows = $builder->build($seasonAssignment);
@@ -22,7 +22,7 @@ class SeasonChecklistStatusTest extends TestCase
protected function setUp(): void
{
$this->builder = new SeasonChecklistBuilder($this->createMock(SeasonTaskDeadlineResolver::class));
$this->builder = new SeasonChecklistBuilder($this->createStub(SeasonTaskDeadlineResolver::class));
}
public function testItIsOpenWhileAnEntryRequiringAReturnIsOpen(): void
@@ -12,7 +12,9 @@ use App\Entity\Upload;
use App\Repository\SeasonTaskDocumentRepository;
use App\Service\Season\SeasonTaskSynchronizer;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
/**
@@ -20,16 +22,17 @@ use PHPUnit\Framework\TestCase;
* that is what is asserted: new entries appear on assignments that already exist, and rows of
* an entry that was removed are left alone rather than deleted.
*/
#[AllowMockObjectsWithoutExpectations]
class SeasonTaskSynchronizerTest extends TestCase
{
private EntityManagerInterface&MockObject $entityManager;
private SeasonTaskDocumentRepository&MockObject $seasonTaskDocumentRepository;
private SeasonTaskDocumentRepository&Stub $seasonTaskDocumentRepository;
private SeasonTaskSynchronizer $synchronizer;
protected function setUp(): void
{
$this->entityManager = $this->createMock(EntityManagerInterface::class);
$this->seasonTaskDocumentRepository = $this->createMock(SeasonTaskDocumentRepository::class);
$this->seasonTaskDocumentRepository = $this->createStub(SeasonTaskDocumentRepository::class);
$this->synchronizer = new SeasonTaskSynchronizer(
$this->entityManager,
@@ -12,21 +12,24 @@ use App\Enum\StatisticsEventName;
use App\Service\Statistics\StatisticsRecorder;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception\DatabaseRequired;
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\SecurityBundle\Security;
#[AllowMockObjectsWithoutExpectations]
class StatisticsRecorderTest extends TestCase
{
private Connection&MockObject $connection;
private Security&MockObject $security;
private Security&Stub $security;
private LoggerInterface&MockObject $logger;
protected function setUp(): void
{
$this->connection = $this->createMock(Connection::class);
$this->security = $this->createMock(Security::class);
$this->security = $this->createStub(Security::class);
$this->logger = $this->createMock(LoggerInterface::class);
}
@@ -8,10 +8,12 @@ use App\Entity\Teamer;
use App\Entity\User;
use App\Service\Teamer\AccountDeletionHandler;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
#[AllowMockObjectsWithoutExpectations]
class AccountDeletionHandlerTest extends TestCase
{
private EntityManagerInterface&MockObject $entityManager;
@@ -23,7 +25,7 @@ class AccountDeletionHandlerTest extends TestCase
$this->handler = new AccountDeletionHandler(
$this->entityManager,
$this->createMock(LoggerInterface::class),
$this->createStub(LoggerInterface::class),
);
}
@@ -8,17 +8,17 @@ use App\Config\SeasonCalendar;
use App\Entity\Teamer;
use App\Repository\DispositionRepository;
use App\Service\Teamer\SeasonDispositionCounter;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
class SeasonDispositionCounterTest extends TestCase
{
private DispositionRepository&MockObject $dispositionRepository;
private DispositionRepository&Stub $dispositionRepository;
private SeasonDispositionCounter $counter;
protected function setUp(): void
{
$this->dispositionRepository = $this->createMock(DispositionRepository::class);
$this->dispositionRepository = $this->createStub(DispositionRepository::class);
$this->counter = new SeasonDispositionCounter(
$this->dispositionRepository,
@@ -15,20 +15,23 @@ use App\Model\TeamerMailingRecipient;
use App\Model\TeamerMailingRecipientsDto;
use App\Repository\TeamerRepository;
use App\Service\Teamer\TeamerMailingService;
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
#[AllowMockObjectsWithoutExpectations]
class TeamerMailingServiceTest extends TestCase
{
private TeamerRepository&MockObject $teamerRepository;
private TeamerRepository&Stub $teamerRepository;
private Mailer&MockObject $mailer;
private TeamerMailingService $service;
private static int $nextId = 1;
protected function setUp(): void
{
$this->teamerRepository = $this->createMock(TeamerRepository::class);
$this->teamerRepository = $this->createStub(TeamerRepository::class);
$this->mailer = $this->createMock(Mailer::class);
// The real renderer, not a mock: what the mailing puts in front of a teamer is
@@ -37,7 +40,7 @@ class TeamerMailingServiceTest extends TestCase
$this->teamerRepository,
$this->mailer,
new MailBodyRenderer(),
$this->createMock(LoggerInterface::class),
$this->createStub(LoggerInterface::class),
'mailing',
);
}
@@ -17,6 +17,7 @@ use App\Entity\User;
use App\Service\Teamer\TeamerProvisioner;
use App\Service\Teamer\TeamerProvisioningException;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
@@ -28,6 +29,7 @@ use Psr\Log\NullLogger;
* client: what runs, in which order, what is persisted before the next step, and what a retry does
* after a failure halfway.
*/
#[AllowMockObjectsWithoutExpectations]
class TeamerProvisionerTest extends TestCase
{
private const SELECTION_ID = 1070;
@@ -366,7 +368,7 @@ class TeamerProvisionerTest extends TestCase
return new TeamerProvisioner(
$this->apiClient,
$this->userDataHandler,
$this->createMock(EntityManagerInterface::class),
$this->createStub(EntityManagerInterface::class),
new NullLogger(),
self::SELECTION_ID,
);
+3 -3
View File
@@ -110,9 +110,9 @@ class UploadHandlerTest extends TestCase
private function handler(string $replacementFile = self::REPLACEMENT_FILE): UploadHandler
{
return new UploadHandler(
$this->createMock(RequestStack::class),
$this->createMock(OrphanageManager::class),
$this->createMock(Sanitizer::class),
$this->createStub(RequestStack::class),
$this->createStub(OrphanageManager::class),
$this->createStub(Sanitizer::class),
new NullLogger(),
$this->featureManager,
$this->projectDir,