Skip to content
Snippets Groups Projects
Verified Commit b0dd9219 authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

test: add Path tests

parent cc5ffff6
No related branches found
No related tags found
2 merge requests!3improve into wp-hook and some additional unfinished things,!21.x
......@@ -7,14 +7,42 @@ use WPDesk\Init\Util\Path;
class PathTest extends TestCase {
public function test_canonical_path(): void {
public function test_canonical_path(): void
{
$path = new Path('src/unit/../etc');
$this->assertEquals('src/etc', (string) $path->canonical());
}
public function test_absolute_path(): void
{
$path = new Path('src');
$this->assertEquals(getcwd().'/src', (string) $path->absolute());
}
public function test_join(): void {
$path = new Path('src');
$this->assertEquals('src/test/unit', (string) $path->join('test', 'unit'));
$this->assertEquals(getcwd().'/src/Util', (string) $path->join('test', '..', 'Util')->absolute());
public function test_join(): void
{
$path = new Path('/var/www');
$joinedPath = $path->join('public', 'html', 'index.php');
$this->assertEquals('/var/www/public/html/index.php', (string) $joinedPath);
}
public function test_get_basename(): void
{
$path = new Path('/var/www/public/html/index.php');
$this->assertEquals('index.php', $path->get_basename());
}
public function test_get_filename_without_extension(): void
{
$path = new Path('/var/www/public/html/index.php');
$this->assertEquals('index', $path->get_filename_without_extension());
}
public function test_read_directory(): void
{
$path = new Path(__DIR__ . '/../Fixtures/hook-bindings/');
$dirContent = $path->read_directory();
$this->assertEquals(getcwd() . '/tests/Fixtures/hook-bindings/index.php', (string) $dirContent[0]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment