Upgrade tests to PhpUnit 10 (#5252)
This commit is contained in:
@@ -92,26 +92,26 @@ class ColorTest extends TestCase
|
||||
public function testGetFontContrastColor(): void
|
||||
{
|
||||
$sut = new Color();
|
||||
$this->assertEquals('#ffffff', $sut->getFontContrastColor('#666'));
|
||||
$this->assertEquals('#ffffff', $sut->getFontContrastColor('#666666'));
|
||||
$this->assertEquals('#ffffff', $sut->getFontContrastColor('#000000'));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('#ccc'));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('#cccccc'));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('#ffffff'));
|
||||
self::assertEquals('#ffffff', $sut->getFontContrastColor('#666'));
|
||||
self::assertEquals('#ffffff', $sut->getFontContrastColor('#666666'));
|
||||
self::assertEquals('#ffffff', $sut->getFontContrastColor('#000000'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('#ccc'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('#cccccc'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('#ffffff'));
|
||||
}
|
||||
|
||||
public function testGetFontContrastColorReturnsContrastForDefaultColorOnInvalidColor(): void
|
||||
{
|
||||
$sut = new Color();
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor(''));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('000000'));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor(Constants::DEFAULT_COLOR));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('#6'));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('#66'));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('#6666'));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('#cccc'));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('#ccccc'));
|
||||
$this->assertEquals('#000000', $sut->getFontContrastColor('#ccccccc'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor(''));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('000000'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor(Constants::DEFAULT_COLOR));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('#6'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('#66'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('#6666'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('#cccc'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('#ccccc'));
|
||||
self::assertEquals('#000000', $sut->getFontContrastColor('#ccccccc'));
|
||||
}
|
||||
|
||||
public function testGetRandomColor(): void
|
||||
|
||||
@@ -21,8 +21,8 @@ class DurationTest extends TestCase
|
||||
{
|
||||
$sut = new Duration();
|
||||
|
||||
$this->assertNull($sut->format(null));
|
||||
$this->assertEquals('2:38', $sut->format(9494));
|
||||
self::assertNull($sut->format(null));
|
||||
self::assertEquals('2:38', $sut->format(9494));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ class DurationTest extends TestCase
|
||||
public function testParseDurationString($expected, $duration, $mode): void
|
||||
{
|
||||
$sut = new Duration();
|
||||
$this->assertEquals($expected, $sut->parseDurationString($duration));
|
||||
self::assertEquals($expected, $sut->parseDurationString($duration));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,10 +40,10 @@ class DurationTest extends TestCase
|
||||
public function testParseDuration($expected, $duration, $mode): void
|
||||
{
|
||||
$sut = new Duration();
|
||||
$this->assertEquals($expected, $sut->parseDuration($duration, $mode));
|
||||
self::assertEquals($expected, $sut->parseDuration($duration, $mode));
|
||||
}
|
||||
|
||||
public function getParseDurationTestData()
|
||||
public static function getParseDurationTestData()
|
||||
{
|
||||
return [
|
||||
[3600, 1, Duration::FORMAT_DECIMAL],
|
||||
@@ -80,7 +80,7 @@ class DurationTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function getParseDurationInvalidData()
|
||||
public static function getParseDurationInvalidData()
|
||||
{
|
||||
return [
|
||||
// invalid input
|
||||
|
||||
@@ -17,7 +17,7 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class FileHelperTest extends TestCase
|
||||
{
|
||||
public function getFileTestData()
|
||||
public static function getFileTestData()
|
||||
{
|
||||
return [
|
||||
['Barss_laolala_ld_ksjf_123_MyAwesome_GmbH', 'Barß / laölala # ld_ksjf 123 MyAwesome GmbH'],
|
||||
|
||||
@@ -21,13 +21,13 @@ class FormFormatConverterTest extends TestCase
|
||||
{
|
||||
$sut = new FormFormatConverter();
|
||||
|
||||
$this->assertEquals('dd.MM.yyyy', $sut->convert('dd.MM.yy'));
|
||||
$this->assertEquals('d.M.yyyy', $sut->convert('d.M.y'));
|
||||
$this->assertEquals('g:i A', $sut->convert('h:mm a'));
|
||||
$this->assertEquals('G:i', $sut->convert('H:mm'));
|
||||
$this->assertEquals('H.i', $sut->convert('HH.mm'));
|
||||
$this->assertEquals('A g:i', $sut->convert('a h:mm'));
|
||||
$this->assertEquals('H \h i', $sut->convert('HH \'h\' mm'));
|
||||
self::assertEquals('dd.MM.yyyy', $sut->convert('dd.MM.yy'));
|
||||
self::assertEquals('d.M.yyyy', $sut->convert('d.M.y'));
|
||||
self::assertEquals('g:i A', $sut->convert('h:mm a'));
|
||||
self::assertEquals('G:i', $sut->convert('H:mm'));
|
||||
self::assertEquals('H.i', $sut->convert('HH.mm'));
|
||||
self::assertEquals('A g:i', $sut->convert('a h:mm'));
|
||||
self::assertEquals('H \h i', $sut->convert('HH \'h\' mm'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ class FormFormatConverterTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function getProblemPattern()
|
||||
public static function getProblemPattern()
|
||||
{
|
||||
yield ["yy-MM-dd HH 'h' mm", '2009-08-06 17 h 45'];
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ class JavascriptFormatConverterTest extends TestCase
|
||||
public function test()
|
||||
{
|
||||
$sut = new JavascriptFormatConverter();
|
||||
$this->assertEquals('DD.MM.YYYY HH:mm', $sut->convert('dd.MM.y HH:mm'));
|
||||
$this->assertEquals('DD.MM.YYYY HH:mm', $sut->convert('dd.MM.yy HH:mm'));
|
||||
$this->assertEquals('DD.MM.YYYY HH:mm', $sut->convert('dd.MM.yyyy HH:mm'));
|
||||
$this->assertEquals('DD-MM-YYYY HH:mm', $sut->convert('dd-MM-yyyy HH:mm'));
|
||||
$this->assertEquals('D/MM/YYYY HH:mm', $sut->convert('d/MM/yyyy HH:mm'));
|
||||
$this->assertEquals('YYYY-MM-DD HH:mm', $sut->convert('yyyy-MM-dd HH:mm'));
|
||||
$this->assertEquals('YYYY.MM.DD. HH:mm A', $sut->convert('yyyy.MM.dd. HH:mm a'));
|
||||
self::assertEquals('DD.MM.YYYY HH:mm', $sut->convert('dd.MM.y HH:mm'));
|
||||
self::assertEquals('DD.MM.YYYY HH:mm', $sut->convert('dd.MM.yy HH:mm'));
|
||||
self::assertEquals('DD.MM.YYYY HH:mm', $sut->convert('dd.MM.yyyy HH:mm'));
|
||||
self::assertEquals('DD-MM-YYYY HH:mm', $sut->convert('dd-MM-yyyy HH:mm'));
|
||||
self::assertEquals('D/MM/YYYY HH:mm', $sut->convert('d/MM/yyyy HH:mm'));
|
||||
self::assertEquals('YYYY-MM-DD HH:mm', $sut->convert('yyyy-MM-dd HH:mm'));
|
||||
self::assertEquals('YYYY.MM.DD. HH:mm A', $sut->convert('yyyy.MM.dd. HH:mm a'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ class MarkdownTest extends TestCase
|
||||
public function testMarkdownToHtml(): void
|
||||
{
|
||||
$sut = new Markdown();
|
||||
$this->assertEquals('<p><em>test</em></p>', $sut->toHtml('*test*'));
|
||||
$this->assertEquals('<p># foobar</p>', $sut->toHtml('# foobar'));
|
||||
self::assertEquals('<p><em>test</em></p>', $sut->toHtml('*test*'));
|
||||
self::assertEquals('<p># foobar</p>', $sut->toHtml('# foobar'));
|
||||
$html = <<<'EOT'
|
||||
<p>foo bar</p>
|
||||
<ul>
|
||||
@@ -62,7 +62,7 @@ class MarkdownTest extends TestCase
|
||||
1111
|
||||
222
|
||||
EOT;
|
||||
$this->assertEquals($html, $sut->toHtml($markdown));
|
||||
self::assertEquals($html, $sut->toHtml($markdown));
|
||||
}
|
||||
|
||||
public function testDuplicateIds(): void
|
||||
@@ -82,7 +82,7 @@ class MarkdownTest extends TestCase
|
||||
### test
|
||||
# test
|
||||
EOT;
|
||||
$this->assertEquals($html, $sut->toHtml($markdown));
|
||||
self::assertEquals($html, $sut->toHtml($markdown));
|
||||
}
|
||||
|
||||
public function testLinksAreSanitized(): void
|
||||
@@ -100,6 +100,6 @@ class MarkdownTest extends TestCase
|
||||
[XSS](javascript:alert("XSS"))
|
||||
[XSS](javascript:alert('XSS'))
|
||||
EOT;
|
||||
$this->assertEquals($html, $sut->toHtml($markdown));
|
||||
self::assertEquals($html, $sut->toHtml($markdown));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class NumberGeneratorTest extends TestCase
|
||||
/**
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public function getTestData(): array
|
||||
public static function getTestData(): array
|
||||
{
|
||||
return [
|
||||
['DEMO-{XXX}-{known,5}', ['known' => 123], 'DEMO-{XXX}-00124', 0],
|
||||
|
||||
@@ -22,18 +22,18 @@ class PaginationTest extends TestCase
|
||||
public function testDefaults(): void
|
||||
{
|
||||
$sut = new Pagination(new ArrayAdapter([]));
|
||||
$this->assertEquals(1, $sut->getCurrentPage());
|
||||
$this->assertEquals(10, $sut->getMaxPerPage());
|
||||
$this->assertTrue($sut->getNormalizeOutOfRangePages());
|
||||
self::assertEquals(1, $sut->getCurrentPage());
|
||||
self::assertEquals(10, $sut->getMaxPerPage());
|
||||
self::assertTrue($sut->getNormalizeOutOfRangePages());
|
||||
}
|
||||
|
||||
public function testDefaultQuery(): void
|
||||
{
|
||||
$query = new TimesheetQuery();
|
||||
$sut = new Pagination(new ArrayAdapter([]), $query);
|
||||
$this->assertEquals(1, $sut->getCurrentPage());
|
||||
$this->assertEquals(50, $sut->getMaxPerPage());
|
||||
$this->assertTrue($sut->getNormalizeOutOfRangePages());
|
||||
self::assertEquals(1, $sut->getCurrentPage());
|
||||
self::assertEquals(50, $sut->getMaxPerPage());
|
||||
self::assertTrue($sut->getNormalizeOutOfRangePages());
|
||||
}
|
||||
|
||||
public function testWithParams(): void
|
||||
@@ -43,8 +43,8 @@ class PaginationTest extends TestCase
|
||||
$query->setPageSize(1);
|
||||
$query->setIsApiCall(true);
|
||||
$sut = new Pagination(new ArrayAdapter([1, 2, 3, 4, 5]), $query);
|
||||
$this->assertFalse($sut->getNormalizeOutOfRangePages());
|
||||
$this->assertEquals(1, $sut->getMaxPerPage());
|
||||
$this->assertEquals(3, $sut->getCurrentPage());
|
||||
self::assertFalse($sut->getNormalizeOutOfRangePages());
|
||||
self::assertEquals(1, $sut->getMaxPerPage());
|
||||
self::assertEquals(3, $sut->getCurrentPage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class ProfileManagerTest extends TestCase
|
||||
self::assertEquals(ProfileManager::PROFILE_DESKTOP, $sut->getProfileFromSession($session));
|
||||
}
|
||||
|
||||
public function getInvalidProfiles()
|
||||
public static function getInvalidProfiles()
|
||||
{
|
||||
return [
|
||||
['MOBILE'],
|
||||
@@ -54,7 +54,7 @@ class ProfileManagerTest extends TestCase
|
||||
self::assertFalse($sut->isValidProfile($profile));
|
||||
}
|
||||
|
||||
public function getDatatableNames()
|
||||
public static function getDatatableNames()
|
||||
{
|
||||
return [
|
||||
['admin-timesheet_mobile', 'admin-timesheet', 'mobile'],
|
||||
@@ -77,7 +77,7 @@ class ProfileManagerTest extends TestCase
|
||||
self::assertEquals($expected, $sut->getDatatableName($datatable, $prefix));
|
||||
}
|
||||
|
||||
public function getProfileNames()
|
||||
public static function getProfileNames()
|
||||
{
|
||||
return [
|
||||
['mobile', ProfileManager::PROFILE_MOBILE],
|
||||
@@ -125,7 +125,7 @@ class ProfileManagerTest extends TestCase
|
||||
self::assertNull($session->get(ProfileManager::SESSION_PROFILE));
|
||||
}
|
||||
|
||||
public function getCookieProfiles()
|
||||
public static function getCookieProfiles()
|
||||
{
|
||||
return [
|
||||
['mobile', ProfileManager::PROFILE_MOBILE],
|
||||
@@ -154,7 +154,7 @@ class ProfileManagerTest extends TestCase
|
||||
self::assertEquals($expected, $profile);
|
||||
}
|
||||
|
||||
public function getSessionProfiles()
|
||||
public static function getSessionProfiles()
|
||||
{
|
||||
return [
|
||||
['mobile', ProfileManager::PROFILE_MOBILE],
|
||||
|
||||
@@ -29,7 +29,7 @@ class StringHelperTest extends TestCase
|
||||
self::assertEquals(10, mb_strlen(StringHelper::ensureMaxLength('까깨꺄꺠꺼께껴꼐꼬꽈꼬꽈', 10)));
|
||||
}
|
||||
|
||||
public function getDdeAttackStrings()
|
||||
public static function getDdeAttackStrings()
|
||||
{
|
||||
yield ['DDE ("cmd";"/C calc";"!A0")A0'];
|
||||
yield [' DDE ("cmd";"/C calc";"!A0")A0'];
|
||||
@@ -56,7 +56,7 @@ class StringHelperTest extends TestCase
|
||||
self::assertEquals("' " . $input, StringHelper::sanitizeDDE($input));
|
||||
}
|
||||
|
||||
public function getNonDdeAttackStrings()
|
||||
public static function getNonDdeAttackStrings()
|
||||
{
|
||||
yield [''];
|
||||
yield [' '];
|
||||
|
||||
Reference in New Issue
Block a user