|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace BeubiQA\tests\Unit; |
|
4
|
|
|
|
|
5
|
|
|
use BeubiQA\Application\Selenium; |
|
6
|
|
|
|
|
7
|
|
|
class StopperTest extends \PHPUnit_Framework_TestCase |
|
8
|
|
|
{ |
|
9
|
|
|
/** @var Selenium\SeleniumStopper */ |
|
10
|
|
|
private $stopper; |
|
11
|
|
|
|
|
12
|
|
|
public function setup() |
|
13
|
|
|
{ |
|
14
|
|
|
$this->httpClient = $this->getMockBuilder('GuzzleHttp\Client')->getMock(); |
|
15
|
|
|
$this->waiter = $this->getMockBuilder('BeubiQA\Application\Lib\ResponseWaitter') |
|
16
|
|
|
->disableOriginalConstructor() |
|
17
|
|
|
->getMock(); |
|
18
|
|
|
$this->seleniumOptions = $this->getMockBuilder('BeubiQA\Application\Selenium\Options\SeleniumStopOptions')->getMock(); |
|
19
|
|
|
$this->stopper = new Selenium\SeleniumStopper($this->seleniumOptions, $this->waiter, $this->httpClient); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @expectedException LogicException |
|
24
|
|
|
* @expectedExceptionMessage Port, Url, Shutdown Url, Shutdown Options, and Query are mandatory. |
|
25
|
|
|
*/ |
|
26
|
|
View Code Duplication |
public function testNoQueryThrowsException() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumUrl')->willReturn('not_empty'); |
|
29
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumPort')->willReturn('not_empty'); |
|
30
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumShutdownUrl')->willReturn('not_empty'); |
|
31
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumShutDownOptions')->willReturn('not_empty'); |
|
32
|
|
|
$this->stopper->stop(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @expectedException LogicException |
|
37
|
|
|
* @expectedExceptionMessage Port, Url, Shutdown Url, Shutdown Options, and Query are mandatory. |
|
38
|
|
|
*/ |
|
39
|
|
View Code Duplication |
public function testNoUrlThrowsException() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumQuery')->willReturn('not_empty'); |
|
42
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumPort')->willReturn('not_empty'); |
|
43
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumShutdownUrl')->willReturn('not_empty'); |
|
44
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumShutDownOptions')->willReturn('not_empty'); |
|
45
|
|
|
$this->stopper->stop(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @expectedException LogicException |
|
50
|
|
|
* @expectedExceptionMessage Port, Url, Shutdown Url, Shutdown Options, and Query are mandatory. |
|
51
|
|
|
*/ |
|
52
|
|
View Code Duplication |
public function testNoPortThrowsException() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumQuery')->willReturn('not_empty'); |
|
55
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumUrl')->willReturn('not_empty'); |
|
56
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumShutdownUrl')->willReturn('not_empty'); |
|
57
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumShutDownOptions')->willReturn('not_empty'); |
|
58
|
|
|
$this->stopper->stop(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @expectedException LogicException |
|
63
|
|
|
* @expectedExceptionMessage Port, Url, Shutdown Url, Shutdown Options, and Query are mandatory. |
|
64
|
|
|
*/ |
|
65
|
|
View Code Duplication |
public function testNoShutdownOptionsThrowsException() |
|
66
|
|
|
{ |
|
67
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumPort')->willReturn('not_empty'); |
|
68
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumQuery')->willReturn('not_empty'); |
|
69
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumUrl')->willReturn('not_empty'); |
|
70
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumShutdownUrl')->willReturn('not_empty'); |
|
71
|
|
|
$this->stopper->stop(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function testStopperStops() |
|
75
|
|
|
{ |
|
76
|
|
|
$shutUrl = 'shutUrl'; |
|
77
|
|
|
$shutOptions = 'shutOptions'; |
|
78
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumQuery')->willReturn('not_empty'); |
|
79
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumUrl')->willReturn('not_empty'); |
|
80
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumPort')->willReturn('not_empty'); |
|
81
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumShutdownUrl')->willReturn($shutUrl); |
|
82
|
|
|
$this->seleniumOptions->expects($this->any())->method('getSeleniumShutDownOptions')->willReturn($shutOptions); |
|
83
|
|
|
|
|
84
|
|
|
$this->httpClient->expects($this->any())->method('get')->with('shutUrl', 'shutOptions'); |
|
85
|
|
|
|
|
86
|
|
|
$this->stopper->stop(); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|