diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2025-01-05 22:59:29 +0000 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2025-01-06 12:47:39 +0000 |
| commit | 24cb7547cb882ddc3e5b99cdff164831ef80290c (patch) | |
| tree | 98e5b0ad6c11771ae5ed86c89965027fd1ddc4ef /tests | |
| parent | ab70d7f0caddd7fcd86d1f539eafdf19f1e65698 (diff) | |
| download | webtrees-24cb7547cb882ddc3e5b99cdff164831ef80290c.tar.gz webtrees-24cb7547cb882ddc3e5b99cdff164831ef80290c.tar.bz2 webtrees-24cb7547cb882ddc3e5b99cdff164831ef80290c.zip | |
Working on phpstan issues in test scripts
Diffstat (limited to 'tests')
44 files changed, 362 insertions, 264 deletions
diff --git a/tests/TestCase.php b/tests/TestCase.php index ba4c025b5f..1998009147 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -90,7 +90,7 @@ class TestCase extends \PHPUnit\Framework\TestCase /** * Create a request and bind it into the container. * - * @param array<string> $query + * @param array<string|array<string>> $query * @param array<string> $params * @param array<UploadedFileInterface> $files * @param array<string|Tree> $attributes @@ -103,6 +103,7 @@ class TestCase extends \PHPUnit\Framework\TestCase array $attributes = [] ): ServerRequestInterface { $server_request_factory = Registry::container()->get(ServerRequestFactoryInterface::class); + self::assertInstanceOf(ServerRequestFactoryInterface::class, $server_request_factory); $uri = 'https://webtrees.test/index.php?' . http_build_query($query); @@ -119,7 +120,7 @@ class TestCase extends \PHPUnit\Framework\TestCase foreach ($attributes as $key => $value) { $request = $request->withAttribute($key, $value); - if ($key === 'tree') { + if ($key === 'tree' && $value instanceof Tree) { Registry::container()->set(Tree::class, $value); } } @@ -182,7 +183,9 @@ class TestCase extends \PHPUnit\Framework\TestCase $gedcom_import_service = new GedcomImportService(); $tree_service = new TreeService($gedcom_import_service); $tree = $tree_service->create(basename($gedcom_file), basename($gedcom_file)); - $stream = Registry::container()->get(StreamFactoryInterface::class)->createStreamFromFile(__DIR__ . '/data/' . $gedcom_file); + $stream_factory = Registry::container()->get(StreamFactoryInterface::class); + self::assertInstanceOf(StreamFactoryInterface::class, $stream_factory); + $stream = $stream_factory->createStreamFromFile(__DIR__ . '/data/' . $gedcom_file); $tree_service->importGedcomFile($tree, $stream, $gedcom_file, ''); @@ -204,11 +207,16 @@ class TestCase extends \PHPUnit\Framework\TestCase $stream_factory = Registry::container()->get(StreamFactoryInterface::class); $uploaded_file_factory = Registry::container()->get(UploadedFileFactoryInterface::class); + self::assertInstanceOf(StreamFactoryInterface::class, $stream_factory); + self::assertInstanceOf(UploadedFileFactoryInterface::class, $uploaded_file_factory); + $stream = $stream_factory->createStreamFromFile($filename); $size = filesize($filename); $status = UPLOAD_ERR_OK; $client_name = basename($filename); + $this->assertIsInt($size); + return $uploaded_file_factory->createUploadedFile($stream, $size, $status, $client_name, $mime_type); } @@ -250,14 +258,14 @@ class TestCase extends \PHPUnit\Framework\TestCase switch ($tag) { case 'html': - static::assertSame([], $stack); + self::assertSame([], $stack); break; case 'head': case 'body': - static::assertSame(['head'], $stack); + self::assertSame(['head'], $stack); break; case 'div': - static::assertNotContains('span', $stack, $message); + self::assertNotContains('span', $stack, $message); break; } @@ -266,7 +274,9 @@ class TestCase extends \PHPUnit\Framework\TestCase } if ($tag === 'script' && !$self_closing) { - $html = substr($html, strpos($html, '</script>')); + $offset = strpos($html, '</script>'); + self::assertIsInt($offset); + $html = substr($html, $offset); } else { $html = substr($html, strlen($match[0])); } @@ -276,13 +286,15 @@ class TestCase extends \PHPUnit\Framework\TestCase } } while ($html !== ''); - static::assertSame([], $stack); + self::assertSame([], $stack); } /** * Workaround for removal of withConsecutive in phpunit 10. * * @param array<int,mixed> $parameters + + * @return Callback */ protected static function withConsecutive(array $parameters): Callback { diff --git a/tests/app/Elements/XrefFamilyTest.php b/tests/app/Elements/XrefFamilyTest.php index 80486adf18..dd2866def2 100644 --- a/tests/app/Elements/XrefFamilyTest.php +++ b/tests/app/Elements/XrefFamilyTest.php @@ -58,8 +58,10 @@ class XrefFamilyTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEscape(): void diff --git a/tests/app/Elements/XrefIndividualTest.php b/tests/app/Elements/XrefIndividualTest.php index 96e2f26eba..8fb1bde548 100644 --- a/tests/app/Elements/XrefIndividualTest.php +++ b/tests/app/Elements/XrefIndividualTest.php @@ -58,8 +58,10 @@ class XrefIndividualTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEscape(): void diff --git a/tests/app/Elements/XrefLocationTest.php b/tests/app/Elements/XrefLocationTest.php index 2d351a774b..4d520dd22c 100644 --- a/tests/app/Elements/XrefLocationTest.php +++ b/tests/app/Elements/XrefLocationTest.php @@ -58,8 +58,10 @@ class XrefLocationTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEscape(): void diff --git a/tests/app/Elements/XrefMediaTest.php b/tests/app/Elements/XrefMediaTest.php index 0c424d34db..2b821a1420 100644 --- a/tests/app/Elements/XrefMediaTest.php +++ b/tests/app/Elements/XrefMediaTest.php @@ -58,8 +58,10 @@ class XrefMediaTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEscape(): void { diff --git a/tests/app/Elements/XrefNoteTest.php b/tests/app/Elements/XrefNoteTest.php index 15d0aadb95..d0b976e68b 100644 --- a/tests/app/Elements/XrefNoteTest.php +++ b/tests/app/Elements/XrefNoteTest.php @@ -53,8 +53,10 @@ class XrefNoteTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEscape(): void { diff --git a/tests/app/Elements/XrefRepositoryTest.php b/tests/app/Elements/XrefRepositoryTest.php index 36469aaea3..48af4607be 100644 --- a/tests/app/Elements/XrefRepositoryTest.php +++ b/tests/app/Elements/XrefRepositoryTest.php @@ -58,8 +58,10 @@ class XrefRepositoryTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEscape(): void { diff --git a/tests/app/Elements/XrefSharedNoteTest.php b/tests/app/Elements/XrefSharedNoteTest.php index ab83ed16e0..1aaec4ccc5 100644 --- a/tests/app/Elements/XrefSharedNoteTest.php +++ b/tests/app/Elements/XrefSharedNoteTest.php @@ -53,8 +53,10 @@ class XrefSharedNoteTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEscape(): void { diff --git a/tests/app/Elements/XrefSourceTest.php b/tests/app/Elements/XrefSourceTest.php index 794a9b4c7a..8bad1a7a04 100644 --- a/tests/app/Elements/XrefSourceTest.php +++ b/tests/app/Elements/XrefSourceTest.php @@ -60,8 +60,10 @@ class XrefSourceTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEditInlineSource(): void diff --git a/tests/app/Elements/XrefSubmissionTest.php b/tests/app/Elements/XrefSubmissionTest.php index d81b3199dd..7419c5dfb6 100644 --- a/tests/app/Elements/XrefSubmissionTest.php +++ b/tests/app/Elements/XrefSubmissionTest.php @@ -58,8 +58,10 @@ class XrefSubmissionTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEscape(): void { diff --git a/tests/app/Elements/XrefSubmitterTest.php b/tests/app/Elements/XrefSubmitterTest.php index 097740652b..b165d19d28 100644 --- a/tests/app/Elements/XrefSubmitterTest.php +++ b/tests/app/Elements/XrefSubmitterTest.php @@ -58,8 +58,10 @@ class XrefSubmitterTest extends TestCase $select_nodes = $dom->getElementsByTagName('select'); self::assertEquals(1, $select_nodes->count()); - $option_nodes = $select_nodes[0]->getElementsByTagName('option'); - self::assertEquals(1, $option_nodes->count()); + foreach ($select_nodes as $select_node) { + $option_nodes = $select_node->getElementsByTagName('option'); + self::assertEquals(1, $option_nodes->count()); + } } public function testEscape(): void { diff --git a/tests/app/Encodings/ASCIITest.php b/tests/app/Encodings/ASCIITest.php index 487936f4b4..af62f324c5 100644 --- a/tests/app/Encodings/ASCIITest.php +++ b/tests/app/Encodings/ASCIITest.php @@ -42,7 +42,7 @@ class ASCIITest extends TestCase $actual = $encoding->toUtf8($character); $expected = iconv(ASCII::NAME, UTF8::NAME, $character); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } foreach (range(128, 255) as $code_point) { @@ -50,7 +50,7 @@ class ASCIITest extends TestCase $actual = $encoding->toUtf8($character); $expected = UTF8::REPLACEMENT_CHARACTER; - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } } } diff --git a/tests/app/Encodings/AnselTest.php b/tests/app/Encodings/AnselTest.php index a9be6e4bc0..e4b4dc707e 100644 --- a/tests/app/Encodings/AnselTest.php +++ b/tests/app/Encodings/AnselTest.php @@ -142,9 +142,12 @@ class AnselTest extends TestCase foreach ($codes as $code) { $utf8 = UTF8::chr($code); $norm = Normalizer::normalize($utf8, Normalizer::FORM_D); + self::assertIsString($norm); if ($norm !== $utf8) { $chars = preg_split('//u', $norm, -1, PREG_SPLIT_NO_EMPTY); + self::assertIsArray($chars); + if (!ctype_alpha($chars[0])) { continue; } @@ -155,7 +158,7 @@ class AnselTest extends TestCase continue; } - static::assertSame($utf8, $encoding->toUtf8($encoding->fromUtf8($utf8)), 'U+' . dechex($code)); + self::assertSame($utf8, $encoding->toUtf8($encoding->fromUtf8($utf8)), 'U+' . dechex($code)); } } } diff --git a/tests/app/Encodings/CP437Test.php b/tests/app/Encodings/CP437Test.php index d96d9f8571..34fd8cc42f 100644 --- a/tests/app/Encodings/CP437Test.php +++ b/tests/app/Encodings/CP437Test.php @@ -43,7 +43,7 @@ class CP437Test extends TestCase $actual = $encoding->toUtf8($character); $expected = iconv(CP437::NAME, UTF8::NAME, $character); - static::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); + self::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); } } } diff --git a/tests/app/Encodings/CP850Test.php b/tests/app/Encodings/CP850Test.php index 774c45a08b..f6b5a52531 100644 --- a/tests/app/Encodings/CP850Test.php +++ b/tests/app/Encodings/CP850Test.php @@ -41,7 +41,7 @@ class CP850Test extends TestCase $actual = $encoding->toUtf8($character); $expected = iconv(CP850::NAME, UTF8::NAME, $character); - static::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); + self::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); } } } diff --git a/tests/app/Encodings/ISO88591Test.php b/tests/app/Encodings/ISO88591Test.php index dd2add9e1e..b3ea2596f3 100644 --- a/tests/app/Encodings/ISO88591Test.php +++ b/tests/app/Encodings/ISO88591Test.php @@ -48,7 +48,7 @@ class ISO88591Test extends TestCase $character = chr($code_point); $actual = $encoding->toUtf8($character); - static::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, dechex($code_point) . '=>' . $actual); + self::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, dechex($code_point) . '=>' . $actual); } foreach ($ranges as $range) { @@ -58,7 +58,7 @@ class ISO88591Test extends TestCase $expected = iconv(ISO88591::NAME, UTF8::NAME, $character); $expected = $expected === '' ? UTF8::REPLACEMENT_CHARACTER : $expected; - static::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); + self::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); } } } diff --git a/tests/app/Encodings/ISO88592Test.php b/tests/app/Encodings/ISO88592Test.php index ffc9884035..548c6f035c 100644 --- a/tests/app/Encodings/ISO88592Test.php +++ b/tests/app/Encodings/ISO88592Test.php @@ -48,7 +48,7 @@ class ISO88592Test extends TestCase $character = chr($code_point); $actual = $encoding->toUtf8($character); - static::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, dechex($code_point) . '=>' . $actual); + self::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, dechex($code_point) . '=>' . $actual); } foreach ($ranges as $range) { @@ -58,7 +58,7 @@ class ISO88592Test extends TestCase $expected = iconv(ISO88592::NAME, UTF8::NAME, $character); $expected = $expected === '' ? UTF8::REPLACEMENT_CHARACTER : $expected; - static::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); + self::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); } } } diff --git a/tests/app/Encodings/UTF16BETest.php b/tests/app/Encodings/UTF16BETest.php index 22343dc3fd..c636db15f3 100644 --- a/tests/app/Encodings/UTF16BETest.php +++ b/tests/app/Encodings/UTF16BETest.php @@ -44,14 +44,14 @@ class UTF16BETest extends TestCase $expected = iconv(UTF16BE::NAME, UTF8::NAME, $char); $actual = $encoding->toUtf8($char); - static::assertSame($expected, $actual, 'U+' . dechex($code)); + self::assertSame($expected, $actual, 'U+' . dechex($code)); } foreach (range(0x80, 0xFF) as $code) { $char = chr(intdiv($code, 256)) . chr($code % 256); $actual = $encoding->toUtf8($char); - static::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, 'U+' . dechex($code)); + self::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, 'U+' . dechex($code)); } foreach (range(0x100, 0xD7FF) as $code) { @@ -59,14 +59,14 @@ class UTF16BETest extends TestCase $expected = iconv(UTF16BE::NAME, UTF8::NAME, $char); $actual = $encoding->toUtf8($char); - static::assertSame($expected, $actual, 'U+' . dechex($code)); + self::assertSame($expected, $actual, 'U+' . dechex($code)); } foreach (range(0xD800, 0xDFFF) as $code) { $char = chr(intdiv($code, 256)) . chr($code % 256); $actual = $encoding->toUtf8($char); - static::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, 'U+' . dechex($code)); + self::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, 'U+' . dechex($code)); } foreach (range(0xE000, 0xFFFF) as $code) { @@ -74,7 +74,7 @@ class UTF16BETest extends TestCase $expected = iconv(UTF16BE::NAME, UTF8::NAME, $char); $actual = $encoding->toUtf8($char); - static::assertSame($expected, $actual, 'U+' . dechex($code)); + self::assertSame($expected, $actual, 'U+' . dechex($code)); } } } diff --git a/tests/app/Encodings/UTF16LETest.php b/tests/app/Encodings/UTF16LETest.php index 1516c9538b..815b4f6678 100644 --- a/tests/app/Encodings/UTF16LETest.php +++ b/tests/app/Encodings/UTF16LETest.php @@ -44,14 +44,14 @@ class UTF16LETest extends TestCase $expected = iconv(UTF16LE::NAME, UTF8::NAME, $char); $actual = $encoding->toUtf8($char); - static::assertSame($expected, $actual, 'U+' . dechex($code)); + self::assertSame($expected, $actual, 'U+' . dechex($code)); } foreach (range(0x80, 0xFF) as $code) { $char = chr($code % 256) . chr(intdiv($code, 256)); $actual = $encoding->toUtf8($char); - static::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, 'U+' . dechex($code)); + self::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, 'U+' . dechex($code)); } foreach (range(0x100, 0xD7FF) as $code) { @@ -59,14 +59,14 @@ class UTF16LETest extends TestCase $expected = iconv(UTF16LE::NAME, UTF8::NAME, $char); $actual = $encoding->toUtf8($char); - static::assertSame($expected, $actual, 'U+' . dechex($code)); + self::assertSame($expected, $actual, 'U+' . dechex($code)); } foreach (range(0xD800, 0xDFFF) as $code) { $char = chr($code % 256) . chr(intdiv($code, 256)); $actual = $encoding->toUtf8($char); - static::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, 'U+' . dechex($code)); + self::assertSame(UTF8::REPLACEMENT_CHARACTER, $actual, 'U+' . dechex($code)); } foreach (range(0xE000, 0xFFFF) as $code) { @@ -74,7 +74,7 @@ class UTF16LETest extends TestCase $expected = iconv(UTF16LE::NAME, UTF8::NAME, $char); $actual = $encoding->toUtf8($char); - static::assertSame($expected, $actual, 'U+' . dechex($code)); + self::assertSame($expected, $actual, 'U+' . dechex($code)); } } } diff --git a/tests/app/Encodings/Windows1250Test.php b/tests/app/Encodings/Windows1250Test.php index 51691db85f..6a9a117c83 100644 --- a/tests/app/Encodings/Windows1250Test.php +++ b/tests/app/Encodings/Windows1250Test.php @@ -44,7 +44,7 @@ class Windows1250Test extends TestCase $expected = iconv(Windows1250::NAME, 'UTF-8//IGNORE', $character); $expected = $expected === '' ? UTF8::REPLACEMENT_CHARACTER : $expected; - static::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); + self::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); } } } diff --git a/tests/app/Encodings/Windows1251Test.php b/tests/app/Encodings/Windows1251Test.php index 6e40c78116..443f563fe9 100644 --- a/tests/app/Encodings/Windows1251Test.php +++ b/tests/app/Encodings/Windows1251Test.php @@ -44,7 +44,7 @@ class Windows1251Test extends TestCase $expected = iconv(Windows1251::NAME, 'UTF-8//IGNORE', $character); $expected = $expected === '' ? UTF8::REPLACEMENT_CHARACTER : $expected; - static::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); + self::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); } } } diff --git a/tests/app/Encodings/Windows1252Test.php b/tests/app/Encodings/Windows1252Test.php index 9820162e43..bca462bda8 100644 --- a/tests/app/Encodings/Windows1252Test.php +++ b/tests/app/Encodings/Windows1252Test.php @@ -44,7 +44,7 @@ class Windows1252Test extends TestCase $expected = iconv(Windows1252::NAME, 'UTF-8//IGNORE', $character); $expected = $expected === '' ? UTF8::REPLACEMENT_CHARACTER : $expected; - static::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); + self::assertSame($expected, $actual, dechex($code_point) . '=>' . $actual . ' ' . $expected); } } } diff --git a/tests/app/Factories/CalendarDateFactoryTest.php b/tests/app/Factories/CalendarDateFactoryTest.php index 68c9e66872..212dbfc4fe 100644 --- a/tests/app/Factories/CalendarDateFactoryTest.php +++ b/tests/app/Factories/CalendarDateFactoryTest.php @@ -38,10 +38,10 @@ class CalendarDateFactoryTest extends TestCase $date = $factory->make(''); - static::assertSame(GregorianDate::ESCAPE, $date->format('%@')); - static::assertSame(0, $date->year); - static::assertSame(0, $date->month); - static::assertSame(0, $date->day); + self::assertSame(GregorianDate::ESCAPE, $date->format('%@')); + self::assertSame(0, $date->year); + self::assertSame(0, $date->month); + self::assertSame(0, $date->day); } public function testValidCalendarEscape(): void @@ -60,10 +60,10 @@ class CalendarDateFactoryTest extends TestCase foreach ($calendar_escapes as $calendar_escape) { $date = $factory->make($calendar_escape); - static::assertSame($calendar_escape, $date->format('%@')); - static::assertSame(0, $date->year); - static::assertSame(0, $date->month); - static::assertSame(0, $date->day); + self::assertSame($calendar_escape, $date->format('%@')); + self::assertSame(0, $date->year); + self::assertSame(0, $date->month); + self::assertSame(0, $date->day); } } @@ -72,10 +72,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('@#DSTARDATE@'); - static::assertSame('@#DGREGORIAN@', $date->format('%@')); - static::assertSame(0, $date->year); - static::assertSame(0, $date->month); - static::assertSame(0, $date->day); + self::assertSame('@#DGREGORIAN@', $date->format('%@')); + self::assertSame(0, $date->year); + self::assertSame(0, $date->month); + self::assertSame(0, $date->day); } public function testDayMonthAndYear(): void @@ -83,10 +83,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('01 JAN 1970'); - static::assertSame('@#DGREGORIAN@', $date->format('%@')); - static::assertSame(1970, $date->year); - static::assertSame(1, $date->month); - static::assertSame(1, $date->day); + self::assertSame('@#DGREGORIAN@', $date->format('%@')); + self::assertSame(1970, $date->year); + self::assertSame(1, $date->month); + self::assertSame(1, $date->day); } public function testMonthAndYear(): void @@ -94,10 +94,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('JAN 1970'); - static::assertSame('@#DGREGORIAN@', $date->format('%@')); - static::assertSame(1970, $date->year); - static::assertSame(1, $date->month); - static::assertSame(0, $date->day); + self::assertSame('@#DGREGORIAN@', $date->format('%@')); + self::assertSame(1970, $date->year); + self::assertSame(1, $date->month); + self::assertSame(0, $date->day); } public function testYear(): void @@ -105,10 +105,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('1970'); - static::assertSame('@#DGREGORIAN@', $date->format('%@')); - static::assertSame(1970, $date->year); - static::assertSame(0, $date->month); - static::assertSame(0, $date->day); + self::assertSame('@#DGREGORIAN@', $date->format('%@')); + self::assertSame(1970, $date->year); + self::assertSame(0, $date->month); + self::assertSame(0, $date->day); } public function testExtractedYear(): void @@ -116,10 +116,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('THE MID 1960S'); - static::assertSame('@#DGREGORIAN@', $date->format('%@')); - static::assertSame(1960, $date->year); - static::assertSame(0, $date->month); - static::assertSame(0, $date->day); + self::assertSame('@#DGREGORIAN@', $date->format('%@')); + self::assertSame(1960, $date->year); + self::assertSame(0, $date->month); + self::assertSame(0, $date->day); } public function testExtractedMonthAndYear(): void @@ -127,10 +127,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('PERHAPS FEB OR MAR IN 1960 or 1961'); - static::assertSame('@#DGREGORIAN@', $date->format('%@')); - static::assertSame(1960, $date->year); - static::assertSame(2, $date->month); - static::assertSame(0, $date->day); + self::assertSame('@#DGREGORIAN@', $date->format('%@')); + self::assertSame(1960, $date->year); + self::assertSame(2, $date->month); + self::assertSame(0, $date->day); } public function testExtractedDayMonthAndYear(): void @@ -138,10 +138,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('PERHAPS 11 OR 12 FEB OR MAR IN 1960 or 1961'); - static::assertSame('@#DGREGORIAN@', $date->format('%@')); - static::assertSame(1960, $date->year); - static::assertSame(2, $date->month); - static::assertSame(11, $date->day); + self::assertSame('@#DGREGORIAN@', $date->format('%@')); + self::assertSame(1960, $date->year); + self::assertSame(2, $date->month); + self::assertSame(11, $date->day); } public function testExtractedMonth(): void @@ -149,10 +149,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('PERHAPS FEB OR MAR'); - static::assertSame('@#DGREGORIAN@', $date->format('%@')); - static::assertSame(0, $date->year); - static::assertSame(2, $date->month); - static::assertSame(0, $date->day); + self::assertSame('@#DGREGORIAN@', $date->format('%@')); + self::assertSame(0, $date->year); + self::assertSame(2, $date->month); + self::assertSame(0, $date->day); } public function testExtractedDayAndMonth(): void @@ -160,10 +160,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('PERHAPS 11 OR 12 FEB OR MAR'); - static::assertSame('@#DGREGORIAN@', $date->format('%@')); - static::assertSame(0, $date->year); - static::assertSame(2, $date->month); - static::assertSame(11, $date->day); + self::assertSame('@#DGREGORIAN@', $date->format('%@')); + self::assertSame(0, $date->year); + self::assertSame(2, $date->month); + self::assertSame(11, $date->day); } public function testUnambiguousOverrideWithHebrewMonth(): void @@ -171,10 +171,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('@#DGREGORIAN@ 10 NSN 5432'); - static::assertSame('@#DHEBREW@', $date->format('%@')); - static::assertSame(5432, $date->year); - static::assertSame(8, $date->month); - static::assertSame(10, $date->day); + self::assertSame('@#DHEBREW@', $date->format('%@')); + self::assertSame(5432, $date->year); + self::assertSame(8, $date->month); + self::assertSame(10, $date->day); } public function testUnambiguousOverrideWithFrenchMonth(): void @@ -182,10 +182,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('@#DGREGORIAN@ 10 PLUV 11'); - static::assertSame('@#DFRENCH R@', $date->format('%@')); - static::assertSame(11, $date->year); - static::assertSame(5, $date->month); - static::assertSame(10, $date->day); + self::assertSame('@#DFRENCH R@', $date->format('%@')); + self::assertSame(11, $date->year); + self::assertSame(5, $date->month); + self::assertSame(10, $date->day); } public function testUnambiguousOverrideWithHijriMonth(): void @@ -193,10 +193,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('@#DGREGORIAN@ 10 SHAAB 1234'); - static::assertSame('@#DHIJRI@', $date->format('%@')); - static::assertSame(1234, $date->year); - static::assertSame(8, $date->month); - static::assertSame(10, $date->day); + self::assertSame('@#DHIJRI@', $date->format('%@')); + self::assertSame(1234, $date->year); + self::assertSame(8, $date->month); + self::assertSame(10, $date->day); } public function testUnambiguousOverrideWithJalaliMonth(): void @@ -204,10 +204,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('@#DGREGORIAN@ 10 BAHMA 1234'); - static::assertSame('@#DJALALI@', $date->format('%@')); - static::assertSame(1234, $date->year); - static::assertSame(11, $date->month); - static::assertSame(10, $date->day); + self::assertSame('@#DJALALI@', $date->format('%@')); + self::assertSame(1234, $date->year); + self::assertSame(11, $date->month); + self::assertSame(10, $date->day); } public function testUnambiguousOverrideWithJulianBCYear(): void @@ -215,10 +215,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('@#DGREGORIAN@ 10 AUG 44 B.C.'); - static::assertSame('@#DJULIAN@', $date->format('%@')); - static::assertSame(-44, $date->year); - static::assertSame(8, $date->month); - static::assertSame(10, $date->day); + self::assertSame('@#DJULIAN@', $date->format('%@')); + self::assertSame(-44, $date->year); + self::assertSame(8, $date->month); + self::assertSame(10, $date->day); } public function testUnambiguousYearWithNoCalendar(): void @@ -226,10 +226,10 @@ class CalendarDateFactoryTest extends TestCase $factory = new CalendarDateFactory(); $date = $factory->make('3456'); - static::assertSame('@#DHEBREW@', $date->format('%@')); - static::assertSame(3456, $date->year); - static::assertSame(0, $date->month); - static::assertSame(0, $date->day); + self::assertSame('@#DHEBREW@', $date->format('%@')); + self::assertSame(3456, $date->year); + self::assertSame(0, $date->month); + self::assertSame(0, $date->day); } public function testSupportedCalendars(): void @@ -238,6 +238,6 @@ class CalendarDateFactoryTest extends TestCase $calendars = $factory->supportedCalendars(); - static::assertNotEmpty($calendars); + self::assertNotEmpty($calendars); } } diff --git a/tests/app/Factories/EncodingFactoryTest.php b/tests/app/Factories/EncodingFactoryTest.php index f1b9b7340e..e487706282 100644 --- a/tests/app/Factories/EncodingFactoryTest.php +++ b/tests/app/Factories/EncodingFactoryTest.php @@ -42,17 +42,17 @@ class EncodingFactoryTest extends TestCase { $factory = new EncodingFactory(); - static::assertInstanceOf( + self::assertInstanceOf( UTF8::class, $factory->detect(UTF8::BYTE_ORDER_MARK) ); - static::assertInstanceOf( + self::assertInstanceOf( UTF16BE::class, $factory->detect(UTF16BE::BYTE_ORDER_MARK) ); - static::assertInstanceOf( + self::assertInstanceOf( UTF16LE::class, $factory->detect(UTF16LE::BYTE_ORDER_MARK) ); @@ -62,12 +62,12 @@ class EncodingFactoryTest extends TestCase { $factory = new EncodingFactory(); - static::assertInstanceOf( + self::assertInstanceOf( UTF16BE::class, $factory->detect("\x000") ); - static::assertInstanceOf( + self::assertInstanceOf( UTF16LE::class, $factory->detect("0\x00") ); @@ -77,7 +77,7 @@ class EncodingFactoryTest extends TestCase { $factory = new EncodingFactory(); - static::assertInstanceOf( + self::assertInstanceOf( MacRoman::class, $factory->detect("0 HEAD\n1 CHAR MACINTOSH\n0 TRLR") ); @@ -87,7 +87,7 @@ class EncodingFactoryTest extends TestCase { $factory = new EncodingFactory(); - static::assertInstanceOf( + self::assertInstanceOf( UTF8::class, $factory->detect("0 HEAD\n0 TRLR") ); @@ -97,17 +97,17 @@ class EncodingFactoryTest extends TestCase { $factory = new EncodingFactory(); - static::assertInstanceOf(UTF8::class, $factory->make(UTF8::NAME)); - static::assertInstanceOf(UTF16BE::class, $factory->make(UTF16BE::NAME)); - static::assertInstanceOf(UTF16LE::class, $factory->make(UTF16LE::NAME)); - static::assertInstanceOf(ANSEL::class, $factory->make(ANSEL::NAME)); - static::assertInstanceOf(ASCII::class, $factory->make(ASCII::NAME)); - static::assertInstanceOf(CP437::class, $factory->make(CP437::NAME)); - static::assertInstanceOf(CP850::class, $factory->make(CP850::NAME)); - static::assertInstanceOf(Windows1250::class, $factory->make(Windows1250::NAME)); - static::assertInstanceOf(Windows1251::class, $factory->make(Windows1251::NAME)); - static::assertInstanceOf(Windows1252::class, $factory->make(Windows1252::NAME)); - static::assertInstanceOf(MacRoman::class, $factory->make(MacRoman::NAME)); + self::assertInstanceOf(UTF8::class, $factory->make(UTF8::NAME)); + self::assertInstanceOf(UTF16BE::class, $factory->make(UTF16BE::NAME)); + self::assertInstanceOf(UTF16LE::class, $factory->make(UTF16LE::NAME)); + self::assertInstanceOf(ANSEL::class, $factory->make(ANSEL::NAME)); + self::assertInstanceOf(ASCII::class, $factory->make(ASCII::NAME)); + self::assertInstanceOf(CP437::class, $factory->make(CP437::NAME)); + self::assertInstanceOf(CP850::class, $factory->make(CP850::NAME)); + self::assertInstanceOf(Windows1250::class, $factory->make(Windows1250::NAME)); + self::assertInstanceOf(Windows1251::class, $factory->make(Windows1251::NAME)); + self::assertInstanceOf(Windows1252::class, $factory->make(Windows1252::NAME)); + self::assertInstanceOf(MacRoman::class, $factory->make(MacRoman::NAME)); $this->expectException(DomainException::class); $factory->make('Not the name of a valid encoding'); @@ -119,10 +119,10 @@ class EncodingFactoryTest extends TestCase $encodings = $factory->list(); - static::assertCount(13, $encodings); + self::assertCount(13, $encodings); foreach ($encodings as $key => $value) { - static::assertInstanceOf(EncodingInterface::class, $factory->make($key)); + self::assertInstanceOf(EncodingInterface::class, $factory->make($key)); } } } diff --git a/tests/app/Factories/MarkdownFactoryTest.php b/tests/app/Factories/MarkdownFactoryTest.php index 0f8fa74e3a..0ada6652f0 100644 --- a/tests/app/Factories/MarkdownFactoryTest.php +++ b/tests/app/Factories/MarkdownFactoryTest.php @@ -32,7 +32,7 @@ class MarkdownFactoryTest extends TestCase { $factory = new MarkdownFactory(); - static::assertSame( + self::assertSame( '<p>FOO <a href="https://example.com">https://example.com</a> BAR</p>', $factory->autolink('FOO https://example.com BAR') ); @@ -43,7 +43,7 @@ class MarkdownFactoryTest extends TestCase $factory = new MarkdownFactory(); $tree = $this->createMock(Tree::class); - static::assertSame( + self::assertSame( '<p>FOO <a href="https://example.com">https://example.com</a> BAR</p>', $factory->autolink('FOO https://example.com BAR', $tree) ); @@ -53,7 +53,7 @@ class MarkdownFactoryTest extends TestCase { $factory = new MarkdownFactory(); - static::assertSame( + self::assertSame( '<p><b> <a href="https://example.com">https://example.com</a> </b></p>', $factory->autolink('<b> https://example.com </b>') ); @@ -63,12 +63,12 @@ class MarkdownFactoryTest extends TestCase { $factory = new MarkdownFactory(); - static::assertSame( + self::assertSame( '<p>FOO https://example.com BAR</p>', $factory->markdown('FOO https://example.com BAR') ); - static::assertSame( + self::assertSame( '<p>FOO <a href="https://example.com">https://example.com</a> BAR</p>', $factory->markdown('FOO <https://example.com> BAR') ); @@ -79,12 +79,12 @@ class MarkdownFactoryTest extends TestCase $tree = $this->createMock(Tree::class); $factory = new MarkdownFactory(); - static::assertSame( + self::assertSame( '<p>FOO https://example.com BAR</p>', $factory->markdown('FOO https://example.com BAR', $tree) ); - static::assertSame( + self::assertSame( '<p>FOO <a href="https://example.com">https://example.com</a> BAR</p>', $factory->markdown('FOO <https://example.com> BAR', $tree) ); @@ -94,7 +94,7 @@ class MarkdownFactoryTest extends TestCase { $factory = new MarkdownFactory(); - static::assertSame( + self::assertSame( '<p><b> <a href="https://example.com">https://example.com</a> </b></p>', $factory->markdown('<b> <https://example.com> </b>') ); @@ -104,12 +104,12 @@ class MarkdownFactoryTest extends TestCase { $factory = new MarkdownFactory(); - static::assertSame( + self::assertSame( '<p>alpha<br />beta<br />gamma<br />delta</p>', $factory->autolink("alpha\nbeta\ngamma \ndelta") ); - static::assertSame( + self::assertSame( '<p>alpha<br />beta<br />gamma<br />delta</p>', $factory->markdown("alpha\nbeta\ngamma \ndelta") ); @@ -119,12 +119,12 @@ class MarkdownFactoryTest extends TestCase { $factory = new MarkdownFactory(); - static::assertSame( + self::assertSame( '<p>alpha<br />beta</p><p>gamma<br />delta</p>', $factory->autolink("alpha\nbeta\n\n\n\ngamma\ndelta") ); - static::assertSame( + self::assertSame( '<p>alpha<br />beta</p><p>gamma<br />delta</p>', $factory->markdown("alpha\nbeta\n\n\n\ngamma\ndelta") ); diff --git a/tests/app/Factories/RouteFactoryTest.php b/tests/app/Factories/RouteFactoryTest.php index a1897412f6..3bbe618375 100644 --- a/tests/app/Factories/RouteFactoryTest.php +++ b/tests/app/Factories/RouteFactoryTest.php @@ -34,7 +34,7 @@ class RouteFactoryTest extends TestCase $url = $route_factory->route(HomePage::class, ['foo' => null, 'bar' => '']); - static::assertStringNotContainsString('foo=', $url); - static::assertStringContainsString('bar=', $url); + self::assertStringNotContainsString('foo=', $url); + self::assertStringContainsString('bar=', $url); } } diff --git a/tests/app/Http/Middleware/CheckCsrfTest.php b/tests/app/Http/Middleware/CheckCsrfTest.php index 7fafbb5609..429dd47249 100644 --- a/tests/app/Http/Middleware/CheckCsrfTest.php +++ b/tests/app/Http/Middleware/CheckCsrfTest.php @@ -37,8 +37,11 @@ class CheckCsrfTest extends TestCase $handler = $this->createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response()); + $uri_factory = Registry::container()->get(UriFactoryInterface::class); + self::assertInstanceOf(UriFactoryInterface::class, $uri_factory); + $request = self::createRequest(RequestMethodInterface::METHOD_POST) - ->withUri(Registry::container()->get(UriFactoryInterface::class)->createUri('https://example.com')); + ->withUri($uri_factory->createUri('https://example.com')); $middleware = new CheckCsrf(); $response = $middleware->process($request, $handler); diff --git a/tests/app/Http/RequestHandlers/FixLevel0MediaActionTest.php b/tests/app/Http/RequestHandlers/FixLevel0MediaActionTest.php index a193ed82dd..120df9fda6 100644 --- a/tests/app/Http/RequestHandlers/FixLevel0MediaActionTest.php +++ b/tests/app/Http/RequestHandlers/FixLevel0MediaActionTest.php @@ -38,7 +38,7 @@ class FixLevel0MediaActionTest extends TestCase $tree = $tree_service->create('name', 'title'); $handler = new FixLevel0MediaAction($tree_service); $request = self::createRequest(RequestMethodInterface::METHOD_POST, [], [ - 'tree_id' => $tree->id(), + 'tree_id' => (string) $tree->id(), 'fact_id' => '', 'indi_xref' => 'X1', 'obje_xref' => 'X2', diff --git a/tests/app/Http/RequestHandlers/FixLevel0MediaDataTest.php b/tests/app/Http/RequestHandlers/FixLevel0MediaDataTest.php index 899f81d79f..75025ee9d1 100644 --- a/tests/app/Http/RequestHandlers/FixLevel0MediaDataTest.php +++ b/tests/app/Http/RequestHandlers/FixLevel0MediaDataTest.php @@ -39,7 +39,9 @@ class FixLevel0MediaDataTest extends TestCase $tree_service = new TreeService($gedcom_import_service); $tree = $tree_service->create('name', 'title'); $handler = new FixLevel0MediaData($datatables_service, $tree_service); - $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['tree_id' => $tree->id()]); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, [ + 'tree_id' => (string) $tree->id(), + ]); $response = $handler->handle($request); self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); diff --git a/tests/app/Http/RequestHandlers/ManageMediaDataTest.php b/tests/app/Http/RequestHandlers/ManageMediaDataTest.php index faa287c247..a0b62c2a6d 100644 --- a/tests/app/Http/RequestHandlers/ManageMediaDataTest.php +++ b/tests/app/Http/RequestHandlers/ManageMediaDataTest.php @@ -93,8 +93,8 @@ class ManageMediaDataTest extends TestCase 'media_folder' => 'media/', 'subfolders' => 'include', 'search' => ['value' => ''], - 'start' => '0', - 'length' => '10', + 'start' => '0', + 'length' => '10', ]); $response = $handler->handle($request); diff --git a/tests/app/Http/RequestHandlers/SiteLogsDeleteTest.php b/tests/app/Http/RequestHandlers/SiteLogsDeleteTest.php index 29b7403113..27066c55ee 100644 --- a/tests/app/Http/RequestHandlers/SiteLogsDeleteTest.php +++ b/tests/app/Http/RequestHandlers/SiteLogsDeleteTest.php @@ -41,6 +41,6 @@ class SiteLogsDeleteTest extends TestCase $handler = new SiteLogsDelete($site_logs_service); $response = $handler->handle($request); - static::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); } } diff --git a/tests/app/Http/RequestHandlers/SiteLogsDownloadTest.php b/tests/app/Http/RequestHandlers/SiteLogsDownloadTest.php index e167bfa344..b2ccf04ca0 100644 --- a/tests/app/Http/RequestHandlers/SiteLogsDownloadTest.php +++ b/tests/app/Http/RequestHandlers/SiteLogsDownloadTest.php @@ -48,8 +48,8 @@ class SiteLogsDownloadTest extends TestCase $handler = new SiteLogsDownload($site_logs_service); $response = $handler->handle($request); - static::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); - static::assertSame('text/csv; charset=UTF-8', $response->getHeaderLine('content-type')); - static::assertSame('attachment; filename="webtrees-logs.csv"', $response->getHeaderLine('content-disposition')); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame('text/csv; charset=UTF-8', $response->getHeaderLine('content-type')); + self::assertSame('attachment; filename="webtrees-logs.csv"', $response->getHeaderLine('content-disposition')); } } diff --git a/tests/app/Http/RequestHandlers/SiteLogsPageTest.php b/tests/app/Http/RequestHandlers/SiteLogsPageTest.php index 62c2974c41..9af30dab2a 100644 --- a/tests/app/Http/RequestHandlers/SiteLogsPageTest.php +++ b/tests/app/Http/RequestHandlers/SiteLogsPageTest.php @@ -44,6 +44,6 @@ class SiteLogsPageTest extends TestCase $handler = new SiteLogsPage($tree_service, $user_service); $response = $handler->handle($request); - static::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } } diff --git a/tests/app/Http/RequestHandlers/UserEditActionTest.php b/tests/app/Http/RequestHandlers/UserEditActionTest.php index c8ef023f33..76aa921d3b 100644 --- a/tests/app/Http/RequestHandlers/UserEditActionTest.php +++ b/tests/app/Http/RequestHandlers/UserEditActionTest.php @@ -41,7 +41,7 @@ class UserEditActionTest extends TestCase $user = $user_service->create('user', 'real', 'email', 'pass'); $handler = new UserEditAction($mail_service, $tree_service, $user_service); $request = self::createRequest(RequestMethodInterface::METHOD_POST, [], [ - 'user_id' => $user->id(), + 'user_id' => (string) $user->id(), 'username' => '', 'real_name' => '', 'email' => '', diff --git a/tests/app/Module/MapLinkBingTest.php b/tests/app/Module/MapLinkBingTest.php index ec2720a1dd..cfe9f3b86d 100644 --- a/tests/app/Module/MapLinkBingTest.php +++ b/tests/app/Module/MapLinkBingTest.php @@ -40,7 +40,7 @@ class MapLinkBingTest extends TestCase $html = $module->mapLink($fact); - static::assertSame('', $html); + self::assertSame('', $html); } /** diff --git a/tests/app/Module/MapLinkGoogleTest.php b/tests/app/Module/MapLinkGoogleTest.php index 594c2bb5d5..c379c43009 100644 --- a/tests/app/Module/MapLinkGoogleTest.php +++ b/tests/app/Module/MapLinkGoogleTest.php @@ -40,7 +40,7 @@ class MapLinkGoogleTest extends TestCase $html = $module->mapLink($fact); - static::assertSame('', $html); + self::assertSame('', $html); } public function testLink(): void diff --git a/tests/app/Module/MapLinkOpenStreetMapTest.php b/tests/app/Module/MapLinkOpenStreetMapTest.php index 48f4d1853f..59eda39985 100644 --- a/tests/app/Module/MapLinkOpenStreetMapTest.php +++ b/tests/app/Module/MapLinkOpenStreetMapTest.php @@ -40,7 +40,7 @@ class MapLinkOpenStreetMapTest extends TestCase $html = $module->mapLink($fact); - static::assertSame('', $html); + self::assertSame('', $html); } public function testLink(): void diff --git a/tests/app/Reports/RightToLeftSupportTest.php b/tests/app/Reports/RightToLeftSupportTest.php index d0fa7ed0f1..4f6bd176e0 100644 --- a/tests/app/Reports/RightToLeftSupportTest.php +++ b/tests/app/Reports/RightToLeftSupportTest.php @@ -34,13 +34,13 @@ class RightToLeftSupportTest extends TestCase public function testEmptyString(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '', RightToLeftSupport::spanLtrRtl('') ); I18N::init('he', true); - static::assertSame( + self::assertSame( '', RightToLeftSupport::spanLtrRtl('') ); @@ -49,77 +49,77 @@ class RightToLeftSupportTest extends TestCase public function testStripControlCharacters(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl('foo‎bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl('foo‏bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\x8Ebar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\x8Fbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xADbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xAEbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xAAbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xABbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xACbar") ); I18N::init('he', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl('foo‎bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl('foo‏bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\x8Ebar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\x8Fbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xADbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xAEbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xAAbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xABbar") ); - static::assertSame( + self::assertSame( '<span dir="ltr">foobar</span>', RightToLeftSupport::spanLtrRtl("foo\xE2\x80\xACbar") ); @@ -128,21 +128,21 @@ class RightToLeftSupportTest extends TestCase public function testNewLinesBecomeHTMLBreaks(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo</span><br><span dir="ltr">bar</span>', RightToLeftSupport::spanLtrRtl("foo\nbar") ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג</span><br><span dir="rtl">דהו</span>', RightToLeftSupport::spanLtrRtl("אבג\nדהו") ); I18N::init('he', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo</span><br><span dir="ltr">bar</span>', RightToLeftSupport::spanLtrRtl("foo\nbar") ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג</span><br><span dir="rtl">דהו</span>', RightToLeftSupport::spanLtrRtl("אבג\nדהו") ); @@ -151,21 +151,21 @@ class RightToLeftSupportTest extends TestCase public function testLineBreaks(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo</span><br><span dir="ltr">bar</span>', RightToLeftSupport::spanLtrRtl('foo<br>bar') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג</span><br><span dir="rtl">דהו</span>', RightToLeftSupport::spanLtrRtl('אבג<br>דהו') ); I18N::init('he', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo</span><br><span dir="ltr">bar</span>', RightToLeftSupport::spanLtrRtl('foo<br>bar') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג</span><br><span dir="rtl">דהו</span>', RightToLeftSupport::spanLtrRtl('אבג<br>דהו') ); @@ -174,29 +174,29 @@ class RightToLeftSupportTest extends TestCase public function testHtmlEntities(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo bar</span>', RightToLeftSupport::spanLtrRtl('foo bar') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג דהו</span>', RightToLeftSupport::spanLtrRtl('אבג דהו') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo&bar</span>', RightToLeftSupport::spanLtrRtl('foo&bar') ); I18N::init('he', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo bar</span>', RightToLeftSupport::spanLtrRtl('foo bar') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג דהו</span>', RightToLeftSupport::spanLtrRtl('אבג דהו') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo&bar</span>', RightToLeftSupport::spanLtrRtl('foo&bar') ); @@ -205,29 +205,29 @@ class RightToLeftSupportTest extends TestCase public function testBraces(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo{{123}}bar</span>', RightToLeftSupport::spanLtrRtl('foo{{123}}bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo{{bar</span>', RightToLeftSupport::spanLtrRtl('foo{{bar') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג{{123}}דהו</span>', RightToLeftSupport::spanLtrRtl('אבג{{123}}דהו') ); I18N::init('he', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo{{123}}bar</span>', RightToLeftSupport::spanLtrRtl('foo{{123}}bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo{{bar</span>', RightToLeftSupport::spanLtrRtl('foo{{bar') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג{{123}}דהו</span>', RightToLeftSupport::spanLtrRtl('אבג{{123}}דהו') ); @@ -236,53 +236,53 @@ class RightToLeftSupportTest extends TestCase public function testNumbers(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo 123,456.789 bar</span>', RightToLeftSupport::spanLtrRtl('foo 123,456.789 bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo +123,456.789 bar</span>', RightToLeftSupport::spanLtrRtl('foo +123,456.789 bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo -123,456.789 bar</span>', RightToLeftSupport::spanLtrRtl('foo -123,456.789 bar') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג 123,456.789 דהו</span>', RightToLeftSupport::spanLtrRtl('אבג 123,456.789 דהו') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג +123,456.789 דהו</span>', RightToLeftSupport::spanLtrRtl('אבג +123,456.789 דהו') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג -123,456.789 דהו</span>', RightToLeftSupport::spanLtrRtl('אבג -123,456.789 דהו') ); I18N::init('he', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo 123,456.789 bar</span>', RightToLeftSupport::spanLtrRtl('foo 123,456.789 bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo +123,456.789 bar</span>', RightToLeftSupport::spanLtrRtl('foo +123,456.789 bar') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo -123,456.789 bar</span>', RightToLeftSupport::spanLtrRtl('foo -123,456.789 bar') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג 123,456.789 דהו</span>', RightToLeftSupport::spanLtrRtl('אבג 123,456.789 דהו') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג +123,456.789 דהו</span>', RightToLeftSupport::spanLtrRtl('אבג +123,456.789 דהו') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג -123,456.789 דהו</span>', RightToLeftSupport::spanLtrRtl('אבג -123,456.789 דהו') ); @@ -291,37 +291,37 @@ class RightToLeftSupportTest extends TestCase public function testParentheses(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo (bar)</span>', RightToLeftSupport::spanLtrRtl('foo (bar)') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo </span><span dir="rtl">(אבג)</span>', RightToLeftSupport::spanLtrRtl('foo (אבג)') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג</span><span dir="ltr"> (bar)</span>', RightToLeftSupport::spanLtrRtl('אבג (bar)') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג (דהו)</span>', RightToLeftSupport::spanLtrRtl('אבג (דהו)') ); I18N::init('he', true); - static::assertSame( + self::assertSame( '<span dir="ltr">foo (bar)</span>', RightToLeftSupport::spanLtrRtl('foo (bar)') ); - static::assertSame( + self::assertSame( '<span dir="ltr">foo </span><span dir="rtl">(אבג)</span>', RightToLeftSupport::spanLtrRtl('foo (אבג)') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג </span><span dir="ltr">(bar)</span>', RightToLeftSupport::spanLtrRtl('אבג (bar)') ); - static::assertSame( + self::assertSame( '<span dir="rtl">אבג (דהו)</span>', RightToLeftSupport::spanLtrRtl('אבג (דהו)') ); @@ -330,21 +330,21 @@ class RightToLeftSupportTest extends TestCase public function testUnescapedHtml(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '<span dir="ltr">>foo<</span>', RightToLeftSupport::spanLtrRtl('>foo<') ); - static::assertSame( + self::assertSame( '<span dir="ltr">></span><span dir="rtl">אבג<</span>', RightToLeftSupport::spanLtrRtl('>אבג<') ); I18N::init('he', true); - static::assertSame( + self::assertSame( '<span dir="rtl">></span><span dir="ltr">foo<</span>', RightToLeftSupport::spanLtrRtl('>foo<') ); - static::assertSame( + self::assertSame( '<span dir="rtl">>אבג<</span>', RightToLeftSupport::spanLtrRtl('>אבג<') ); @@ -353,13 +353,13 @@ class RightToLeftSupportTest extends TestCase public function testBreakInNumber(): void { I18N::init('en-US', true); - static::assertSame( + self::assertSame( '<span dir="ltr">123</span><br><span dir="ltr">456</span>', RightToLeftSupport::spanLtrRtl('123<br>456') ); I18N::init('he', true); - static::assertSame( + self::assertSame( '<span dir="rtl">123</span><br><span dir="rtl">456</span>', RightToLeftSupport::spanLtrRtl('123<br>456') ); diff --git a/tests/app/Services/GedcomEditServiceTest.php b/tests/app/Services/GedcomEditServiceTest.php index 979d1d7fa6..cc23fb4061 100644 --- a/tests/app/Services/GedcomEditServiceTest.php +++ b/tests/app/Services/GedcomEditServiceTest.php @@ -19,6 +19,8 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Services; +use Fisharebest\Webtrees\Fact; +use Fisharebest\Webtrees\Http\RequestHandlers\FixLevel0MediaDataTest; use Fisharebest\Webtrees\TestCase; use Fisharebest\Webtrees\Tree; use PHPUnit\Framework\Attributes\CoversClass; @@ -33,7 +35,7 @@ class GedcomEditServiceTest extends TestCase { $gedcom_edit_service = new GedcomEditService(); - static::assertSame( + self::assertSame( '1 BIRT Y', $gedcom_edit_service->editLinesToGedcom( 'INDI', @@ -44,7 +46,7 @@ class GedcomEditServiceTest extends TestCase ) ); - static::assertSame( + self::assertSame( "\n1 BIRT Y\n2 ADDR England", $gedcom_edit_service->editLinesToGedcom( 'INDI', @@ -54,7 +56,7 @@ class GedcomEditServiceTest extends TestCase ) ); - static::assertSame( + self::assertSame( "\n1 BIRT\n2 PLAC England", $gedcom_edit_service->editLinesToGedcom( 'INDI', @@ -64,7 +66,7 @@ class GedcomEditServiceTest extends TestCase ) ); - static::assertSame( + self::assertSame( "\n1 BIRT\n2 PLAC England\n2 SOUR @S1@\n3 PAGE 123", $gedcom_edit_service->editLinesToGedcom( 'INDI', @@ -75,7 +77,7 @@ class GedcomEditServiceTest extends TestCase ); // Missing SOUR, so ignore PAGE - static::assertSame( + self::assertSame( "\n1 BIRT\n2 PLAC England", $gedcom_edit_service->editLinesToGedcom( 'INDI', @@ -85,7 +87,7 @@ class GedcomEditServiceTest extends TestCase ) ); - static::assertSame( + self::assertSame( "\n1 BIRT\n2 PLAC England", $gedcom_edit_service->editLinesToGedcom( 'INDI', @@ -95,7 +97,7 @@ class GedcomEditServiceTest extends TestCase ) ); - static::assertSame( + self::assertSame( "\n1 BIRT\n2 PLAC England\n1 DEAT\n2 PLAC Scotland", $gedcom_edit_service->editLinesToGedcom( 'INDI', @@ -122,6 +124,7 @@ class GedcomEditServiceTest extends TestCase self::assertSameSize($expected_new_facts, $new_facts); for ($i = 0; $i < count($expected_new_facts); $i++) { $new_fact = $new_facts->get($i); + self::assertInstanceOf(Fact::class, $new_fact); self::assertSame($expected_new_facts[$i], $new_fact->tag()); } } @@ -146,6 +149,7 @@ class GedcomEditServiceTest extends TestCase self::assertSameSize($expected_new_facts, $new_facts); for ($i = 0; $i < count($expected_new_facts); $i++) { $new_fact = $new_facts->get($i); + self::assertInstanceOf(Fact::class, $new_fact); self::assertSame($expected_new_facts[$i], $new_fact->tag()); } } diff --git a/tests/app/Services/RateLimitServiceTest.php b/tests/app/Services/RateLimitServiceTest.php index ee73cf78e6..275f70a016 100644 --- a/tests/app/Services/RateLimitServiceTest.php +++ b/tests/app/Services/RateLimitServiceTest.php @@ -52,15 +52,15 @@ class RateLimitServiceTest extends TestCase $rate_limit_service->limitRateForUser($user, 3, 30, 'rate-limit'); $history = $user->getPreference('rate-limit'); - static::assertCount(1, explode(',', $history)); + self::assertCount(1, explode(',', $history)); $rate_limit_service->limitRateForUser($user, 3, 30, 'rate-limit'); $history = $user->getPreference('rate-limit'); - static::assertCount(2, explode(',', $history)); + self::assertCount(2, explode(',', $history)); $rate_limit_service->limitRateForUser($user, 3, 30, 'rate-limit'); $history = $user->getPreference('rate-limit'); - static::assertCount(3, explode(',', $history)); + self::assertCount(3, explode(',', $history)); } public function testOldEventsIgnored(): void @@ -74,7 +74,7 @@ class RateLimitServiceTest extends TestCase $rate_limit_service->limitRateForUser($user, 5, 30, 'rate-limit'); $history = $user->getPreference('rate-limit'); - static::assertCount(6, explode(',', $history)); + self::assertCount(6, explode(',', $history)); } public function testLimitReached(): void diff --git a/tests/app/Services/UserServiceTest.php b/tests/app/Services/UserServiceTest.php index 7b4b44547a..5fe7b3a30c 100644 --- a/tests/app/Services/UserServiceTest.php +++ b/tests/app/Services/UserServiceTest.php @@ -74,6 +74,7 @@ class UserServiceTest extends TestCase $user_service = new UserService(); $user1 = $user_service->create('user', 'User', 'user@example.com', 'secret'); $user2 = $user_service->find($user1->id()); + self::assertInstanceOf(UserInterface::class, $user2); self::assertSame($user1->id(), $user2->id()); } @@ -83,6 +84,7 @@ class UserServiceTest extends TestCase $user_service = new UserService(); $user1 = $user_service->create('user', 'User', 'user@example.com', 'secret'); $user2 = $user_service->findByEmail($user1->email()); + self::assertInstanceOf(UserInterface::class, $user2); self::assertSame($user1->id(), $user2->id()); } @@ -92,6 +94,7 @@ class UserServiceTest extends TestCase $user_service = new UserService(); $user1 = $user_service->create('user', 'User', 'user@example.com', 'secret'); $user2 = $user_service->findByUserName($user1->userName()); + self::assertInstanceOf(UserInterface::class, $user2); self::assertSame($user1->id(), $user2->id()); } @@ -102,6 +105,8 @@ class UserServiceTest extends TestCase $user1 = $user_service->create('user', 'User', 'user@example.com', 'secret'); $user2 = $user_service->findByIdentifier($user1->userName()); $user3 = $user_service->findByIdentifier($user1->email()); + self::assertInstanceOf(UserInterface::class, $user2); + self::assertInstanceOf(UserInterface::class, $user3); self::assertSame($user1->id(), $user2->id()); self::assertSame($user1->id(), $user3->id()); diff --git a/tests/app/TimestampTest.php b/tests/app/TimestampTest.php index 9b7332e618..b896c0a1f7 100644 --- a/tests/app/TimestampTest.php +++ b/tests/app/TimestampTest.php @@ -29,7 +29,9 @@ class TimestampTest extends TestCase { public function testJulianDay(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame(2460296, gregoriantojd(12, 17, 2023)); self::assertSame(2460296, $timestamp->julianDay()); @@ -58,7 +60,9 @@ class TimestampTest extends TestCase public function testFormat(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('17', $timestamp->format('d')); self::assertSame('Sun', $timestamp->format('D')); @@ -101,7 +105,9 @@ class TimestampTest extends TestCase public function testIsoFormat(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('12/17/2023', $timestamp->isoFormat('l')); self::assertSame('Dec 17, 2023', $timestamp->isoFormat('ll')); @@ -116,15 +122,22 @@ class TimestampTest extends TestCase public function testToDateTimeString(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); } public function testCompare(): void { - $timestamp1 = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); - $timestamp2 = new Timestamp(mktime(16, 21, 20, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp1 = new Timestamp($time, 'UTC', 'en-US'); + + $time = mktime(16, 21, 20, 12, 17, 2023); + self::assertIsInt($time); + $timestamp2 = new Timestamp($time, 'UTC', 'en-US'); self::assertSame(-1, $timestamp1->compare($timestamp2)); self::assertSame(0, $timestamp1->compare($timestamp1)); @@ -133,7 +146,9 @@ class TimestampTest extends TestCase public function testAddSeconds(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2023-12-17 16:21:20', $timestamp->addSeconds(1)->toDateTimeString()); @@ -142,7 +157,9 @@ class TimestampTest extends TestCase public function testAddMinutes(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2023-12-17 16:22:19', $timestamp->addMinutes(1)->toDateTimeString()); @@ -151,7 +168,9 @@ class TimestampTest extends TestCase public function testAddHours(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2023-12-17 17:21:19', $timestamp->addHours(1)->toDateTimeString()); @@ -160,7 +179,9 @@ class TimestampTest extends TestCase public function testAddDays(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2023-12-18 16:21:19', $timestamp->addDays(1)->toDateTimeString()); @@ -168,7 +189,9 @@ class TimestampTest extends TestCase public function testAddMonths(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2024-01-17 16:21:19', $timestamp->addMonths(1)->toDateTimeString()); @@ -176,7 +199,9 @@ class TimestampTest extends TestCase public function testAddYears(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2024-12-17 16:21:19', $timestamp->addYears(1)->toDateTimeString()); @@ -184,7 +209,9 @@ class TimestampTest extends TestCase public function testSubtractSeconds(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2023-12-17 16:21:18', $timestamp->subtractSeconds(1)->toDateTimeString()); @@ -193,7 +220,9 @@ class TimestampTest extends TestCase public function testSubtractMinutes(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2023-12-17 16:20:19', $timestamp->subtractMinutes(1)->toDateTimeString()); @@ -202,7 +231,9 @@ class TimestampTest extends TestCase public function testSubtractHours(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2023-12-17 15:21:19', $timestamp->subtractHours(1)->toDateTimeString()); @@ -211,7 +242,9 @@ class TimestampTest extends TestCase public function testSubtractDays(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2023-12-16 16:21:19', $timestamp->subtractDays(1)->toDateTimeString()); @@ -220,7 +253,9 @@ class TimestampTest extends TestCase public function testSubtractMonths(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2023-11-17 16:21:19', $timestamp->subtractMonths(1)->toDateTimeString()); @@ -229,7 +264,9 @@ class TimestampTest extends TestCase public function testSubtractYears(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame('2023-12-17 16:21:19', $timestamp->toDateTimeString()); self::assertSame('2022-12-17 16:21:19', $timestamp->subtractYears(1)->toDateTimeString()); @@ -238,7 +275,9 @@ class TimestampTest extends TestCase public function testTimestamp(): void { - $timestamp = new Timestamp(mktime(16, 21, 19, 12, 17, 2023), 'UTC', 'en-US'); + $time = mktime(16, 21, 19, 12, 17, 2023); + self::assertIsInt($time); + $timestamp = new Timestamp($time, 'UTC', 'en-US'); self::assertSame(1702830079, $timestamp->timestamp()); } diff --git a/tests/app/TreeTest.php b/tests/app/TreeTest.php index ad02f5586c..3a55b8e63d 100644 --- a/tests/app/TreeTest.php +++ b/tests/app/TreeTest.php @@ -300,15 +300,23 @@ class TreeTest extends TestCase $resource = $gedcom_export_service->export($tree, true); $original = file_get_contents(__DIR__ . '/../data/demo.ged'); $export = stream_get_contents($resource); + self::assertIsString($original); + self::assertIsString($export); fclose($resource); // The version, date and time in the HEAD record will be different. $original = preg_replace('/\n2 VERS .*/', '', $original, 1); $export = preg_replace('/\n2 VERS .*/', '', $export, 1); + self::assertIsString($original); + self::assertIsString($export); $original = preg_replace('/\n1 DATE .. ... ..../', '', $original, 1); $export = preg_replace('/\n1 DATE .. ... ..../', '', $export, 1); + self::assertIsString($original); + self::assertIsString($export); $original = preg_replace('/\n2 TIME ..:..:../', '', $original, 1); $export = preg_replace('/\n2 TIME ..:..:../', '', $export, 1); + self::assertIsString($original); + self::assertIsString($export); self::assertSame($original, $export); } diff --git a/tests/feature/IndividualListTest.php b/tests/feature/IndividualListTest.php index dc1865d5fa..5e970c7572 100644 --- a/tests/feature/IndividualListTest.php +++ b/tests/feature/IndividualListTest.php @@ -53,7 +53,9 @@ class IndividualListTest extends TestCase $this->user->setPreference(UserInterface::PREF_AUTO_ACCEPT_EDITS, '1'); Auth::login($this->user); // The default "John Doe" individual will confuse the test results... - Registry::individualFactory()->make('X1', $this->tree)->deleteRecord(); + $john_doe = Registry::individualFactory()->make('X1', $this->tree); + $this->assertInstanceOf(Individual::class, $john_doe); + $john_doe->deleteRecord(); } public function testCollationOfInitials(): void |
