diff --git a/tests/Api/AccountManagerTest.php b/tests/Api/AccountManagerTest.php index 5ef9778..c7320a3 100644 --- a/tests/Api/AccountManagerTest.php +++ b/tests/Api/AccountManagerTest.php @@ -34,31 +34,28 @@ public function testRegisterAccount() $this->assertSame($defaultAccount, $accountManager->getDefaultAccount()); } - /** - * @expectedException \InvalidArgumentException - */ public function testGetNonExistingDefaultAccount() { + $this->expectException(\InvalidArgumentException::class); + $account = new Account('', '', ''); $accountManager = new AccountManager('default-key'); $accountManager->registerAccount('the-key', $account); $accountManager->getDefaultAccount(); } - /** - * @expectedException \InvalidArgumentException - */ public function testGetNonExistingDefaultAccountWithEmptyAccountManager() { + $this->expectException(\InvalidArgumentException::class); + $accountManager = new AccountManager('default-key'); $accountManager->getDefaultAccount(); } - /** - * @expectedException \InvalidArgumentException - */ public function testGetNonExistingAccount() { + $this->expectException(\InvalidArgumentException::class); + $account = new Account('', '', ''); $accountManager = new AccountManager('default-key'); $accountManager->registerAccount('the-key', $account); diff --git a/tests/Api/CloudManagerTest.php b/tests/Api/CloudManagerTest.php index 2b5e000..b056638 100644 --- a/tests/Api/CloudManagerTest.php +++ b/tests/Api/CloudManagerTest.php @@ -34,7 +34,7 @@ class CloudManagerTest extends TestCase */ private $cloudManager; - protected function setUp() + protected function setUp(): void { $mockBuilder = $this->getMockBuilder('Xabbuh\PandaClient\Api\Cloud'); $mockBuilder->disableOriginalConstructor(); @@ -55,28 +55,25 @@ public function testRegisterCloud() $this->assertSame($this->cloud2, $this->cloudManager->getDefaultCloud()); } - /** - * @expectedException \InvalidArgumentException - */ public function testGetNonExistingDefaultCloud() { + $this->expectException(\InvalidArgumentException::class); + $this->cloudManager->registerCloud('the-key', $this->cloud1); $this->cloudManager->getDefaultCloud(); } - /** - * @expectedException \InvalidArgumentException - */ public function testGetNonExistingDefaultCloudWithEmptyCloudManager() { + $this->expectException(\InvalidArgumentException::class); + $this->cloudManager->getDefaultCloud(); } - /** - * @expectedException \InvalidArgumentException - */ public function testGetNonExistingCloud() { + $this->expectException(\InvalidArgumentException::class); + $this->cloudManager->registerCloud('the-key', $this->cloud1); $this->cloudManager->getCloud('another-key'); } diff --git a/tests/Api/CloudTest.php b/tests/Api/CloudTest.php index d840523..f1b3ad6 100644 --- a/tests/Api/CloudTest.php +++ b/tests/Api/CloudTest.php @@ -48,7 +48,7 @@ class CloudTest extends TestCase */ private $cloud; - protected function setUp() + protected function setUp(): void { $this->createHttpClient(); $this->createTransformers(); diff --git a/tests/Api/HttpClientTest.php b/tests/Api/HttpClientTest.php index 9599135..dfeaa7b 100644 --- a/tests/Api/HttpClientTest.php +++ b/tests/Api/HttpClientTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Xabbuh\PandaClient\Api\Account; use Xabbuh\PandaClient\Api\HttpClient; +use Xabbuh\PandaClient\Exception\ApiException; /** * @author Christian Flothmann @@ -29,7 +30,7 @@ class HttpClientTest extends TestCase private $guzzleClient; - protected function setUp() + protected function setUp(): void { $this->httpClient = new HttpClient(); $this->httpClient->setAccount(new Account( @@ -68,12 +69,11 @@ public function testPut() $this->httpClient->put('/foo'); } - /** - * @expectedException \Xabbuh\PandaClient\Exception\ApiException - * @expectedExceptionCode 208 - */ public function testApiException() { + $this->expectException(ApiException::class); + $this->expectExceptionCode(208); + $error = new \stdClass(); $error->error = 500; $error->message = 'error message'; diff --git a/tests/Api/HttplugClientTest.php b/tests/Api/HttplugClientTest.php index 7969a5b..48fa905 100644 --- a/tests/Api/HttplugClientTest.php +++ b/tests/Api/HttplugClientTest.php @@ -17,6 +17,7 @@ use Psr\Http\Message\RequestInterface; use Xabbuh\PandaClient\Api\Account; use Xabbuh\PandaClient\Api\HttplugClient; +use Xabbuh\PandaClient\Exception\ApiException; /** * @author Christian Flothmann @@ -34,7 +35,7 @@ class HttplugClientTest extends TestCase */ private $mockClient; - protected function setUp() + protected function setUp(): void { $this->mockClient = new Client(); $this->httpClient = new HttplugClient($this->mockClient); @@ -86,12 +87,11 @@ public function testPut() $this->assertRequestMethod('PUT'); } - /** - * @expectedException \Xabbuh\PandaClient\Exception\ApiException - * @expectedExceptionCode 208 - */ public function testApiException() { + $this->expectException(ApiException::class); + $this->expectExceptionCode(208); + $error = new \stdClass(); $error->error = 500; $error->message = 'error message'; diff --git a/tests/ApiTest.php b/tests/ApiTest.php index f1071d9..088d954 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -17,7 +17,7 @@ class ApiTest extends TestCase { - protected function setUp() + protected function setUp(): void { HttpClientDiscovery::prependStrategy('Http\Discovery\Strategy\MockClientStrategy'); } @@ -40,31 +40,28 @@ public function testDefaultApi() $this->assertEquals(1, count($cloudManager->getClouds())); } - /** - * @expectedException \InvalidArgumentException - */ public function testWithoutAccount() { + $this->expectException(\InvalidArgumentException::class); + $config = $this->createDefaultConfig(); unset($config['accounts']); new Api($config); } - /** - * @expectedException \InvalidArgumentException - */ public function testWithoutCloud() { + $this->expectException(\InvalidArgumentException::class); + $config = $this->createDefaultConfig(); unset($config['clouds']); new Api($config); } - /** - * @expectedException \InvalidArgumentException - */ public function testCloudWithoutAccount() { + $this->expectException(\InvalidArgumentException::class); + $config = $this->createDefaultConfig(); unset($config['clouds']['default']['account']); new Api($config); diff --git a/tests/Serializer/Symfony/NormalizerTest.php b/tests/Serializer/Symfony/NormalizerTest.php index f292dcd..1001bfd 100644 --- a/tests/Serializer/Symfony/NormalizerTest.php +++ b/tests/Serializer/Symfony/NormalizerTest.php @@ -21,7 +21,7 @@ class NormalizerTest extends TestCase */ private $normalizer; - protected function setUp() + protected function setUp(): void { $this->normalizer = new Normalizer(); } diff --git a/tests/Serializer/Symfony/SerializerTest.php b/tests/Serializer/Symfony/SerializerTest.php index 867aa3d..9872353 100644 --- a/tests/Serializer/Symfony/SerializerTest.php +++ b/tests/Serializer/Symfony/SerializerTest.php @@ -44,7 +44,7 @@ class SerializerTest extends TestCase */ private $videoSerializer; - protected function setUp() + protected function setUp(): void { $this->cloudSerializer = new Serializer(); $this->encodingSerializer = new Serializer(); diff --git a/tests/Signer/PandaSignerTest.php b/tests/Signer/PandaSignerTest.php index 8e612cc..243bdfd 100644 --- a/tests/Signer/PandaSignerTest.php +++ b/tests/Signer/PandaSignerTest.php @@ -25,7 +25,7 @@ class PandaSignerTest extends TestCase */ private $signer; - protected function setUp() + protected function setUp(): void { $cloudId = '123456789'; $account = new Account('abcdefgh', 'ijklmnop', 'api.pandastream.com'); diff --git a/tests/Transformer/CloudTransformerTest.php b/tests/Transformer/CloudTransformerTest.php index ef6e824..4eda874 100644 --- a/tests/Transformer/CloudTransformerTest.php +++ b/tests/Transformer/CloudTransformerTest.php @@ -18,7 +18,7 @@ */ class CloudTransformerTest extends TransformerTest { - protected function setUp() + protected function setUp(): void { $this->transformer = new CloudTransformer(); diff --git a/tests/Transformer/EncodingTransformerTest.php b/tests/Transformer/EncodingTransformerTest.php index c7a49e6..5bc275b 100644 --- a/tests/Transformer/EncodingTransformerTest.php +++ b/tests/Transformer/EncodingTransformerTest.php @@ -18,7 +18,7 @@ */ class EncodingTransformerTest extends TransformerTest { - protected function setUp() + protected function setUp(): void { $this->transformer = new EncodingTransformer(); diff --git a/tests/Transformer/NotificationsTransformerTest.php b/tests/Transformer/NotificationsTransformerTest.php index ac487d8..e47bf25 100644 --- a/tests/Transformer/NotificationsTransformerTest.php +++ b/tests/Transformer/NotificationsTransformerTest.php @@ -27,7 +27,7 @@ class NotificationsTransformerTest extends TestCase */ private $transformer; - protected function setUp() + protected function setUp(): void { $this->transformer = new NotificationsTransformer(); } diff --git a/tests/Transformer/ProfileTransformerTest.php b/tests/Transformer/ProfileTransformerTest.php index bb417c0..ff09451 100644 --- a/tests/Transformer/ProfileTransformerTest.php +++ b/tests/Transformer/ProfileTransformerTest.php @@ -18,7 +18,7 @@ */ class ProfileTransformerTest extends TransformerTest { - protected function setUp() + protected function setUp(): void { $this->transformer = new ProfileTransformer(); diff --git a/tests/Transformer/TransformerRegistryTest.php b/tests/Transformer/TransformerRegistryTest.php index 4eb3cc4..ff416a4 100644 --- a/tests/Transformer/TransformerRegistryTest.php +++ b/tests/Transformer/TransformerRegistryTest.php @@ -56,7 +56,7 @@ class TransformerRegistryTest extends TestCase */ private $videoTransformer; - protected function setUp() + protected function setUp(): void { $this->transformers = new TransformerRegistry(); $this->cloudTransformer = $this->getMockBuilder('Xabbuh\PandaClient\Transformer\CloudTransformerInterface')->getMock(); @@ -96,43 +96,38 @@ public function testGetTransformer() ); } - /** - * @expectedException \InvalidArgumentException - */ public function testInvalidArgumentExceptionWithoutCloudTransformer() { + $this->expectException(\InvalidArgumentException::class); + $this->transformers->getCloudTransformer(); } - /** - * @expectedException \InvalidArgumentException - */ public function testInvalidArgumentExceptionWithoutEncodingTransformer() { + $this->expectException(\InvalidArgumentException::class); + $this->transformers->getEncodingTransformer(); } - /** - * @expectedException \InvalidArgumentException - */ public function testInvalidArgumentExceptionWithoutNotificationsTransformer() { + $this->expectException(\InvalidArgumentException::class); + $this->transformers->getNotificationsTransformer(); } - /** - * @expectedException \InvalidArgumentException - */ public function testInvalidArgumentExceptionWithoutProfileTransformer() { + $this->expectException(\InvalidArgumentException::class); + $this->transformers->getProfileTransformer(); } - /** - * @expectedException \InvalidArgumentException - */ public function testInvalidArgumentExceptionWithoutVideoTransformer() { + $this->expectException(\InvalidArgumentException::class); + $this->transformers->getVideoTransformer(); } } diff --git a/tests/Transformer/TransformerTest.php b/tests/Transformer/TransformerTest.php index fca7458..28ea3b3 100644 --- a/tests/Transformer/TransformerTest.php +++ b/tests/Transformer/TransformerTest.php @@ -28,7 +28,7 @@ abstract class TransformerTest extends TestCase */ protected $serializer; - protected function setUp() + protected function setUp(): void { $this->createSerializer(); $this->transformer->setSerializer($this->serializer); diff --git a/tests/Transformer/VideoTransformerTest.php b/tests/Transformer/VideoTransformerTest.php index 6a8c811..e67a45a 100644 --- a/tests/Transformer/VideoTransformerTest.php +++ b/tests/Transformer/VideoTransformerTest.php @@ -18,7 +18,7 @@ */ class VideoTransformerTest extends TransformerTest { - protected function setUp() + protected function setUp(): void { $this->transformer = new VideoTransformer();