Skip to content

Commit

Permalink
[TASK] Upgrade to PHPUnit 10.x
Browse files Browse the repository at this point in the history
Also drop redundant configuration options.

Fixes #1574
  • Loading branch information
oliverklee committed Feb 3, 2025
1 parent 23027f1 commit 17f7056
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 264 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ updates:
allow:
- dependency-type: "development"
ignore:
- dependency-name: "brianium/paratest"
- dependency-name: "doctrine/dbal"
- dependency-name: "phpunit/phpunit"
versions: [ "^10.0" ]
- dependency-name: "symfony/console"
- dependency-name: "symfony/translation"
- dependency-name: "symfony/yaml"
Expand Down
6 changes: 0 additions & 6 deletions Build/php-cs-fixer/php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@

$config = CsFixerConfig::create();

$config->addRules([
// This is required as long as we are on PHPUnit 9.x. It can be removed after the switch to PHPUnit 10.x.
// @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/8337
'php_unit_test_case_static_method_calls' => ['call_type' => 'self', 'methods' => ['createStub' => 'this']],
]);

// @TODO 4.0 no need to call this manually
$config->setParallelConfig(ParallelConfigFactory::detect());

Expand Down
24 changes: 1 addition & 23 deletions Build/phpunit/FunctionalTests.xml
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
cacheResult="false"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
forceCoversAnnotation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
>
<coverage/>
<testsuites>
<testsuite name="Functional tests">
<!--
This path either needs an adaption in extensions, or an extension's
test location path needs to be given to phpunit.
-->
<directory suffix="Test.php">./</directory>
</testsuite>
</testsuites>
<php>
<!-- @deprecated: will be removed with next major version, constant TYPO3_MODE is deprecated -->
<const name="TYPO3_MODE" value="BE"/>
<!--
@deprecated: Set this to not suppress warnings, notices and deprecations in functional tests
with TYPO3 core v11 and up.
Expand Down
26 changes: 2 additions & 24 deletions Build/phpunit/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
cacheResult="false"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
>
<coverage/>
<testsuites>
<testsuite name="Unit tests">
<!--
This path either needs an adaption in extensions, or an extension's
test location path needs to be given to phpunit.
-->
<directory suffix="Test.php">./</directory>
</testsuite>
</testsuites>
<php>
<!-- @deprecated: will be removed with next major version, constant TYPO3_MODE is deprecated -->
<const name="TYPO3_MODE" value="BE"/>
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
</php>
Expand Down
34 changes: 10 additions & 24 deletions Tests/Functional/Command/CreateTestDataCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace TTN\Tea\Tests\Functional\Command;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use TTN\Tea\Command\CreateTestDataCommand;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

/**
* @covers \TTN\Tea\Command\CreateTestDataCommand
*/
#[CoversClass(CreateTestDataCommand::class)]
final class CreateTestDataCommandTest extends FunctionalTestCase
{
/**
Expand All @@ -38,35 +38,27 @@ protected function setUp(): void
$this->commandTester = new CommandTester($command);
}

/**
* @test
*/
#[Test]
public function isConsoleCommand(): void
{
self::assertInstanceOf(Command::class, $this->subject);
}

/**
* @test
*/
#[Test]
public function hasDescription(): void
{
$expected = 'Create test data for the tea extension in an already existing page (sysfolder).';
self::assertSame($expected, $this->subject->getHelp());
}

/**
* @test
*/
#[Test]
public function hasHelpText(): void
{
$expected = 'Create test data for the tea extension in an already existing page (sysfolder).';
self::assertSame($expected, $this->subject->getHelp());
}

/**
* @test
*/
#[Test]
public function runReturnsSuccessStatus(): void
{
$result = $this->commandTester->execute(
Expand All @@ -78,9 +70,7 @@ public function runReturnsSuccessStatus(): void
self::assertSame(Command::SUCCESS, $result);
}

/**
* @test
*/
#[Test]
public function createsTestData(): void
{
$this->commandTester->execute([
Expand All @@ -90,9 +80,7 @@ public function createsTestData(): void
$this->assertCSVDataSet(__DIR__ . '/Fixtures/Database/Teas.csv');
}

/**
* @test
*/
#[Test]
public function deletesExistingDataOnGivenPidBeforeCreatingNewData(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/Database/ExistingTeas.csv');
Expand All @@ -106,9 +94,7 @@ public function deletesExistingDataOnGivenPidBeforeCreatingNewData(): void
$this->assertCSVDataSet(__DIR__ . '/Fixtures/Database/TeasAfterDelete.csv');
}

/**
* @test
*/
#[Test]
public function doesNotDeleteDataOnOtherPid(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/Database/OtherExistingTeas.csv');
Expand Down
15 changes: 6 additions & 9 deletions Tests/Functional/Controller/TeaControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

namespace TTN\Tea\Tests\Functional\Controller;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TTN\Tea\Controller\TeaController;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

/**
* @covers \TTN\Tea\Controller\TeaController
*/
#[CoversClass(TeaController::class)]
final class TeaControllerTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = ['ttn/tea'];
Expand Down Expand Up @@ -49,9 +50,7 @@ protected function setUp(): void
$this->importCSVDataSet(__DIR__ . '/Fixtures/Database/Teas.csv');
}

/**
* @test
*/
#[Test]
public function indexActionRendersAllAvailableTeas(): void
{
$request = (new InternalRequest())->withPageId(1);
Expand All @@ -62,9 +61,7 @@ public function indexActionRendersAllAvailableTeas(): void
self::assertStringContainsString('Oolong', $html);
}

/**
* @test
*/
#[Test]
public function showActionRendersTheGivenTeas(): void
{
$request = (new InternalRequest())->withPageId(3)->withQueryParameters(['tx_tea_teashow[tea]' => 1]);
Expand Down
60 changes: 17 additions & 43 deletions Tests/Functional/Domain/Repository/TeaRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

namespace TTN\Tea\Tests\Functional\Domain\Repository;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TTN\Tea\Domain\Model\Tea;
use TTN\Tea\Domain\Repository\TeaRepository;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

/**
* @covers \TTN\Tea\Domain\Repository\TeaRepository
* @covers \TTN\Tea\Domain\Model\Tea
*/
#[CoversClass(TeaRepository::class)]
#[CoversClass(Tea::class)]
final class TeaRepositoryTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = ['ttn/tea'];
Expand All @@ -32,27 +32,21 @@ protected function setUp(): void
$this->subject = $this->get(TeaRepository::class);
}

/**
* @test
*/
#[Test]
public function isRepository(): void
{
self::assertInstanceOf(Repository::class, $this->subject);
}

/**
* @test
*/
#[Test]
public function findAllForNoRecordsReturnsEmptyContainer(): void
{
$result = $this->subject->findAll();

self::assertCount(0, $result);
}

/**
* @test
*/
#[Test]
public function findAllSortsByTitleInAscendingOrder(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/TwoUnsortedTeas.csv');
Expand All @@ -63,19 +57,15 @@ public function findAllSortsByTitleInAscendingOrder(): void
self::assertSame(2, $result->current()->getUid());
}

/**
* @test
*/
#[Test]
public function findByUidForInexistentRecordReturnsNull(): void
{
$model = $this->subject->findByUid(1);

self::assertNull($model);
}

/**
* @test
*/
#[Test]
public function findByUidForExistingRecordReturnsModel(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/TeaWithAllScalarData.csv');
Expand All @@ -85,9 +75,7 @@ public function findByUidForExistingRecordReturnsModel(): void
self::assertInstanceOf(Tea::class, $model);
}

/**
* @test
*/
#[Test]
public function findByUidForExistingRecordMapsAllScalarData(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/TeaWithAllScalarData.csv');
Expand All @@ -100,9 +88,7 @@ public function findByUidForExistingRecordMapsAllScalarData(): void
self::assertSame(2, $model->getOwnerUid());
}

/**
* @test
*/
#[Test]
public function fillsImageRelation(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/TeaWithImage.csv');
Expand All @@ -115,9 +101,7 @@ public function fillsImageRelation(): void
self::assertSame(1, $image->getUid());
}

/**
* @test
*/
#[Test]
public function addAndPersistAllCreatesNewRecord(): void
{
$title = 'Godesberger Burgtee';
Expand All @@ -130,9 +114,7 @@ public function addAndPersistAllCreatesNewRecord(): void
$this->assertCSVDataSet(__DIR__ . '/Fixtures/PersistedTea.csv');
}

/**
* @test
*/
#[Test]
public function findByOwnerUidFindsTeaWithTheGivenOwnerUid(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/TeaWithOwner.csv');
Expand All @@ -142,9 +124,7 @@ public function findByOwnerUidFindsTeaWithTheGivenOwnerUid(): void
self::assertCount(1, $result);
}

/**
* @test
*/
#[Test]
public function findByOwnerUidFindsTeaWithTheGivenOwnerUidOnPage(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/TeaWithOwnerOnPage.csv');
Expand All @@ -154,9 +134,7 @@ public function findByOwnerUidFindsTeaWithTheGivenOwnerUidOnPage(): void
self::assertCount(1, $result);
}

/**
* @test
*/
#[Test]
public function findByOwnerUidFindsIgnoresTeaWithNonMatchingOwnerUid(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/TeaWithOwner.csv');
Expand All @@ -166,9 +144,7 @@ public function findByOwnerUidFindsIgnoresTeaWithNonMatchingOwnerUid(): void
self::assertCount(0, $result);
}

/**
* @test
*/
#[Test]
public function findByOwnerUidFindsIgnoresTeaWithZeroOwnerUid(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/TeaWithoutOwner.csv');
Expand All @@ -178,9 +154,7 @@ public function findByOwnerUidFindsIgnoresTeaWithZeroOwnerUid(): void
self::assertCount(0, $result);
}

/**
* @test
*/
#[Test]
public function findByOwnerUidSortsByTitleInAscendingOrder(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/TwoTeasWithOwner.csv');
Expand Down
Loading

0 comments on commit 17f7056

Please sign in to comment.