From a2724082caa6d3d476bed70dd41af09153ab0b8e Mon Sep 17 00:00:00 2001 From: luchaos Date: Mon, 6 Jun 2022 22:42:26 +0200 Subject: [PATCH] Add directory separator agnostic assertPathEquals() to tests (#1021) --- .gitignore | 1 - tests/src/ShortcodeTest.php | 1 - tests/src/TestCase.php | 13 +++++++++++++ tests/src/Util/PathTest.php | 7 ++++--- tests/src/Util/StringTest.php | 2 +- tests/src/Util/UrlTest.php | 2 +- 6 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 tests/src/TestCase.php diff --git a/.gitignore b/.gitignore index 816282f9de..4b3da546c1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ nbproject .php_cs.cache .php-cs-fixer.cache .phpunit.result.cache -test*.php /public/Badge /public/Images diff --git a/tests/src/ShortcodeTest.php b/tests/src/ShortcodeTest.php index b6749947b1..8989d82197 100644 --- a/tests/src/ShortcodeTest.php +++ b/tests/src/ShortcodeTest.php @@ -2,7 +2,6 @@ namespace Test; -use PHPUnit\Framework\TestCase; use RA\Shortcode; final class ShortcodeTest extends TestCase diff --git a/tests/src/TestCase.php b/tests/src/TestCase.php new file mode 100644 index 0000000000..a0e0edcd23 --- /dev/null +++ b/tests/src/TestCase.php @@ -0,0 +1,13 @@ +assertEquals(str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $expected), $actual, $message); + } +} diff --git a/tests/src/Util/PathTest.php b/tests/src/Util/PathTest.php index d7c29ae222..4acb023a0b 100644 --- a/tests/src/Util/PathTest.php +++ b/tests/src/Util/PathTest.php @@ -4,14 +4,15 @@ namespace Test\Util; -use PHPUnit\Framework\TestCase; +use Test\TestCase; final class PathTest extends TestCase { public function testPaths() { $this->assertStringStartsWith(base_path(), public_path()); - $this->assertEquals(base_path() . '/public/index.php', public_path('index.php')); - $this->assertEquals(base_path() . '/public', base_path('public')); + + $this->assertPathEquals(base_path() . '\public\index.php', public_path('index.php')); + $this->assertPathEquals(base_path() . '/public', base_path('public')); } } diff --git a/tests/src/Util/StringTest.php b/tests/src/Util/StringTest.php index 77f8fbc83a..a842d1c804 100644 --- a/tests/src/Util/StringTest.php +++ b/tests/src/Util/StringTest.php @@ -4,7 +4,7 @@ namespace Test\Util; -use PHPUnit\Framework\TestCase; +use Test\TestCase; final class StringTest extends TestCase { diff --git a/tests/src/Util/UrlTest.php b/tests/src/Util/UrlTest.php index 102edd632b..d690e2a783 100644 --- a/tests/src/Util/UrlTest.php +++ b/tests/src/Util/UrlTest.php @@ -4,7 +4,7 @@ namespace Test\Util; -use PHPUnit\Framework\TestCase; +use Test\TestCase; final class UrlTest extends TestCase {