diff --git a/composer.json b/composer.json index 3b8d229d..96e6e428 100755 --- a/composer.json +++ b/composer.json @@ -89,7 +89,8 @@ "padraic/phar-updater": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^5.7", + "mockery/mockery": "^1.3" }, "config": { "platform": { diff --git a/composer.lock b/composer.lock index 8bed47e1..7a71153e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7ec8559bdf0136a99e1f68c2c278d24e", + "content-hash": "ee277424273531d2fad2697a3476b87c", "packages": [ { "name": "composer/ca-bundle", @@ -1843,6 +1843,118 @@ ], "time": "2015-06-14T21:17:01+00:00" }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "time": "2020-07-09T08:09:16+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.3.3", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "60fa2f67f6e4d3634bb4a45ff3171fa52215800d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/60fa2f67f6e4d3634bb4a45ff3171fa52215800d", + "reference": "60fa2f67f6e4d3634bb4a45ff3171fa52215800d", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.10|^6.5|^7.5|^8.5|^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "time": "2020-08-11T18:10:21+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.7.0", diff --git a/tests/Fake/Process/DummyExecute.php b/tests/Fake/Process/DummyExecute.php index 4c729a94..4d06cc06 100644 --- a/tests/Fake/Process/DummyExecute.php +++ b/tests/Fake/Process/DummyExecute.php @@ -17,15 +17,36 @@ class DummyExecute extends Execute { + private function getMockProcess($cmd) + { + $process = \Mockery::mock('Symfony\Component\Process\Process'); + $process->shouldReceive( + 'setTimeout', + 'run', + 'wait', + 'stop', + 'getExitCode', + 'getExitCodeText', + 'getWorkingDirectory', + 'isOutputDisabled', + 'getErrorOutput' + ); + + $process->shouldReceive('isSuccessful')->andReturn(true); + $process->shouldReceive('getOutput')->andReturn(''); + $process->shouldReceive('getCommandLine')->andReturn($cmd); + + return $process; + } + public function run($cmd, $error = null) { if ($cmd instanceof Process) { // Get the command line from process. $cmd = $cmd->getCommandLine(); } - $cmd = new DummyProcess($cmd); - return $this->helper->run($this->output, $cmd, $error); + return $this->helper->run($this->output, $this->getMockProcess($cmd), $error); } public function mustRun($cmd, $error = null) @@ -34,9 +55,8 @@ public function mustRun($cmd, $error = null) // Get the command line from process. $cmd = $cmd->getCommandLine(); } - $cmd = new DummyProcess($cmd); - return $this->helper->mustRun($this->output, $cmd, $error); + return $this->helper->mustRun($this->output, $this->getMockProcess($cmd), $error); } public function runAll($processes) @@ -51,15 +71,15 @@ public function mustRunAll($processes) public function passThrough($commandline, $cwd = null, $timeout = null) { - return $this->passThroughProcess(new DummyProcess($commandline, $cwd, null, null, $timeout)); + return $this->passThroughProcess($this->getMockProcess($commandline)); } public function passThroughProcess(Process $process) { - if ($process instanceof DummyProcess) { + if ($process instanceof \Mockery\MockInterface) { return $process; } - return new DummyProcess($process->getCommandLine(), $process->getWorkingDirectory(), null, null, $process->getTimeout()); + return $this->getMockProcess($process->getCommandLine()); } } diff --git a/tests/Fake/Process/DummyProcess.php b/tests/Fake/Process/DummyProcess.php deleted file mode 100644 index d412a39f..00000000 --- a/tests/Fake/Process/DummyProcess.php +++ /dev/null @@ -1,40 +0,0 @@ -realcommandline = $commandline; - } - - public function getCommandLine() - { - return $this->realcommandline; - } - - public function getOutput() - { - return ''; - } - - public function isSuccessful() - { - return true; - } -}