|
@@ 65-84 (lines=20) @@
|
| 62 |
|
$instance = new Packtpublr(['email' => self::EMAIL]); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
public function testLogin() |
| 66 |
|
{ |
| 67 |
|
$instance = new Packtpublr(['email' => '[email protected]', 'password' => 'Password123']); |
| 68 |
|
|
| 69 |
|
$client = Mockery::mock('GuzzleHttp\Client'); |
| 70 |
|
|
| 71 |
|
$body = Mockery::mock('stdClass'); |
| 72 |
|
$body->shouldReceive('__toString')->andReturn(''); |
| 73 |
|
|
| 74 |
|
$response = Mockery::mock('GuzzleHttp\Message\Response'); |
| 75 |
|
$response->shouldReceive('getStatusCode')->andReturn(self::HTTP_RESPONSE_SUCCESS); |
| 76 |
|
$response->shouldReceive('getHeaders')->andReturn($body); |
| 77 |
|
$response->shouldReceive('getBody')->andReturnSelf(); |
| 78 |
|
|
| 79 |
|
$client->shouldReceive('post')->andReturn($response); |
| 80 |
|
|
| 81 |
|
$instance->setHttpClient($client); |
| 82 |
|
|
| 83 |
|
$this->assertTrue($instance->login()); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
public function testLoginWithOptionalArguments() |
| 87 |
|
{ |
|
@@ 86-105 (lines=20) @@
|
| 83 |
|
$this->assertTrue($instance->login()); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
public function testLoginWithOptionalArguments() |
| 87 |
|
{ |
| 88 |
|
$instance = new Packtpublr(['email' => '[email protected]', 'password' => 'Password123']); |
| 89 |
|
|
| 90 |
|
$client = Mockery::mock('GuzzleHttp\Client'); |
| 91 |
|
|
| 92 |
|
$body = Mockery::mock('stdClass'); |
| 93 |
|
$body->shouldReceive('__toString')->andReturn(''); |
| 94 |
|
|
| 95 |
|
$response = Mockery::mock('GuzzleHttp\Message\Response'); |
| 96 |
|
$response->shouldReceive('getStatusCode')->andReturn(self::HTTP_RESPONSE_SUCCESS); |
| 97 |
|
$response->shouldReceive('getHeaders')->andReturn($body); |
| 98 |
|
$response->shouldReceive('getBody')->andReturnSelf(); |
| 99 |
|
|
| 100 |
|
$client->shouldReceive('post')->andReturn($response); |
| 101 |
|
|
| 102 |
|
$instance->setHttpClient($client); |
| 103 |
|
|
| 104 |
|
$this->assertTrue($instance->login('[email protected]', 'Password123')); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
public function testRedeem() |
| 108 |
|
{ |
|
@@ 154-173 (lines=20) @@
|
| 151 |
|
$this->assertTrue($instance->redeem()); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
public function testLogout() |
| 155 |
|
{ |
| 156 |
|
$instance = new Packtpublr(['email' => '[email protected]', 'password' => 'Password123']); |
| 157 |
|
|
| 158 |
|
$client = Mockery::mock('GuzzleHttp\Client'); |
| 159 |
|
|
| 160 |
|
$body = Mockery::mock('stdClass'); |
| 161 |
|
$body->shouldReceive('__toString')->andReturn(''); |
| 162 |
|
|
| 163 |
|
$response = Mockery::mock('GuzzleHttp\Message\Response'); |
| 164 |
|
$response->shouldReceive('getStatusCode')->andReturn(self::HTTP_RESPONSE_SUCCESS); |
| 165 |
|
$response->shouldReceive('getHeaders')->andReturn([]); |
| 166 |
|
$response->shouldReceive('getBody')->andReturn($body); |
| 167 |
|
|
| 168 |
|
$client->shouldReceive('get')->andReturn($response); |
| 169 |
|
|
| 170 |
|
$instance->setHttpClient($client); |
| 171 |
|
|
| 172 |
|
$this->assertTrue($instance->logout()); |
| 173 |
|
} |
| 174 |
|
|
| 175 |
|
public function testRun() |
| 176 |
|
{ |