Skip to content

Commit

Permalink
fix: phpunit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DDEV User committed Sep 19, 2024
1 parent b29bb51 commit b64f093
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 20 deletions.
19 changes: 8 additions & 11 deletions Tests/Functional/Caching/FlushViaDataHandlerChangesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

namespace Sinso\Variables\Tests\Functional\Caching;

use Generator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Sinso\Variables\Hooks\DataHandler;
Expand All @@ -37,9 +40,7 @@ class FlushViaDataHandlerChangesTest extends FunctionalTestCase
{
use ProphecyTrait;

/**
* @test
*/
#[Test]
public function canBeCreated(): void
{
$subject = new DataHandler();
Expand All @@ -50,10 +51,8 @@ public function canBeCreated(): void
);
}

/**
* @test
* @dataProvider possibleNoneTriggeringParams
*/
#[Test]
#[DataProvider('possibleNoneTriggeringParams')]
public function doesNotInteractWithCacheManagerOnUnkownData(array $params): void
{
$cacheManager = $this->prophesize(CacheManager::class);
Expand All @@ -68,7 +67,7 @@ public function doesNotInteractWithCacheManagerOnUnkownData(array $params): void
/**
* @return Generator<string,array{params:array}|array{params:array<string,string>}>
*/
public function possibleNoneTriggeringParams(): \Generator
public static function possibleNoneTriggeringParams(): Generator
{
yield 'no table given' => [
'params' => [],
Expand All @@ -87,9 +86,7 @@ public function possibleNoneTriggeringParams(): \Generator
];
}

/**
* @test
*/
#[Test]
public function flushCachesByGroupForMarker(): void
{
$cacheManager = $this->prophesize(CacheManager::class);
Expand Down
15 changes: 15 additions & 0 deletions Tests/Functional/Frontend/AbstractProcessesMarkersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

namespace Sinso\Variables\Tests\Functional\Frontend;

use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

abstract class AbstractProcessesMarkersTest extends FunctionalTestCase
{

protected array $testExtensionsToLoad = [
'typo3conf/ext/variables',
];
Expand All @@ -36,6 +38,19 @@ abstract class AbstractProcessesMarkersTest extends FunctionalTestCase
'typo3conf/ext/variables/Tests/Functional/Fixtures/Frontend/Sites/' => 'typo3conf/sites',
];

protected array $configurationToUseInTestInstance = [
'SYS' => [
'caching' => [
'cacheConfigurations' => [
// Set pages cache database backend, testing-framework sets this to NullBackend by default.
'pages' => [
'backend' => Typo3DatabaseBackend::class,
],
],
],
],
];

protected function setUp(): void
{
parent::setUp();
Expand Down
4 changes: 3 additions & 1 deletion Tests/Functional/Frontend/BreaksOnInvalidHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace Sinso\Variables\Tests\Functional\Frontend;

use PHPUnit\Framework\Attributes\Test;
use Sinso\Variables\Tests\Functional\Fixtures\Frontend\Hook\NotImplementingInterface;

/**
Expand All @@ -40,7 +41,8 @@ class BreaksOnInvalidHookTest extends AbstractProcessesMarkersTest
],
];

public function testThrowsExceptionIfConfiguredClassDoesntImplementInterface(): void
#[Test]
public function throwsExceptionIfConfiguredClassDoesntImplementInterface(): void
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Sinso\Variables\Tests\Functional\Fixtures\Frontend\Hook\NotImplementingInterface does not implement Sinso\Variables\Hooks\MarkersProcessorInterface');
Expand Down
4 changes: 3 additions & 1 deletion Tests/Functional/Frontend/ProcessesMarkersHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace Sinso\Variables\Tests\Functional\Frontend;

use PHPUnit\Framework\Attributes\Test;
use Sinso\Variables\Tests\Functional\Fixtures\Frontend\Hook\ImplementingInterface;

/**
Expand All @@ -40,7 +41,8 @@ class ProcessesMarkersHookTest extends AbstractProcessesMarkersTest
],
];

public function testExecutesHookClass(): void
#[Test]
public function executesHookClass(): void
{
$this->importDataSet('EXT:variables/Tests/Functional/Fixtures/Frontend/Marker.xml');

Expand Down
16 changes: 10 additions & 6 deletions Tests/Functional/Frontend/ProcessesMarkersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@

namespace Sinso\Variables\Tests\Functional\Frontend;

use PHPUnit\Framework\Attributes\Test;

/**
* @covers \Sinso\Variables\Hooks\ContentProcessor
*/
class ProcessesMarkersTest extends AbstractProcessesMarkersTest
{
/**
* @test
*/

#[Test]
public function noMarkerAppliedAsNoneExist(): void
{
self::assertStringContainsString(
Expand All @@ -42,7 +43,8 @@ public function noMarkerAppliedAsNoneExist(): void
self::assertCount(1, $pageCache);
}

public function testAppliesMarkersStoredOnSamePage(): void
#[Test]
public function appliesMarkersStoredOnSamePage(): void
{
$this->importDataSet('EXT:variables/Tests/Functional/Fixtures/Frontend/Marker.xml');

Expand All @@ -56,7 +58,8 @@ public function testAppliesMarkersStoredOnSamePage(): void
self::assertSame('tx_variables_key_hash_b3560bb929f682dcc19c903256f98639', $pageCache[0]['tag']);
}

public function testAppliesMarkersFromRootlinePage(): void
#[Test]
public function appliesMarkersFromRootlinePage(): void
{
$this->importDataSet('EXT:variables/Tests/Functional/Fixtures/Frontend/Marker.xml');

Expand All @@ -71,7 +74,8 @@ public function testAppliesMarkersFromRootlinePage(): void
self::assertSame('tx_variables_key_hash_7324efb2ab7ff6e7ef0fe77210ff6b20', $pageCache[1]['tag']);
}

public function testAppliesMarkersFromConfiguredStoragePid(): void
#[Test]
public function appliesMarkersFromConfiguredStoragePid(): void
{
$this->importDataSet('EXT:variables/Tests/Functional/Fixtures/Frontend/Marker.xml');

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"require-dev": {
"rector/rector": "^0.12.23",
"typo3/testing-framework": "^6.0 || ^7.0",
"typo3/testing-framework": "^7.0",
"phpspec/prophecy-phpunit": "^2.0",
"symplify/easy-coding-standard": "^10.2"
},
Expand Down

0 comments on commit b64f093

Please sign in to comment.