1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-04 08:10: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:
Chris Brown
2020-11-28 13:23:59 -05:00
parent b01556272d
commit 0b341a7ca1
12 changed files with 68 additions and 128 deletions

View File

@@ -9,29 +9,27 @@
use function Valet\swap;
use Illuminate\Container\Container;
class NginxTest extends PHPUnit_Framework_TestCase
class NginxTest 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()
{
Mockery::close();
}
public function test_install_nginx_configuration_places_nginx_base_configuration_in_proper_location()
{
$files = Mockery::mock(Filesystem::class.'[putAsUser]');
$files->shouldReceive('putAsUser')->andReturnUsing(function ($path, $contents) {
$this->assertSame(BREW_PREFIX.'/etc/nginx/nginx.conf', $path);
$this->assertContains('include "'.VALET_HOME_PATH.'/Nginx/*"', $contents);
$this->assertStringContainsString('include "'.VALET_HOME_PATH.'/Nginx/*"', $contents);
})->once();
swap(Filesystem::class, $files);
@@ -40,7 +38,6 @@ public function test_install_nginx_configuration_places_nginx_base_configuration
$nginx->installConfiguration();
}
public function test_install_nginx_directories_creates_location_for_site_specific_configuration()
{
$files = Mockery::mock(Filesystem::class);
@@ -56,7 +53,6 @@ public function test_install_nginx_directories_creates_location_for_site_specifi
$nginx->installNginxDirectory();
}
public function test_nginx_directory_is_never_created_if_it_already_exists()
{
$files = Mockery::mock(Filesystem::class);
@@ -72,7 +68,6 @@ public function test_nginx_directory_is_never_created_if_it_already_exists()
$nginx->installNginxDirectory();
}
public function test_install_nginx_directories_rewrites_secure_nginx_files()
{
$files = Mockery::mock(Filesystem::class);
@@ -89,5 +84,4 @@ public function test_install_nginx_directories_rewrites_secure_nginx_files()
$site->shouldHaveReceived('resecureForNewTld', ['test', 'test']);
}
}