mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 16:40:05 +01:00
Update test suite to phpunit 9.5 syntax Refactored to use polyfill for older PHP versions via `yoast/phpunit-polyfills` Note: this includes 2 important differences from usual phpunit test suites: - instead of extending `PHPUnit\Framework\TestCase` we extend `Yoast\PHPUnitPolyfills\TestCases\TestCase` - instead of handling fixtures via `setUp()` and `tearDown()` we use `set_up()` and `tear_down()` respectively Comment regarding formatting: I chose to use the FQDN in the `extends` syntax of the class declaration instead of using `use` so that it is more quickly apparent that we're doing something slightly different than usual phpunit syntax, particularly in regards to the set_up() / tear_down() methods that appear immediately following the `extends` line.
25 lines
753 B
PHP
25 lines
753 B
PHP
<?php
|
|
|
|
use Valet\Filesystem;
|
|
|
|
class FilesystemTest extends Yoast\PHPUnitPolyfills\TestCases\TestCase
|
|
{
|
|
public function tear_down()
|
|
{
|
|
exec('rm -rf '.__DIR__.'/output');
|
|
mkdir(__DIR__.'/output');
|
|
touch(__DIR__.'/output/.gitkeep');
|
|
}
|
|
|
|
public function test_remove_broken_links_removes_broken_symlinks()
|
|
{
|
|
$files = new Filesystem;
|
|
file_put_contents(__DIR__.'/output/file.out', 'test');
|
|
symlink(__DIR__.'/output/file.out', __DIR__.'/output/file.link');
|
|
$this->assertFileExists(__DIR__.'/output/file.link');
|
|
unlink(__DIR__.'/output/file.out');
|
|
$files->removeBrokenLinksAt(__DIR__.'/output');
|
|
$this->assertFileDoesNotExist(__DIR__.'/output/file.link');
|
|
}
|
|
}
|