-
Notifications
You must be signed in to change notification settings - Fork 702
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1004 from drbyte/phpunit-polyfill
Update test suite to phpunit 9.5
- Loading branch information
Showing
12 changed files
with
68 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ vendor/ | |
composer.lock | ||
error.log | ||
.idea | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,28 +9,25 @@ | |
use Illuminate\Support\Collection; | ||
use Illuminate\Container\Container; | ||
|
||
class BrewTest extends PHPUnit_Framework_TestCase | ||
class BrewTest 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_brew_can_be_resolved_from_container() | ||
{ | ||
$this->assertInstanceOf(Brew::class, resolve(Brew::class)); | ||
} | ||
|
||
|
||
public function test_installed_returns_true_when_given_formula_is_installed() | ||
{ | ||
$cli = Mockery::mock(CommandLine::class); | ||
|
@@ -45,7 +42,6 @@ public function test_installed_returns_true_when_given_formula_is_installed() | |
$this->assertTrue(resolve(Brew::class)->installed('php')); | ||
} | ||
|
||
|
||
public function test_installed_returns_false_when_given_formula_is_not_installed() | ||
{ | ||
$cli = Mockery::mock(CommandLine::class); | ||
|
@@ -66,7 +62,6 @@ public function test_installed_returns_false_when_given_formula_is_not_installed | |
$this->assertFalse(resolve(Brew::class)->installed('[email protected]')); | ||
} | ||
|
||
|
||
public function test_has_installed_php_indicates_if_php_is_installed_via_brew() | ||
{ | ||
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]); | ||
|
@@ -196,7 +191,6 @@ public function test_has_installed_php_indicates_if_php_is_installed_via_brew() | |
$this->assertFalse($brew->hasInstalledPhp()); | ||
} | ||
|
||
|
||
public function test_tap_taps_the_given_homebrew_repository() | ||
{ | ||
$cli = Mockery::mock(CommandLine::class); | ||
|
@@ -207,7 +201,6 @@ public function test_tap_taps_the_given_homebrew_repository() | |
resolve(Brew::class)->tap('[email protected]', '[email protected]', '[email protected]'); | ||
} | ||
|
||
|
||
public function test_restart_restarts_the_service_using_homebrew_services() | ||
{ | ||
$cli = Mockery::mock(CommandLine::class); | ||
|
@@ -218,7 +211,6 @@ public function test_restart_restarts_the_service_using_homebrew_services() | |
resolve(Brew::class)->restartService('dnsmasq'); | ||
} | ||
|
||
|
||
public function test_stop_stops_the_service_using_homebrew_services() | ||
{ | ||
$cli = Mockery::mock(CommandLine::class); | ||
|
@@ -228,7 +220,6 @@ public function test_stop_stops_the_service_using_homebrew_services() | |
resolve(Brew::class)->stopService('dnsmasq'); | ||
} | ||
|
||
|
||
public function test_linked_php_returns_linked_php_formula_name() | ||
{ | ||
$getBrewMock = function ($filesystem) { | ||
|
@@ -262,18 +253,15 @@ public function test_linked_php_returns_linked_php_formula_name() | |
$this->assertSame('[email protected]', $getBrewMock($files)->linkedPhp()); | ||
} | ||
|
||
|
||
/** | ||
* @expectedException DomainException | ||
*/ | ||
public function test_linked_php_throws_exception_if_no_php_link() | ||
{ | ||
$this->expectException(DomainException::class); | ||
|
||
$brewMock = Mockery::mock(Brew::class)->makePartial(); | ||
$brewMock->shouldReceive('hasLinkedPhp')->once()->andReturn(false); | ||
$brewMock->linkedPhp(); | ||
} | ||
|
||
|
||
public function test_has_linked_php_returns_true_if_php_link_exists() | ||
{ | ||
$files = Mockery::mock(Filesystem::class); | ||
|
@@ -285,29 +273,25 @@ public function test_has_linked_php_returns_true_if_php_link_exists() | |
$this->assertTrue($brew->hasLinkedPhp()); | ||
} | ||
|
||
|
||
/** | ||
* @expectedException DomainException | ||
*/ | ||
public function test_linked_php_throws_exception_if_unsupported_php_version_is_linked() | ||
{ | ||
$this->expectException(DomainException::class); | ||
|
||
$files = Mockery::mock(Filesystem::class); | ||
$files->shouldReceive('isLink')->once()->with(BREW_PREFIX.'/bin/php')->andReturn(true); | ||
$files->shouldReceive('readLink')->once()->with(BREW_PREFIX.'/bin/php')->andReturn('/test/path/php/5.4.14/test'); | ||
swap(Filesystem::class, $files); | ||
resolve(Brew::class)->linkedPhp(); | ||
} | ||
|
||
|
||
public function test_install_or_fail_will_install_brew_formulas() | ||
public function test_install_or_fail_will_install_brew_formulae() | ||
{ | ||
$cli = Mockery::mock(CommandLine::class); | ||
$cli->shouldReceive('runAsUser')->once()->with('brew install dnsmasq', Mockery::type('Closure')); | ||
swap(CommandLine::class, $cli); | ||
resolve(Brew::class)->installOrFail('dnsmasq'); | ||
} | ||
|
||
|
||
public function test_install_or_fail_can_install_taps() | ||
{ | ||
$cli = Mockery::mock(CommandLine::class); | ||
|
@@ -318,12 +302,10 @@ public function test_install_or_fail_can_install_taps() | |
$brew->installOrFail('dnsmasq', [], ['test/tap']); | ||
} | ||
|
||
|
||
/** | ||
* @expectedException DomainException | ||
*/ | ||
public function test_install_or_fail_throws_exception_on_failure() | ||
{ | ||
$this->expectException(DomainException::class); | ||
|
||
$cli = Mockery::mock(CommandLine::class); | ||
$cli->shouldReceive('runAsUser')->andReturnUsing(function ($command, $onError) { | ||
$onError(1, 'test error ouput'); | ||
|
@@ -332,11 +314,10 @@ public function test_install_or_fail_throws_exception_on_failure() | |
resolve(Brew::class)->installOrFail('dnsmasq'); | ||
} | ||
|
||
/** | ||
* @expectedException DomainException | ||
*/ | ||
public function test_link_will_throw_exception_on_failure() | ||
{ | ||
$this->expectException(DomainException::class); | ||
|
||
$cli = Mockery::mock(CommandLine::class); | ||
$cli->shouldReceive('runAsUser')->once()->withArgs([ | ||
'brew link aformula', | ||
|
@@ -372,11 +353,10 @@ public function test_link_will_pass_formula_and_force_to_run_as_user_if_set() | |
$this->assertSame('Some output forced', resolve(Brew::class)->link('aformula', true)); | ||
} | ||
|
||
/** | ||
* @expectedException DomainException | ||
*/ | ||
public function test_unlink_will_throw_exception_on_failure() | ||
{ | ||
$this->expectException(DomainException::class); | ||
|
||
$cli = Mockery::mock(CommandLine::class); | ||
$cli->shouldReceive('runAsUser')->once()->withArgs([ | ||
'brew unlink aformula', | ||
|
@@ -400,11 +380,10 @@ public function test_unlink_will_pass_formula_to_run_as_user() | |
$this->assertSame('Some output', resolve(Brew::class)->unlink('aformula')); | ||
} | ||
|
||
/** | ||
* @expectedException DomainException | ||
*/ | ||
public function test_getRunningServices_will_throw_exception_on_failure() | ||
{ | ||
$this->expectException(DomainException::class); | ||
|
||
$cli = Mockery::mock(CommandLine::class); | ||
$cli->shouldReceive('runAsUser')->once()->withArgs([ | ||
'brew services list | grep started | awk \'{ print $1; }\'', | ||
|
@@ -485,48 +464,48 @@ public function supportedPhpLinkPathProvider() | |
{ | ||
return [ | ||
[ | ||
'/test/path/php/7.3.0/test', // linked path | ||
'/test/path/php/7.4.0/test', // linked path | ||
[ // matches | ||
'path/php/7.3.0/test', | ||
'path/php/7.4.0/test', | ||
'php', | ||
'', | ||
'7.3', | ||
'7.4', | ||
'.0', | ||
], | ||
'php', // expected link formula | ||
], | ||
[ | ||
'/test/path/php@7.2/7.2.13/test', | ||
'/test/path/php@7.4/7.4.13/test', | ||
[ | ||
'path/php@7.2/7.2.13/test', | ||
'path/php@7.4/7.4.13/test', | ||
'php', | ||
'@7.2', | ||
'7.2', | ||
'@7.4', | ||
'7.4', | ||
'.13', | ||
], | ||
'php@7.2' | ||
'php@7.4' | ||
], | ||
[ | ||
'/test/path/php/7.2.9_2/test', | ||
'/test/path/php/7.4.9_2/test', | ||
[ | ||
'path/php/7.2.9_2/test', | ||
'path/php/7.4.9_2/test', | ||
'php', | ||
'', | ||
'7.2', | ||
'7.4', | ||
'.9_2', | ||
], | ||
'php', | ||
], | ||
[ | ||
'/test/path/php72/7.2.9_2/test', | ||
'/test/path/php74/7.4.9_2/test', | ||
[ | ||
'path/php72/7.2.9_2/test', | ||
'path/php74/7.4.9_2/test', | ||
'php', | ||
'72', | ||
'7.2', | ||
'74', | ||
'7.4', | ||
'.9_2', | ||
], | ||
'php72', | ||
'php74', | ||
], | ||
[ | ||
'/test/path/php56/test', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.