Skip to content

Commit

Permalink
[TASK] Rector up to PHPUnit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrodala committed Mar 26, 2024
1 parent c58ca2c commit 00d5e31
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 95 deletions.
14 changes: 6 additions & 8 deletions Tests/Functional/Domain/Form/Finishers/LoggerFinisherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Pagemachine\Formlog\Tests\Functional\Domain\Form\Finishers;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Configuration\SiteConfiguration;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Core\Bootstrap;
Expand Down Expand Up @@ -79,10 +81,8 @@ protected function tearDown(): void
unset($GLOBALS['TSFE']);
}

/**
* @test
* @dataProvider formData
*/
#[DataProvider('formData')]
#[Test]
public function logsSubmittedFormData(array $fields, array $formValues, string $expectedData)
{
$formDefinition = $this->buildFormDefinition([
Expand Down Expand Up @@ -110,7 +110,7 @@ public function logsSubmittedFormData(array $fields, array $formValues, string $
self::assertSame('[]', $logEntry['finisher_variables'] ?? null);
}

public function formData(): \Generator
public static function formData(): \Generator
{
yield 'basic' => [
[
Expand Down Expand Up @@ -185,9 +185,7 @@ public function formData(): \Generator
];
}

/**
* @test
*/
#[Test]
public function logsFinisherVariables()
{
$formDefinition = $this->buildFormDefinition([
Expand Down
10 changes: 5 additions & 5 deletions Tests/Functional/Domain/FormLog/SuggestionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Pagemachine\Formlog\Tests\Functional\Domain\FormLog;

use Pagemachine\Formlog\Domain\FormLog\Suggestions;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
Expand All @@ -18,10 +20,8 @@ final class SuggestionsTest extends FunctionalTestCase
'typo3conf/ext/formlog',
];

/**
* @test
* @dataProvider properties
*/
#[DataProvider('properties')]
#[Test]
public function returnsSuggestionsForProperty(string $property, array $expected): void
{
$data = [
Expand Down Expand Up @@ -72,7 +72,7 @@ public function returnsSuggestionsForProperty(string $property, array $expected)
self::assertEquals($expected, $result);
}

public function properties(): \Generator
public static function properties(): \Generator
{
yield 'basic' => [
'identifier',
Expand Down
10 changes: 4 additions & 6 deletions Tests/Unit/Domain/Data/JsonDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
namespace Pagemachine\Formlog\Tests\Unit\Domain\Data;

use Pagemachine\Formlog\Domain\Data\JsonData;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
* Testcase for Pagemachine\Formlog\Domain\Data\JsonData
*/
final class JsonDataTest extends UnitTestCase
{
/**
* @test
*/
#[Test]
public function parseJsonString(): JsonData
{
$jsonString = '{"foo":"bar","qux":10}';
Expand All @@ -26,9 +26,7 @@ public function parseJsonString(): JsonData
return $data;
}

/**
* @depends parseJsonString
*/
#[Depends('parseJsonString')]
public function formatJsonData(JsonData $data): void
{
$jsonString = (string)$data;
Expand Down
18 changes: 5 additions & 13 deletions Tests/Unit/Domain/FormLog/DateRangeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/*
* This file is part of the Pagemachine TYPO3 Formlog project.
*/

use Pagemachine\Formlog\Domain\FormLog\DateRangeFilter;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

Expand All @@ -27,9 +27,7 @@ protected function tearDown(): void
GeneralUtility::purgeInstances();
}

/**
* @test
*/
#[Test]
public function constructsWithDates()
{
$date1 = new \DateTime();
Expand All @@ -40,19 +38,15 @@ public function constructsWithDates()
self::assertSame($date2, $dateRangeFilter->getEndDate());
}

/**
* @test
*/
#[Test]
public function isEmptyByDefault()
{
$dateRangeFilter = new DateRangeFilter();

self::assertTrue($dateRangeFilter->isEmpty());
}

/**
* @test
*/
#[Test]
public function isNotEmptyWithAtLeastOneDate()
{
$date1 = new \DateTime();
Expand All @@ -71,9 +65,7 @@ public function isNotEmptyWithAtLeastOneDate()
self::assertFalse($dateRangeFilter->isEmpty());
}

/**
* @test
*/
#[Test]
public function canBeConvertedToArray(): void
{
$dateRangeFilter = new DateRangeFilter(
Expand Down
30 changes: 8 additions & 22 deletions Tests/Unit/Domain/FormLog/FiltersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
/*
* This file is part of the Pagemachine TYPO3 Formlog project.
*/

use Pagemachine\Formlog\Domain\FormLog\DateRangeFilter;
use Pagemachine\Formlog\Domain\FormLog\Filters;
use Pagemachine\Formlog\Domain\FormLog\ValueFilter;
use PHPUnit\Framework\Attributes\Test;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
Expand All @@ -32,9 +32,7 @@ protected function tearDown(): void
GeneralUtility::purgeInstances();
}

/**
* @test
*/
#[Test]
public function constructsWithFilters()
{
$pageTitleFilter = $this->prophesize(ValueFilter::class)->reveal();
Expand All @@ -47,9 +45,7 @@ public function constructsWithFilters()
self::assertSame($submissionDateFilter, $filters->getSubmissionDate());
}

/**
* @test
*/
#[Test]
public function constructsWithFilterDefaults()
{
$filters = new Filters();
Expand All @@ -58,19 +54,15 @@ public function constructsWithFilterDefaults()
self::assertInstanceOf(DateRangeFilter::class, $filters->getSubmissionDate());
}

/**
* @test
*/
#[Test]
public function isEmptyByDefault()
{
$filters = new Filters();

self::assertTrue($filters->isEmpty());
}

/**
* @test
*/
#[Test]
public function isNotEmptyWithAtLeastOneNonEmptyFilter()
{
$pageTitleFilter = $this->prophesize(ValueFilter::class);
Expand All @@ -91,9 +83,7 @@ public function isNotEmptyWithAtLeastOneNonEmptyFilter()
self::assertFalse($filters->isEmpty());
}

/**
* @test
*/
#[Test]
public function yieldsNothingOnTraversalByDefault()
{
$filters = new Filters();
Expand All @@ -102,9 +92,7 @@ public function yieldsNothingOnTraversalByDefault()
self::assertEmpty($items);
}

/**
* @test
*/
#[Test]
public function yieldsNonEmptyFiltersOnTraversal()
{
$pageTitleFilter = $this->prophesize(ValueFilter::class);
Expand Down Expand Up @@ -132,9 +120,7 @@ public function yieldsNonEmptyFiltersOnTraversal()
self::assertCount(2, $items);
}

/**
* @test
*/
#[Test]
public function canBeConvertedToArray(): void
{
$pageTitleFilter = $this->prophesize(ValueFilter::class);
Expand Down
18 changes: 5 additions & 13 deletions Tests/Unit/Domain/FormLog/ValueFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/*
* This file is part of the Pagemachine TYPO3 Formlog project.
*/

use Pagemachine\Formlog\Domain\FormLog\ValueFilter;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

Expand All @@ -27,39 +27,31 @@ protected function tearDown(): void
GeneralUtility::purgeInstances();
}

/**
* @test
*/
#[Test]
public function constructsWithValue()
{
$valueFilter = new ValueFilter('foo');

self::assertEquals('foo', $valueFilter->getValue());
}

/**
* @test
*/
#[Test]
public function isEmptyByDefault()
{
$valueFilter = new ValueFilter();

self::assertTrue($valueFilter->isEmpty());
}

/**
* @test
*/
#[Test]
public function isNotEmptyWithValue()
{
$valueFilter = new ValueFilter('foo');

self::assertFalse($valueFilter->isEmpty());
}

/**
* @test
*/
#[Test]
public function canBeConvertedToArray(): void
{
$valueFilter = new ValueFilter('foo');
Expand Down
6 changes: 2 additions & 4 deletions Tests/Unit/Export/AbstractExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@
/*
* This file is part of the Pagemachine TYPO3 Formlog project.
*/

use Pagemachine\Formlog\Export\AbstractExport;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
* Testcase for Pagemachine\Formlog\Export\AbstractExport
*/
final class AbstractExportTest extends UnitTestCase
{
/**
* @test
*/
#[Test]
public function sortsColumns(): void
{
$export = new class () extends AbstractExport {
Expand Down
10 changes: 5 additions & 5 deletions Tests/Unit/Form/Element/JSONDataElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
/*
* This file is part of the Pagemachine TYPO3 Formlog project.
*/

use Pagemachine\Formlog\Form\Element\JSONDataElement;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Backend\Form\NodeFactory;
Expand All @@ -33,12 +34,11 @@ protected function tearDown(): void
}

/**
* @test
* @dataProvider samples
*
* @param string $formElementValue
* @param string $expected
*/
#[DataProvider('samples')]
#[Test]
public function rendersFormData($formElementValue, $expected)
{
$iconFactory = $this->prophesize(IconFactory::class);
Expand All @@ -60,7 +60,7 @@ public function rendersFormData($formElementValue, $expected)
self::assertEquals($expected, $result['html']);
}

public function samples()
public static function samples()
{
$expected = <<<HTML
<table class="table table-striped table-hover">
Expand Down
9 changes: 3 additions & 6 deletions Tests/Unit/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@
namespace Pagemachine\Formlog\Tests\Unit;

use Pagemachine\Formlog\Json;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
* Testcase for Pagemachine\Formlog\Json
*/
final class JsonTest extends UnitTestCase
{
/**
* @test
*/
#[Test]
public function failDecodingInvalidJsonString(): void
{
$this->expectException(\JsonException::class);

Json::decode('');
}

/**
* @test
*/
#[Test]
public function failEncodingRecursiveValue(): void
{
$array1 = [];
Expand Down
Loading

0 comments on commit 00d5e31

Please sign in to comment.