diff --git a/.travis.yml b/.travis.yml index 08f43fb4..1d80a39b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 7.0 - 7.1 - 7.2 + - 7.3 install: - composer install diff --git a/build/phpunit.xml.dist b/build/phpunit.xml.dist index 8bcc3780..ac00eac0 100644 --- a/build/phpunit.xml.dist +++ b/build/phpunit.xml.dist @@ -20,7 +20,6 @@ - diff --git a/composer.json b/composer.json index 98259175..11dc7211 100644 --- a/composer.json +++ b/composer.json @@ -39,10 +39,10 @@ "fabpot/goutte": "~1.0.4", "behat/mink-goutte-driver": "1.*", "phpmd/phpmd": "~2.1.3", - "phpunit/phpunit": "~4.8.35", + "phpunit/phpunit": "~5.7.9", "fzaninotto/faker": "~1.4.0", - "mikey179/vfsStream": "~1.4.0", - "squizlabs/php_codesniffer": "~1.5.5", + "mikey179/vfsstream": "~1.4.0", + "squizlabs/php_codesniffer": "~3.4", "satooshi/php-coveralls": "~0.6.1", "symfony/phpunit-bridge": "^4.0" }, diff --git a/src/Bitpay/AccessTokenInterface.php b/src/Bitpay/AccessTokenInterface.php index b701db3a..bd293ebb 100644 --- a/src/Bitpay/AccessTokenInterface.php +++ b/src/Bitpay/AccessTokenInterface.php @@ -1,6 +1,6 @@ orgs[] = $org; - } - - return $this; - } } diff --git a/src/Bitpay/ApplicationInterface.php b/src/Bitpay/ApplicationInterface.php index 63dbbee5..baa5de1d 100644 --- a/src/Bitpay/ApplicationInterface.php +++ b/src/Bitpay/ApplicationInterface.php @@ -1,6 +1,6 @@ 2) { throw new \Bitpay\Client\BitpayException('Incorrect price format or currency type.'); } - elseif ($decimalPrecision > 6) { + if ($decimalPrecision > 6) { throw new \Bitpay\Client\BitpayException('Incorrect price format or currency type.'); } } diff --git a/src/Bitpay/Client/ClientInterface.php b/src/Bitpay/Client/ClientInterface.php index 8d490582..bcde3aa0 100644 --- a/src/Bitpay/Client/ClientInterface.php +++ b/src/Bitpay/Client/ClientInterface.php @@ -1,6 +1,6 @@ setStatusCode($statusCode = $statusLine[2]); + $response->setStatusCode($statusCode = $statusLine[1]); continue; } diff --git a/src/Bitpay/Client/ResponseInterface.php b/src/Bitpay/Client/ResponseInterface.php index 11664d23..0dcb1dfd 100644 --- a/src/Bitpay/Client/ResponseInterface.php +++ b/src/Bitpay/Client/ResponseInterface.php @@ -1,6 +1,6 @@ getMessage()); } diff --git a/tests/Bitpay/ApplicationTest.php b/tests/Bitpay/ApplicationTest.php index 7cd700da..b1dc4580 100644 --- a/tests/Bitpay/ApplicationTest.php +++ b/tests/Bitpay/ApplicationTest.php @@ -52,19 +52,12 @@ public function testAddOrg() $this->assertNotNull($application); - $application->addOrg($this->getMockOrg()); - $this->assertInternalType('array', $application->getOrgs()); - $this->assertCount(1, $application->getOrgs()); + $this->assertCount(0, $application->getOrgs()); } private function getMockUser() { - return $this->getMock('Bitpay\UserInterface'); - } - - private function getMockOrg() - { - return $this->getMock('Bitpay\OrgInterface'); + return $this->createMock('Bitpay\UserInterface'); } } diff --git a/tests/Bitpay/BillTest.php b/tests/Bitpay/BillTest.php index d399b13c..2aaf293d 100644 --- a/tests/Bitpay/BillTest.php +++ b/tests/Bitpay/BillTest.php @@ -232,11 +232,11 @@ public function testSetArchived() private function getMockItem() { - return $this->getMock('Bitpay\ItemInterface'); + return $this->createMock('Bitpay\ItemInterface'); } private function getMockCurrency() { - return $this->getMock('Bitpay\CurrencyInterface'); + return $this->createMock('Bitpay\CurrencyInterface'); } } diff --git a/tests/Bitpay/Client/ClientTest.php b/tests/Bitpay/Client/ClientTest.php index 9cda4d40..7d34fa01 100644 --- a/tests/Bitpay/Client/ClientTest.php +++ b/tests/Bitpay/Client/ClientTest.php @@ -27,7 +27,7 @@ public function setUp() $this->client->setPublicKey($this->getMockPublicKey()); $this->client->setPrivateKey($this->getMockPrivateKey()); $adapter = $this->getMockAdapter(); - $adapter->method('sendRequest')->willReturn($this->getMock('Bitpay\Client\ResponseInterface')); + $adapter->method('sendRequest')->willReturn($this->createMock('Bitpay\Client\ResponseInterface')); $this->client->setAdapter($adapter); } @@ -204,7 +204,7 @@ public function testCreateInvoice() } /** - * @expectedException Exception + * @expectedException \Exception */ public function testCreateResponseWithException() { @@ -238,7 +238,7 @@ public function testCreateResponseWithException() } /** - * @expectedException Exception + * @expectedException \Exception */ public function testCreateInvoiceWithTooMuchPrecisionForAnythingButBitcoin() { @@ -268,7 +268,7 @@ public function testCreateInvoiceWithTooMuchPrecisionForAnythingButBitcoin() /** - * @expectedException Exception + * @expectedException \Exception */ public function testCreateInvoiceWithTooMuchPrecisionEvenForBitcoin() { @@ -315,7 +315,7 @@ public function testGetRequest() /** * @depends testGetRequest * @depends testGetResponse - * @expectedException Exception + * @expectedException \Exception */ public function testCreateInvoiceWithError() { @@ -346,7 +346,7 @@ public function testCreateInvoiceWithError() } /** - * @expectedException Exception + * @expectedException \Exception */ public function testGetCurrenciesWithException() { @@ -453,7 +453,7 @@ public function testCreateToken() } /** - * @expectedException Exception + * @expectedException \Exception */ public function testCreateTokenWithException() { @@ -496,7 +496,7 @@ public function testGetInvoice() } /** - * @expectedException Exception + * @expectedException \Exception */ public function testGetInvoiceException() { @@ -528,7 +528,7 @@ public function testGetPayout() } /** - * @expectedException Exception + * @expectedException \Exception */ public function testGetPayoutException() { @@ -717,26 +717,26 @@ private function getMockCurrency() private function getMockToken() { - return $this->getMock('Bitpay\TokenInterface'); + return $this->createMock('Bitpay\TokenInterface'); } private function getMockAdapter() { - return $this->getMock('Bitpay\Client\Adapter\AdapterInterface'); + return $this->createMock('Bitpay\Client\Adapter\AdapterInterface'); } private function getMockPublicKey() { - return $this->getMock('Bitpay\PublicKey'); + return $this->createMock('Bitpay\PublicKey'); } private function getMockPrivateKey() { - return $this->getMock('Bitpay\PrivateKey'); + return $this->createMock('Bitpay\PrivateKey'); } private function getMockResponse() { - return $this->getMock('Bitpay\Client\ResponseInterface'); + return $this->createMock('Bitpay\Client\ResponseInterface'); } } diff --git a/tests/Bitpay/Client/ResponseTest.php b/tests/Bitpay/Client/ResponseTest.php index 40242cce..29e9e3d5 100644 --- a/tests/Bitpay/Client/ResponseTest.php +++ b/tests/Bitpay/Client/ResponseTest.php @@ -51,6 +51,9 @@ public function testCreateFromRawResponse() { $response = Response::createFromRawResponse($this->getTestResponse200()); $this->assertSame(200, $response->getStatusCode()); + + $response = Response::createFromRawResponse($this->getTestHttp2Response200()); + $this->assertSame(200, $response->getStatusCode()); } /** @@ -70,6 +73,18 @@ private function getTestResponse200() HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 +{ + "response": "example" +} +EOF; + } + + private function getTestHttp2Response200() + { + return <<assertEquals(gmp_strval(gmp_pow($a, $a)), $math->pow($a, $a)); - $this->assertEquals(gmp_strval(gmp_pow($b, $b)), $math->pow($b, $b)); - $this->assertEquals(gmp_strval(gmp_pow($c, $c)), $math->pow($c, $c)); + $this->assertEquals(gmp_strval(gmp_pow($b, $a)), $math->pow($b, $a)); + $this->assertEquals(gmp_strval(gmp_pow($c, $a)), $math->pow($c, $a)); $this->assertEquals(1, $math->pow(1, 1)); } diff --git a/tests/Bitpay/Math/MathTest.php b/tests/Bitpay/Math/MathTest.php index 0bdb5f4a..f4c24c61 100644 --- a/tests/Bitpay/Math/MathTest.php +++ b/tests/Bitpay/Math/MathTest.php @@ -17,7 +17,7 @@ public function testIsEngineSet() { Math::setEngine(null); $this->assertNull(Math::getEngine()); - $engine = $this->getMock('Bitpay\Math\EngineInterface'); + $engine = $this->createMock('Bitpay\Math\EngineInterface'); Math::setEngine($engine); $this->assertInstanceOf('Bitpay\Math\EngineInterface', Math::getEngine()); } diff --git a/tests/Bitpay/PublicKeyTest.php b/tests/Bitpay/PublicKeyTest.php index 1a89b7e7..1519e447 100644 --- a/tests/Bitpay/PublicKeyTest.php +++ b/tests/Bitpay/PublicKeyTest.php @@ -236,7 +236,7 @@ public function testIsGenerated() private function getMockPrivateKey($hex = null) { $hex = ($hex === null) ? $this->hexKeys[0]['private'] : $hex; - $key = $this->getMock('Bitpay\PrivateKey'); + $key = $this->createMock('Bitpay\PrivateKey'); $key->method('isValid')->will($this->returnValue(true)); $key