diff --git a/.gitattributes b/.gitattributes index 7c0fa03..7950037 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,8 @@ .gitattributes export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore +.styleci.yml export-ignore +.php_cs.yml export-ignore .travis.yml export-ignore CONDUCT.md export-ignore CONTRIBUTING.md export-ignore diff --git a/tests/BaseUnitTestCase.php b/tests/BaseUnitTestCase.php index 1557431..3a3c9e3 100644 --- a/tests/BaseUnitTestCase.php +++ b/tests/BaseUnitTestCase.php @@ -4,7 +4,6 @@ namespace Http\Client\Curl\Tests; -use Http\Client\Curl\PromiseCore; use Http\Discovery\MessageFactoryDiscovery; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; @@ -37,11 +36,11 @@ protected function tearDown() * Create new request. * * @param string $method - * @param mixed $uri + * @param mixed $uri * * @return RequestInterface */ - protected function createRequest($method, $uri) + protected function createRequest(string $method, $uri): RequestInterface { return MessageFactoryDiscovery::find()->createRequest($method, $uri); } @@ -51,18 +50,8 @@ protected function createRequest($method, $uri) * * @return ResponseInterface */ - protected function createResponse() + protected function createResponse(): ResponseInterface { return MessageFactoryDiscovery::find()->createResponse(); } - - /** - * Create PromiseCore mock. - * - * @return PromiseCore|\PHPUnit_Framework_MockObject_MockObject - */ - protected function createPromiseCore() - { - return $this->getMockBuilder(PromiseCore::class)->disableOriginalConstructor()->getMock(); - } } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 85ae402..13c6dcd 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -25,7 +25,7 @@ class ClientTest extends TestCase */ public function testExpectHeader() { - $client = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock(); + $client = $this->createMock(Client::class); $createHeaders = new \ReflectionMethod(Client::class, 'createHeaders'); $createHeaders->setAccessible(true); @@ -44,7 +44,7 @@ public function testExpectHeader() */ public function testWithNullPostFields() { - $client = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock(); + $client = $this->createMock(Client::class); $createHeaders = new \ReflectionMethod(Client::class, 'createHeaders'); $createHeaders->setAccessible(true); @@ -59,7 +59,7 @@ public function testWithNullPostFields() public function testRewindStream() { - $client = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock(); + $client = $this->createMock(Client::class); $bodyOptions = new \ReflectionMethod(Client::class, 'addRequestBodyOptions'); $bodyOptions->setAccessible(true); @@ -74,7 +74,7 @@ public function testRewindStream() public function testRewindLargeStream() { - $client = $this->getMockBuilder(Client::class)->disableOriginalConstructor()->getMock(); + $client = $this->createMock(Client::class); $bodyOptions = new \ReflectionMethod(Client::class, 'addRequestBodyOptions'); $bodyOptions->setAccessible(true); diff --git a/tests/CurlPromiseTest.php b/tests/CurlPromiseTest.php index 5c4ddf8..389262e 100644 --- a/tests/CurlPromiseTest.php +++ b/tests/CurlPromiseTest.php @@ -6,6 +6,7 @@ use Http\Client\Curl\CurlPromise; use Http\Client\Curl\MultiRunner; +use Http\Client\Curl\PromiseCore; use Http\Client\Exception\TransferException; use Http\Promise\Promise; @@ -21,10 +22,9 @@ class CurlPromiseTest extends BaseUnitTestCase */ public function testCoreCalls() { - $core = $this->createPromiseCore(); - $runner = $this->getMockBuilder(MultiRunner::class)->disableOriginalConstructor() - ->setMethods(['wait'])->getMock(); - /** @var MultiRunner|\PHPUnit_Framework_MockObject_MockObject $runner */ + $core = $this->createMock(PromiseCore::class); + $runner = $this->createMock(MultiRunner::class); + $promise = new CurlPromise($core, $runner); $onFulfill = function () { @@ -42,10 +42,9 @@ public function testCoreCalls() public function testCoreCallWaitFulfilled() { - $core = $this->createPromiseCore(); - $runner = $this->getMockBuilder(MultiRunner::class)->disableOriginalConstructor() - ->setMethods(['wait'])->getMock(); - /** @var MultiRunner|\PHPUnit_Framework_MockObject_MockObject $runner */ + $core = $this->createMock(PromiseCore::class); + $runner = $this->createMock(MultiRunner::class); + $promise = new CurlPromise($core, $runner); $runner->expects(static::once())->method('wait')->with($core); @@ -56,9 +55,9 @@ public function testCoreCallWaitFulfilled() public function testCoreCallWaitRejected() { - $core = $this->createPromiseCore(); - $runner = $this->getMockBuilder(MultiRunner::class)->disableOriginalConstructor()->getMock(); - /** @var MultiRunner|\PHPUnit_Framework_MockObject_MockObject $runner */ + $core = $this->createMock(PromiseCore::class); + $runner = $this->createMock(MultiRunner::class); + $promise = new CurlPromise($core, $runner); $runner->expects(static::once())->method('wait')->with($core); diff --git a/tests/HttpAsyncClientTestCase.php b/tests/HttpAsyncClientTestCase.php index 8a6f7f0..0b3f839 100644 --- a/tests/HttpAsyncClientTestCase.php +++ b/tests/HttpAsyncClientTestCase.php @@ -17,11 +17,8 @@ abstract class HttpAsyncClientTestCase extends HttpAsyncClientTest */ public function testAsyncSendRequest($method, $uri, array $headers, $body) { - if (defined('HHVM_VERSION')) { - static::markTestSkipped('This test can not run under HHVM'); - } if (null !== $body && in_array($method, ['GET', 'HEAD', 'TRACE'], true)) { - static::markTestSkipped('cURL can not send body using '.$method); + static::markTestSkipped('cURL can not send body using ' . $method); } parent::testAsyncSendRequest( $method, @@ -41,9 +38,6 @@ public function testSendAsyncRequestWithOutcome( array $headers, $body ) { - if (defined('HHVM_VERSION')) { - static::markTestSkipped('This test can not run under HHVM'); - } if (null !== $body) { static::markTestSkipped('cURL can not send body using GET'); } @@ -54,12 +48,4 @@ public function testSendAsyncRequestWithOutcome( $body ); } - - public function testSuccessiveCallMustUseResponseInterface() - { - if (defined('HHVM_VERSION')) { - static::markTestSkipped('This test can not run under HHVM'); - } - parent::testSuccessiveCallMustUseResponseInterface(); - } } diff --git a/tests/HttpClientTestCase.php b/tests/HttpClientTestCase.php index cea9e90..25ee940 100644 --- a/tests/HttpClientTestCase.php +++ b/tests/HttpClientTestCase.php @@ -26,9 +26,6 @@ abstract class HttpClientTestCase extends HttpClientTest */ public function testSendRequest($method, $uri, array $headers, $body) { - if (defined('HHVM_VERSION')) { - static::markTestSkipped('This test can not run under HHVM'); - } if (null !== $body && in_array($method, ['GET', 'HEAD', 'TRACE'], true)) { static::markTestSkipped('cURL can not send body using '.$method); } @@ -50,9 +47,6 @@ public function testSendRequestWithOutcome( array $headers, $body ) { - if (defined('HHVM_VERSION')) { - static::markTestSkipped('This test can not run under HHVM'); - } if (null !== $body) { static::markTestSkipped('cURL can not send body using GET'); }