From 4c0cb52dc8834e50f4f734143599e450ff642b4f Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Fri, 29 May 2020 10:47:44 +0200 Subject: [PATCH 1/3] Run tests on PHP 7.4 and simplify test matrix --- .travis.yml | 19 ++++++++++--------- composer.json | 2 +- tests/FunctionalTest.php | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04f51ad..0a5430e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,5 @@ language: php -php: -# - 5.3 # requires old distro, see below - - 5.4 - - 5.5 - - 5.6 - - 7 - - hhvm # ignore errors, see below - # lock distro so new future defaults will not break the build dist: trusty @@ -15,8 +7,17 @@ matrix: include: - php: 5.3 dist: precise + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: 7.0 + - php: 7.1 + - php: 7.2 + - php: 7.3 + - php: 7.4 + - php: hhvm-3.18 allow_failures: - - php: hhvm + - php: hhvm-3.18 sudo: false diff --git a/composer.json b/composer.json index 72e4a8f..4a7db4b 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "ringcentral/psr7": "^1.2" }, "require-dev": { - "phpunit/phpunit": "^5.0 || ^4.8", + "phpunit/phpunit": "^7.0 || ^5.0 || ^4.8", "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3", "clue/block-react": "^1.1" } diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index 074792d..cac2c19 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -97,6 +97,7 @@ public function testCancelWhileConnectingShouldNotCreateGarbageCycles() $proxy = new ProxyConnector('google.com', $this->dnsConnector); gc_collect_cycles(); + gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on $promise = $proxy->connect('google.com:80'); $promise->cancel(); @@ -104,4 +105,17 @@ public function testCancelWhileConnectingShouldNotCreateGarbageCycles() $this->assertEquals(0, gc_collect_cycles()); } + + public function setExpectedException($exception, $message = '', $code = 0) + { + if (method_exists($this, 'expectException')) { + $this->expectException($exception); + if ($message !== null) { + $this->expectExceptionMessage($message); + } + $this->expectExceptionCode($code); + } else { + parent::setExpectedException($exception, $message, $code); + } + } } From db88a8b03e988a68c577c5db7df20b7a1687ff37 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Fri, 29 May 2020 10:42:05 +0200 Subject: [PATCH 2/3] Add .gitattributes to exclude dev files from exports --- .gitattributes | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0925d33 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/examples/ export-ignore +/phpunit.xml.dist export-ignore +/tests/ export-ignore From 39031e4081236f3a83a1a5bd7b42996475d48cab Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Fri, 29 May 2020 10:55:29 +0200 Subject: [PATCH 3/3] Clean up test suite --- composer.json | 2 +- tests/AbstractTestCase.php | 15 ++++----------- tests/FunctionalTest.php | 2 +- tests/ProxyConnectorTest.php | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 4a7db4b..e0315eb 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "psr-4": { "Clue\\React\\HttpProxy\\": "src/" } }, "autoload-dev": { - "psr-4": { "Tests\\Clue\\React\\HttpProxy\\": "tests/" } + "psr-4": { "Clue\\Tests\\React\\HttpProxy\\": "tests/" } }, "require": { "php": ">=5.3", diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index a77a882..b145410 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -1,10 +1,10 @@ getMockBuilder('Tests\\Clue\\React\\HttpProxy\\CallableStub')->getMock(); - } -} - -class CallableStub -{ - public function __invoke() - { + return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock(); } } diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index cac2c19..f0b0a88 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -1,6 +1,6 @@