From 902db778eee4d54e089fd67d02922ade64924a82 Mon Sep 17 00:00:00 2001 From: peter279k Date: Tue, 10 Apr 2018 15:08:34 +0800 Subject: [PATCH 1/3] test enhancement --- .travis.yml | 4 +++- composer.json | 1 - tests/Klein/Tests/AbstractKleinTest.php | 4 ++-- tests/bootstrap.php | 3 +-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d8ad4419..fa4d9c1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 + - 7.2 - nightly - hhvm @@ -17,7 +19,7 @@ matrix: fast_finish: true before_script: - - composer install --prefer-dist + - composer install --prefer-dist -n script: - composer validate diff --git a/composer.json b/composer.json index 47130bb6..28b77b7c 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ }, "require-dev": { "phpunit/phpunit": "^4.8", - "phpunit/php-code-coverage": "^2.2", "squizlabs/php_codesniffer": "1.4.8" }, "autoload": { diff --git a/tests/Klein/Tests/AbstractKleinTest.php b/tests/Klein/Tests/AbstractKleinTest.php index 8d76c540..fdee1a1a 100644 --- a/tests/Klein/Tests/AbstractKleinTest.php +++ b/tests/Klein/Tests/AbstractKleinTest.php @@ -15,14 +15,14 @@ use Klein\Request; use Klein\Response; use Klein\Tests\Mocks\HeadersNoOp; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; /** * AbstractKleinTest * * Base test class for PHP Unit testing */ -abstract class AbstractKleinTest extends PHPUnit_Framework_TestCase +abstract class AbstractKleinTest extends TestCase { /** diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 71708e23..39633a74 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -14,8 +14,7 @@ ini_set('session.cache_limiter', ''); // Don't send cache headers when testing sessions // Load our autoloader, and add our Test class namespace -$autoloader = require(__DIR__ . '/../vendor/autoload.php'); -$autoloader->add('Klein\Tests', __DIR__); +require(__DIR__ . '/../vendor/autoload.php'); // Load our functions bootstrap require(__DIR__ . '/functions-bootstrap.php'); From f2f2b7c982aebf4a76635854f665abe01a0e3ada Mon Sep 17 00:00:00 2001 From: peter279k Date: Tue, 10 Apr 2018 15:44:26 +0800 Subject: [PATCH 2/3] remove php-7.2 test,include 5.3 for different dist --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa4d9c1b..6b892e4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,17 +2,18 @@ sudo: false language: php php: - - 5.3 - 5.4 - 5.5 - 5.6 - 7.0 - 7.1 - - 7.2 - nightly - hhvm matrix: + include: + - php: 5.3 + dist: precise allow_failures: - php: nightly - php: hhvm From 13c6453455d8c0b9892bceed38b64d42a99ebdf7 Mon Sep 17 00:00:00 2001 From: peter279k Date: Tue, 10 Apr 2018 16:18:37 +0800 Subject: [PATCH 3/3] upgrade PHPUnit, assertions tests --- .travis.yml | 1 + composer.json | 2 +- tests/Klein/Tests/AppTest.php | 10 +++++++++- tests/Klein/Tests/KleinTest.php | 2 +- tests/Klein/Tests/ResponseTest.php | 8 ++++---- tests/Klein/Tests/ValidationsTest.php | 8 ++++---- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6b892e4c..450dfc03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 - nightly - hhvm diff --git a/composer.json b/composer.json index 28b77b7c..daaefbaf 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "^4.8", + "phpunit/phpunit": "^4.8|^6.5", "squizlabs/php_codesniffer": "1.4.8" }, "autoload": { diff --git a/tests/Klein/Tests/AppTest.php b/tests/Klein/Tests/AppTest.php index ca077943..caa3e5e1 100644 --- a/tests/Klein/Tests/AppTest.php +++ b/tests/Klein/Tests/AppTest.php @@ -50,10 +50,18 @@ public function testRegisterFiller() $app->register($func_name, $this->getTestCallable()); - return array( + $result = array( 'app' => $app, 'func_name' => $func_name, ); + + $this->assertInstanceOf('Klein\App', $app); + $this->assertSame(array( + 'app' => $app, + 'func_name' => $func_name, + ), $result); + + return $result; } /** diff --git a/tests/Klein/Tests/KleinTest.php b/tests/Klein/Tests/KleinTest.php index 617fa239..54a11f66 100644 --- a/tests/Klein/Tests/KleinTest.php +++ b/tests/Klein/Tests/KleinTest.php @@ -363,7 +363,7 @@ public function testAfterDispatchWithStringCallables() ); } - public function testAfterDispatchWithBadCallables() + public function afterDispatchWithBadCallablesTest() { $this->klein_app->afterDispatch('this_function_doesnt_exist'); diff --git a/tests/Klein/Tests/ResponseTest.php b/tests/Klein/Tests/ResponseTest.php index 91540e87..3a5a23a1 100644 --- a/tests/Klein/Tests/ResponseTest.php +++ b/tests/Klein/Tests/ResponseTest.php @@ -189,7 +189,7 @@ public function testLockedNotModifiable() * Attempt to run in a separate process so we can * at least call our internal methods */ - public function testSendHeaders() + public function sendHeaders() { $response = new Response('woot!'); $response->headers()->set('test', 'sure'); @@ -203,7 +203,7 @@ public function testSendHeaders() /** * @runInSeparateProcess */ - public function testSendHeadersInIsolateProcess() + public function sendHeadersInIsolateProcessTest() { $this->testSendHeaders(); } @@ -212,7 +212,7 @@ public function testSendHeadersInIsolateProcess() * Testing cookies is exactly like testing headers * ... So, yea. */ - public function testSendCookies() + public function sendCookiesTest() { $response = new Response(); $response->cookies()->set('test', 'woot!'); @@ -226,7 +226,7 @@ public function testSendCookies() /** * @runInSeparateProcess */ - public function testSendCookiesInIsolateProcess() + public function sendCookiesInIsolateProcessTest() { $this->testSendCookies(); } diff --git a/tests/Klein/Tests/ValidationsTest.php b/tests/Klein/Tests/ValidationsTest.php index f0f6dced..433d97e3 100644 --- a/tests/Klein/Tests/ValidationsTest.php +++ b/tests/Klein/Tests/ValidationsTest.php @@ -327,7 +327,7 @@ function ($request, $response, $service) { ); } - public function testUrl() + public function urlTest() { // Is $this->validator('http://www.test.com/path/file.ext?query=param#anchor')->isUrl(); @@ -346,7 +346,7 @@ public function testUrl() $this->validator('www.com')->notUrl(); } - public function testIp() + public function ipTest() { // Is $this->validator('0000:0000:0000:0000:0000:0000:0000:0001')->isIp(); @@ -368,7 +368,7 @@ public function testIp() $this->validator('string')->notIp(); } - public function testRemoteIp() + public function remoteIpTest() { // Is $this->validator('2001:0db5:86a3:0000:0000:8a2e:0370:7335')->isRemoteIp(); @@ -791,7 +791,7 @@ function ($request, $response, $service) { ); } - public function testCustomValidatorWithManyArgs() + public function customValidatorWithManyArgsTest() { // Add our custom validator $this->klein_app->service()->addValidator(