Skip to content

Commit

Permalink
Add directory separator agnostic assertPathEquals() to tests (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
luchaos authored Jun 6, 2022
1 parent 3c115e4 commit a272408
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ nbproject
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
test*.php

/public/Badge
/public/Images
Expand Down
1 change: 0 additions & 1 deletion tests/src/ShortcodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Test;

use PHPUnit\Framework\TestCase;
use RA\Shortcode;

final class ShortcodeTest extends TestCase
Expand Down
13 changes: 13 additions & 0 deletions tests/src/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Test;

use PHPUnit\Framework\TestCase as BaseTestCase;

class TestCase extends BaseTestCase
{
protected function assertPathEquals(string $expected, string $actual, string $message = ''): void
{
$this->assertEquals(str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $expected), $actual, $message);
}
}
7 changes: 4 additions & 3 deletions tests/src/Util/PathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
2 changes: 1 addition & 1 deletion tests/src/Util/StringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Test\Util;

use PHPUnit\Framework\TestCase;
use Test\TestCase;

final class StringTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Util/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Test\Util;

use PHPUnit\Framework\TestCase;
use Test\TestCase;

final class UrlTest extends TestCase
{
Expand Down

0 comments on commit a272408

Please sign in to comment.