Skip to content

Commit

Permalink
minor #23 fix tests (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.x branch.

Discussion
----------

fix tests

Commits
-------

89d97c7 fix tests
  • Loading branch information
xabbuh committed Dec 9, 2019
2 parents c2bc211 + 89d97c7 commit 6e9f98c
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 65 deletions.
15 changes: 6 additions & 9 deletions tests/Api/AccountManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 7 additions & 10 deletions tests/Api/CloudManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Api/CloudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CloudTest extends TestCase
*/
private $cloud;

protected function setUp()
protected function setUp(): void
{
$this->createHttpClient();
$this->createTransformers();
Expand Down
10 changes: 5 additions & 5 deletions tests/Api/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <christian.flothmann@xabbuh.de>
Expand All @@ -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(
Expand Down Expand Up @@ -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';
Expand Down
10 changes: 5 additions & 5 deletions tests/Api/HttplugClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <christian.flothmann@xabbuh.de>
Expand All @@ -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);
Expand Down Expand Up @@ -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';
Expand Down
17 changes: 7 additions & 10 deletions tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class ApiTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
HttpClientDiscovery::prependStrategy('Http\Discovery\Strategy\MockClientStrategy');
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/Symfony/NormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class NormalizerTest extends TestCase
*/
private $normalizer;

protected function setUp()
protected function setUp(): void
{
$this->normalizer = new Normalizer();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/Symfony/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/Signer/PandaSignerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/Transformer/CloudTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class CloudTransformerTest extends TransformerTest
{
protected function setUp()
protected function setUp(): void
{
$this->transformer = new CloudTransformer();

Expand Down
2 changes: 1 addition & 1 deletion tests/Transformer/EncodingTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class EncodingTransformerTest extends TransformerTest
{
protected function setUp()
protected function setUp(): void
{
$this->transformer = new EncodingTransformer();

Expand Down
2 changes: 1 addition & 1 deletion tests/Transformer/NotificationsTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NotificationsTransformerTest extends TestCase
*/
private $transformer;

protected function setUp()
protected function setUp(): void
{
$this->transformer = new NotificationsTransformer();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Transformer/ProfileTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class ProfileTransformerTest extends TransformerTest
{
protected function setUp()
protected function setUp(): void
{
$this->transformer = new ProfileTransformer();

Expand Down
27 changes: 11 additions & 16 deletions tests/Transformer/TransformerRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion tests/Transformer/TransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Transformer/VideoTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class VideoTransformerTest extends TransformerTest
{
protected function setUp()
protected function setUp(): void
{
$this->transformer = new VideoTransformer();

Expand Down

0 comments on commit 6e9f98c

Please sign in to comment.