From 71bb4eec671fcef581faffe3e8189b2839fb1d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 29 Jun 2017 21:57:42 +0200 Subject: [PATCH 1/2] Add PHPUnit to require-dev --- .travis.yml | 2 +- README.md | 16 ++++++++++++++++ composer.json | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3464291..6983d72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,4 +14,4 @@ install: - composer install --no-interaction script: - - phpunit --coverage-text + - vendor/bin/phpunit --coverage-text diff --git a/README.md b/README.md index 034299d..e661962 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ to execute individual functions depending on the arguments given. * [Route](#route) * [NoRouteFoundException](#noroutefoundexception) * [Install](#install) +* [Tests](#tests) * [License](#license) * [More](#more) @@ -554,6 +555,21 @@ $ composer require clue/commander:^1.2 See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. +## Tests + +To run the test suite, you first need to clone this repo and then install all +dependencies [through Composer](http://getcomposer.org): + +```bash +$ composer install +``` + +To run the test suite, go to the project root and run: + +```bash +$ php vendor/bin/phpunit +``` + ## License MIT diff --git a/composer.json b/composer.json index 5e63f51..01def9e 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "php": ">=5.3" }, "require-dev": { - "clue/arguments": "^1.0" + "clue/arguments": "^1.0", + "phpunit/phpunit": "^4.8" } } From a4ec330626cd614c08f61be610c40afa54823d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 29 Jun 2017 22:00:49 +0200 Subject: [PATCH 2/2] Forward compatibility with PHPUnit v5 --- composer.json | 2 +- tests/RouteTest.php | 2 +- tests/Tokens/AlternativeTokenTest.php | 6 +++--- tests/Tokens/SentenceTokenTest.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 01def9e..ef360f2 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,6 @@ }, "require-dev": { "clue/arguments": "^1.0", - "phpunit/phpunit": "^4.8" + "phpunit/phpunit": "^5.0 || ^4.8" } } diff --git a/tests/RouteTest.php b/tests/RouteTest.php index b1ce542..ac1bba9 100644 --- a/tests/RouteTest.php +++ b/tests/RouteTest.php @@ -6,7 +6,7 @@ class RouteTest extends PHPUnit_Framework_TestCase { public function testToStringWillReturnStringFromToken() { - $token = $this->getMock('Clue\Commander\Tokens\TokenInterface'); + $token = $this->getMockBuilder('Clue\Commander\Tokens\TokenInterface')->getMock(); $token->expects($this->once())->method('__toString')->willReturn('test'); $route = new Route($token, 'var_dump'); diff --git a/tests/Tokens/AlternativeTokenTest.php b/tests/Tokens/AlternativeTokenTest.php index 2b80898..ab6b17b 100644 --- a/tests/Tokens/AlternativeTokenTest.php +++ b/tests/Tokens/AlternativeTokenTest.php @@ -9,8 +9,8 @@ class AlternativeTokenTest extends PHPUnit_Framework_TestCase public function testSupportsAnyTwoTokens() { new AlternativeToken(array( - $this->getMock('Clue\Commander\Tokens\TokenInterface'), - $this->getMock('Clue\Commander\Tokens\TokenInterface'), + $this->getMockBuilder('Clue\Commander\Tokens\TokenInterface')->getMock(), + $this->getMockBuilder('Clue\Commander\Tokens\TokenInterface')->getMock(), )); } @@ -35,7 +35,7 @@ public function testRequiresValidTokens() public function testDoesNotSupportOptional() { - $token = $this->getMock('Clue\Commander\Tokens\TokenInterface'); + $token = $this->getMockBuilder('Clue\Commander\Tokens\TokenInterface')->getMock(); $tokens = array( $token, new OptionalToken($token) diff --git a/tests/Tokens/SentenceTokenTest.php b/tests/Tokens/SentenceTokenTest.php index e9a3d8e..d552bc1 100644 --- a/tests/Tokens/SentenceTokenTest.php +++ b/tests/Tokens/SentenceTokenTest.php @@ -8,8 +8,8 @@ class SentenceTokenTest extends PHPUnit_Framework_TestCase public function testSupportsAnyTwoTokens() { new SentenceToken(array( - $this->getMock('Clue\Commander\Tokens\TokenInterface'), - $this->getMock('Clue\Commander\Tokens\TokenInterface'), + $this->getMockBuilder('Clue\Commander\Tokens\TokenInterface')->getMock(), + $this->getMockBuilder('Clue\Commander\Tokens\TokenInterface')->getMock(), )); }