mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 08:30:07 +01:00
Update test suite to phpunit 9.5
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.
This commit is contained in:
@@ -9,17 +9,16 @@
|
||||
use function Valet\swap;
|
||||
use Illuminate\Container\Container;
|
||||
|
||||
class SiteTest extends PHPUnit_Framework_TestCase
|
||||
class SiteTest extends Yoast\PHPUnitPolyfills\TestCases\TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function set_up()
|
||||
{
|
||||
$_SERVER['SUDO_USER'] = user();
|
||||
|
||||
Container::setInstance(new Container);
|
||||
}
|
||||
|
||||
|
||||
public function tearDown()
|
||||
public function tear_down()
|
||||
{
|
||||
exec('rm -rf '.__DIR__.'/output');
|
||||
mkdir(__DIR__.'/output');
|
||||
@@ -28,7 +27,6 @@ public function tearDown()
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
|
||||
public function test_get_certificates_will_return_with_multi_segment_tld()
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
@@ -53,7 +51,6 @@ public function test_get_certificates_will_return_with_multi_segment_tld()
|
||||
$this->assertSame(['helloworld' => 0], $certs->all());
|
||||
}
|
||||
|
||||
|
||||
public function test_get_sites_will_return_if_secured()
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
@@ -108,7 +105,6 @@ public function test_get_sites_will_return_if_secured()
|
||||
], $sites->last());
|
||||
}
|
||||
|
||||
|
||||
public function test_get_sites_will_work_with_non_symlinked_path()
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
@@ -151,7 +147,6 @@ public function test_get_sites_will_work_with_non_symlinked_path()
|
||||
], $sites->first());
|
||||
}
|
||||
|
||||
|
||||
public function test_get_sites_will_not_return_if_path_is_not_directory()
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
@@ -189,7 +184,6 @@ public function test_get_sites_will_not_return_if_path_is_not_directory()
|
||||
], $sites->first());
|
||||
}
|
||||
|
||||
|
||||
public function test_get_sites_will_work_with_symlinked_path()
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
@@ -232,7 +226,6 @@ public function test_get_sites_will_work_with_symlinked_path()
|
||||
], $sites->first());
|
||||
}
|
||||
|
||||
|
||||
public function test_symlink_creates_symlink_to_given_path()
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
@@ -248,21 +241,19 @@ public function test_symlink_creates_symlink_to_given_path()
|
||||
$this->assertSame(VALET_HOME_PATH.'/Sites/link', $linkPath);
|
||||
}
|
||||
|
||||
|
||||
public function test_unlink_removes_existing_symlink()
|
||||
{
|
||||
file_put_contents(__DIR__.'/output/file.out', 'test');
|
||||
symlink(__DIR__.'/output/file.out', __DIR__.'/output/link');
|
||||
$site = resolve(StubForRemovingLinks::class);
|
||||
$site->unlink('link');
|
||||
$this->assertFileNotExists(__DIR__.'/output/link');
|
||||
$this->assertFileDoesNotExist(__DIR__.'/output/link');
|
||||
|
||||
$site = resolve(StubForRemovingLinks::class);
|
||||
$site->unlink('link');
|
||||
$this->assertFileNotExists(__DIR__.'/output/link');
|
||||
$this->assertFileDoesNotExist(__DIR__.'/output/link');
|
||||
}
|
||||
|
||||
|
||||
public function test_prune_links_removes_broken_symlinks_in_sites_path()
|
||||
{
|
||||
file_put_contents(__DIR__.'/output/file.out', 'test');
|
||||
@@ -270,10 +261,9 @@ public function test_prune_links_removes_broken_symlinks_in_sites_path()
|
||||
unlink(__DIR__.'/output/file.out');
|
||||
$site = resolve(StubForRemovingLinks::class);
|
||||
$site->pruneLinks();
|
||||
$this->assertFileNotExists(__DIR__.'/output/link');
|
||||
$this->assertFileDoesNotExist(__DIR__.'/output/link');
|
||||
}
|
||||
|
||||
|
||||
public function test_certificates_trim_tld_for_custom_tlds()
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
@@ -300,7 +290,6 @@ public function test_certificates_trim_tld_for_custom_tlds()
|
||||
$this->assertEquals('fiveletters', $certs->last());
|
||||
}
|
||||
|
||||
|
||||
public function test_no_proxies()
|
||||
{
|
||||
$config = Mockery::mock(Configuration::class);
|
||||
@@ -317,7 +306,6 @@ public function test_no_proxies()
|
||||
$this->assertEquals([], $site->proxies()->all());
|
||||
}
|
||||
|
||||
|
||||
public function test_lists_proxies()
|
||||
{
|
||||
$config = Mockery::mock(Configuration::class);
|
||||
@@ -347,7 +335,6 @@ public function test_lists_proxies()
|
||||
], $site->proxies()->all());
|
||||
}
|
||||
|
||||
|
||||
public function test_add_proxy()
|
||||
{
|
||||
$config = Mockery::mock(Configuration::class);
|
||||
@@ -381,7 +368,6 @@ public function test_add_proxy()
|
||||
], $site->proxies()->all());
|
||||
}
|
||||
|
||||
|
||||
public function test_add_proxy_clears_previous_proxy_certificate()
|
||||
{
|
||||
$config = Mockery::mock(Configuration::class);
|
||||
@@ -426,7 +412,6 @@ public function test_add_proxy_clears_previous_proxy_certificate()
|
||||
], $site->proxies()->all());
|
||||
}
|
||||
|
||||
|
||||
public function test_add_proxy_clears_previous_non_proxy_certificate()
|
||||
{
|
||||
$config = Mockery::mock(Configuration::class);
|
||||
@@ -467,7 +452,6 @@ public function test_add_proxy_clears_previous_non_proxy_certificate()
|
||||
], $site->proxies()->all());
|
||||
}
|
||||
|
||||
|
||||
public function test_remove_proxy()
|
||||
{
|
||||
$config = Mockery::mock(Configuration::class);
|
||||
@@ -602,7 +586,7 @@ public function assertNginxExists($urlWithTld)
|
||||
|
||||
public function assertNginxNotExists($urlWithTld)
|
||||
{
|
||||
SiteTest::assertFileNotExists($this->nginxPath($urlWithTld));
|
||||
SiteTest::assertFileDoesNotExist($this->nginxPath($urlWithTld));
|
||||
}
|
||||
|
||||
public function assertCertificateExists($urlWithTld)
|
||||
@@ -613,8 +597,8 @@ public function assertCertificateExists($urlWithTld)
|
||||
|
||||
public function assertCertificateNotExists($urlWithTld)
|
||||
{
|
||||
SiteTest::assertFileNotExists($this->certificatesPath($urlWithTld, 'crt'));
|
||||
SiteTest::assertFileNotExists($this->certificatesPath($urlWithTld, 'key'));
|
||||
SiteTest::assertFileDoesNotExist($this->certificatesPath($urlWithTld, 'crt'));
|
||||
SiteTest::assertFileDoesNotExist($this->certificatesPath($urlWithTld, 'key'));
|
||||
}
|
||||
|
||||
public function assertCertificateExistsWithCounterValue($urlWithTld, $counter)
|
||||
|
||||
Reference in New Issue
Block a user