Skip to content

Commit

Permalink
Allow a custom path for PHPUnit binary (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
romainnorberg authored and freekmurze committed Nov 12, 2018
1 parent 81b2889 commit 7f5cc1b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ notifications:
passingTests: false
failingTests: false
phpunit:
binaryPath: vendor/bin/phpunit
arguments: '--stop-on-failure'
```
Expand All @@ -110,7 +111,20 @@ notifications:
failingTests: false
```

### Initial PHPUnit arguments
### Customize PHPUnit

#### Binary

By default the tool use `vendor/bin/phpunit` as default PHPUnit binary file, however, it may be useful to be able to customize this value for people who have a binary file in a different location.

You can specificy it in the `.phpunit-watcher.yml` config file. Here's an example:

```yaml
phpunit:
binaryPath: ./vendor/phpunit/phpunit/phpunit
```

#### Initial arguments

If you want to use pass the same arguments to PHPUnit everytime to watcher starts, you can specificy those in the `.phpunit-watcher.yml` config file. Here's an example:

Expand Down
9 changes: 8 additions & 1 deletion src/Screens/Phpunit.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@

class Phpunit extends Screen
{
const DEFAULT_BINARY_PATH = 'vendor/bin/phpunit';

/** @var array */
public $options;

/** @var string */
protected $phpunitArguments;

/** @var string */
private $phpunitBinaryPath;

public function __construct(array $options)
{
$this->options = $options;

$this->phpunitArguments = $options['phpunit']['arguments'] ?? '';

$this->phpunitBinaryPath = $options['phpunit']['binaryPath'] ?? self::DEFAULT_BINARY_PATH;
}

public function draw()
Expand Down Expand Up @@ -83,7 +90,7 @@ protected function writeHeader()

protected function runTests()
{
$result = (new Process("vendor/bin/phpunit {$this->phpunitArguments}"))
$result = (new Process("{$this->phpunitBinaryPath} {$this->phpunitArguments}"))
->setTty(true)
->run(function ($type, $line) {
echo $line;
Expand Down

0 comments on commit 7f5cc1b

Please sign in to comment.