1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Gerrie package. |
4
|
|
|
* |
5
|
|
|
* (c) Andreas Grunwald <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Gerrie\Tests\Check; |
12
|
|
|
|
13
|
|
|
use Gerrie\Check\APIConnectionCheck; |
14
|
|
|
|
15
|
|
|
class APIConnectionCheckTest extends \PHPUnit_Framework_TestCase |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var \Gerrie\Check\CheckInterface |
19
|
|
|
*/ |
20
|
|
|
protected $checkInstance; |
21
|
|
|
|
22
|
|
|
public function setUp() |
23
|
|
|
{ |
24
|
|
|
$apiConnectionMock = $this->getDataServiceMock(); |
25
|
|
|
$this->checkInstance = new APIConnectionCheck($apiConnectionMock); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function tearDown() |
29
|
|
|
{ |
30
|
|
|
$this->checkInstance = null; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
protected function getDataServiceMock($getVersionReturnValue = '1.2.3') |
34
|
|
|
{ |
35
|
|
|
$apiConnectionMock = $this->getMock('Gerrie\API\DataService\DataServiceInterface'); |
36
|
|
|
$apiConnectionMock->expects($this->any()) |
37
|
|
|
->method('getVersion') |
38
|
|
|
->will($this->returnValue($getVersionReturnValue)); |
39
|
|
|
|
40
|
|
|
return $apiConnectionMock; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testCheckWithVersion() |
44
|
|
|
{ |
45
|
|
|
$this->assertTrue($this->checkInstance->check()); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testCheckWithoutVersion() |
49
|
|
|
{ |
50
|
|
|
$apiConnectionMock = $this->getDataServiceMock(''); |
51
|
|
|
$checkInstance = new APIConnectionCheck($apiConnectionMock); |
52
|
|
|
|
53
|
|
|
$this->assertFalse($checkInstance->check()); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testGetFailureMessage() |
57
|
|
|
{ |
58
|
|
|
$this->assertInternalType('string', $this->checkInstance->getFailureMessage()); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function testGetSuccessMessage() |
62
|
|
|
{ |
63
|
|
|
$this->assertInternalType('string', $this->checkInstance->getSuccessMessage()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function testIsOptional() |
67
|
|
|
{ |
68
|
|
|
$this->assertInternalType('bool', $this->checkInstance->isOptional()); |
69
|
|
|
} |
70
|
|
|
} |