Skip to content

Commit

Permalink
Merge pull request #136 from peterdevpl/php8
Browse files Browse the repository at this point in the history
PHP 8 and PHPUnit 9 support
  • Loading branch information
florianv authored Dec 28, 2020
2 parents 2c57323 + d760c2e commit 88edd27
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ matrix:
- php: 7.2
- php: 7.3
- php: 7.4
- php: 8.0

cache:
directories:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
}
},
"require": {
"php": "^7.1.3",
"php": "^7.1.3 || ^8.0",
"florianv/exchanger": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5",
"phpunit/phpunit": "^7 || ^8 || ^9",
"php-http/mock-client": "^1.0",
"php-http/message": "^1.7",
"nyholm/psr7": "^1.0"
Expand Down
10 changes: 5 additions & 5 deletions tests/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BuilderTest extends TestCase
*/
private $builder;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -56,12 +56,12 @@ public function testBuildMultipleServicesAdded()
$this->assertInstanceOf(Swap::class, $this->builder->build());
}

/**
* @expectedException \LogicException
* @expectedExceptionMessage Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface
*/
public function testUseInvalidClient()
{
$this->expectException(\LogicException::class);
$expectedExceptionMessage = 'Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface';
$this->expectExceptionMessage($expectedExceptionMessage);

$builder = new Builder();
$builder->useHttpClient(new \stdClass());
}
Expand Down
27 changes: 14 additions & 13 deletions tests/Service/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Exchanger\Service\Xignite;
use Exchanger\Service\RussianCentralBank;
use Exchanger\Service\XchangeApi;
use Http\Discovery\NotFoundException;
use Http\Mock\Client;
use PHPUnit\Framework\TestCase;
use Swap\Service\Factory;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function servicesProvider()
['xignite', Xignite::class, ['token' => 'token']],
['russian_central_bank', RussianCentralBank::class],
['cryptonator', Cryptonator::class],
['xchangeapi', XchangeApi::class, ['api-key' => 'api-key']]
['xchangeapi', XchangeApi::class, ['api-key' => 'api-key']],
];
}

Expand All @@ -87,30 +88,30 @@ public function testCustomServices()
$this->assertSame($service, $factory->create('baz'));
}

/**
* @expectedException \LogicException
* @expectedExceptionMessage Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface
*/
public function testConstructInvalidClient()
{
$this->expectException(\LogicException::class);
$expectedExceptionMessage = 'Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface';
$this->expectExceptionMessage($expectedExceptionMessage);

$factory = new Factory(new \stdClass());
}

/**
* @expectedException \Http\Discovery\NotFoundException
* @expectedExceptionMessage No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation"
*/
public function testWithNullAsClient()
{
$this->expectException(NotFoundException::class);
$expectedExceptionMessage = 'No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation"';
$this->expectExceptionMessage($expectedExceptionMessage);

$factory = new Factory();
}

/**
* @expectedException \LogicException
* @expectedExceptionMessage Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface
*/
public function testSetInvalidClient()
{
$this->expectException(\LogicException::class);
$expectedExceptionMessage = 'Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface';
$this->expectExceptionMessage($expectedExceptionMessage);

$factory = new Factory(new Client());
$factory->setHttpClient(new \stdClass());
}
Expand Down

0 comments on commit 88edd27

Please sign in to comment.