Skip to content

Commit 88edd27

Browse files
authored
Merge pull request #136 from peterdevpl/php8
PHP 8 and PHPUnit 9 support
2 parents 2c57323 + d760c2e commit 88edd27

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ matrix:
1313
- php: 7.2
1414
- php: 7.3
1515
- php: 7.4
16+
- php: 8.0
1617

1718
cache:
1819
directories:

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
}
2222
},
2323
"require": {
24-
"php": "^7.1.3",
24+
"php": "^7.1.3 || ^8.0",
2525
"florianv/exchanger": "^2.0"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^7.5",
28+
"phpunit/phpunit": "^7 || ^8 || ^9",
2929
"php-http/mock-client": "^1.0",
3030
"php-http/message": "^1.7",
3131
"nyholm/psr7": "^1.0"

tests/BuilderTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BuilderTest extends TestCase
2828
*/
2929
private $builder;
3030

31-
protected function setUp()
31+
protected function setUp(): void
3232
{
3333
parent::setUp();
3434

@@ -56,12 +56,12 @@ public function testBuildMultipleServicesAdded()
5656
$this->assertInstanceOf(Swap::class, $this->builder->build());
5757
}
5858

59-
/**
60-
* @expectedException \LogicException
61-
* @expectedExceptionMessage Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface
62-
*/
6359
public function testUseInvalidClient()
6460
{
61+
$this->expectException(\LogicException::class);
62+
$expectedExceptionMessage = 'Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface';
63+
$this->expectExceptionMessage($expectedExceptionMessage);
64+
6565
$builder = new Builder();
6666
$builder->useHttpClient(new \stdClass());
6767
}

tests/Service/FactoryTest.php

+14-13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Exchanger\Service\Xignite;
2929
use Exchanger\Service\RussianCentralBank;
3030
use Exchanger\Service\XchangeApi;
31+
use Http\Discovery\NotFoundException;
3132
use Http\Mock\Client;
3233
use PHPUnit\Framework\TestCase;
3334
use Swap\Service\Factory;
@@ -62,7 +63,7 @@ public function servicesProvider()
6263
['xignite', Xignite::class, ['token' => 'token']],
6364
['russian_central_bank', RussianCentralBank::class],
6465
['cryptonator', Cryptonator::class],
65-
['xchangeapi', XchangeApi::class, ['api-key' => 'api-key']]
66+
['xchangeapi', XchangeApi::class, ['api-key' => 'api-key']],
6667
];
6768
}
6869

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

90-
/**
91-
* @expectedException \LogicException
92-
* @expectedExceptionMessage Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface
93-
*/
9491
public function testConstructInvalidClient()
9592
{
93+
$this->expectException(\LogicException::class);
94+
$expectedExceptionMessage = 'Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface';
95+
$this->expectExceptionMessage($expectedExceptionMessage);
96+
9697
$factory = new Factory(new \stdClass());
9798
}
9899

99-
/**
100-
* @expectedException \Http\Discovery\NotFoundException
101-
* @expectedExceptionMessage No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation"
102-
*/
103100
public function testWithNullAsClient()
104101
{
102+
$this->expectException(NotFoundException::class);
103+
$expectedExceptionMessage = 'No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation"';
104+
$this->expectExceptionMessage($expectedExceptionMessage);
105+
105106
$factory = new Factory();
106107
}
107108

108-
/**
109-
* @expectedException \LogicException
110-
* @expectedExceptionMessage Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface
111-
*/
112109
public function testSetInvalidClient()
113110
{
111+
$this->expectException(\LogicException::class);
112+
$expectedExceptionMessage = 'Client must be an instance of Http\Client\HttpClient or Psr\Http\Client\ClientInterface';
113+
$this->expectExceptionMessage($expectedExceptionMessage);
114+
114115
$factory = new Factory(new Client());
115116
$factory->setHttpClient(new \stdClass());
116117
}

0 commit comments

Comments
 (0)