Skip to content

Commit

Permalink
Merge pull request #46 from clue-labs/tests
Browse files Browse the repository at this point in the history
Add PHPUnit to require-dev
  • Loading branch information
clue authored Jul 8, 2017
2 parents 988f7ce + 9720d7e commit 834aff1
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ install:
- composer install --prefer-source --no-interaction

script:
- phpunit --coverage-text
- vendor/bin/phpunit --coverage-text
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,36 @@ Zenity](#install) yourself.

![https://help.gnome.org/users/zenity/stable/question.html](https://help.gnome.org/users/zenity/stable/figures/zenity-question-screenshot.png)

**Table of contents**

* [Quickstart example](#quickstart-example)
* [Usage](#usage)
* [Launcher](#launcher)
* [setBin()](#setbin)
* [waitFor()](#waitfor)
* [launch()](#launch)
* [launchZen()](#launchzen)
* [Mixing synchronous and asynchronous PHP](#mixing-synchronous-and-asynchronous-php)
* [Builder](#builder)
* [Dialog](#dialog)
* [AbstractDialog](#abstractdialog)
* [CalendarDialog](#calendardialog)
* [ColorSelectionDialog](#colorselectiondialog)
* [EntryDialog](#entrydialog)
* [ErrorDialog](#errordialog)
* [FileSelectionDialog](#fileselectiondialog)
* [FormsDialog](#formsdialog)
* [InfoDialog](#infodialog)
* [ListDialog](#listdialog)
* [NotificationDialog](#notificationdialog)
* [PasswordDialog](#passworddialog)
* [QuestionDialog](#questiondialog)
* [ScaleDialog](#scaledialog)
* [TextInfoDialog](#textinfodialog)
* [WarningDialog](#warningdialog)
* [Install](#install)
* [License](#license)

## Quickstart example

Once [installed](#install), you can use the following code to open a prompt
Expand Down Expand Up @@ -297,6 +327,21 @@ $launcher = new Launcher($loop);
$launcher->setBin('/path/to/zenity');
```

## Tests

To run the test suite, you first need to clone this repo and then install all
dependencies [through Composer](https://getcomposer.org):

```bash
$ composer install
```

To run the test suite, go to the project root and run:

```bash
$ php vendor/bin/phpunit
```

## License

MIT
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"react/child-process": "~0.4.0|~0.3.0"
},
"require-dev": {
"clue/block-react": "^1.1"
"clue/block-react": "^1.1",
"phpunit/phpunit": "^5.0 || ^4.8"
},
"autoload": {
"psr-4": { "Clue\\React\\Zenity\\": "src/" }
Expand Down
2 changes: 1 addition & 1 deletion tests/FunctionalLauncherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function setUp()
{
$this->loop = Factory::create();

$this->dialog = $this->getMock('Clue\React\Zenity\Dialog\AbstractDialog');
$this->dialog = $this->getMockBuilder('Clue\React\Zenity\Dialog\AbstractDialog')->getMock();
$this->dialog->expects($this->once())->method('createZen')->will($this->returnValue(new BaseZen()));

$this->launcher = new Launcher($this->loop);
Expand Down
6 changes: 3 additions & 3 deletions tests/Zen/BaseZenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ abstract class BaseZenTest extends TestCase
public function setUp()
{
$inbuffer =& $this->stdin;
$this->instream = $this->getMock('React\Stream\WritableStreamInterface');
$this->instream = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
$this->instream->expects($this->any())->method('write')->will($this->returnCallback(function ($value) use (&$inbuffer) {
$inbuffer .= $value;
}));

$this->process = $this->getMockBuilder('React\ChildProcess\Process')->disableOriginalConstructor()->getMock();
$this->process->stdin = $this->instream;

$this->process->stdout = $this->getMock('React\Stream\ReadableStreamInterface');
$this->process->stderr = $this->getMock('React\Stream\ReadableStreamInterface');
$this->process->stdout = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$this->process->stderr = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
}

public function testClosingZenTerminatesProcess()
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function expectCallableNever()
*/
protected function createCallableMock()
{
return $this->getMock('CallableStub');
return $this->getMockBuilder('CallableStub')->getMock();
}

protected function expectPromiseResolve($promise)
Expand Down

0 comments on commit 834aff1

Please sign in to comment.