1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Test\FlexiPeeHP; |
4
|
|
|
|
5
|
|
|
use FlexiPeeHP\Hooks; |
6
|
|
|
use FlexiPeeHP\Changes; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-05-24 at 14:37:54. |
10
|
|
|
*/ |
11
|
|
|
class HooksTest extends FlexiBeeRWTest |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var Hooks |
15
|
|
|
*/ |
16
|
|
|
protected $object; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Changes API enabler/disabler |
20
|
|
|
* @var Changes |
21
|
|
|
*/ |
22
|
|
|
protected $changes; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Sets up the fixture, for example, opens a network connection. |
26
|
|
|
* This method is called before a test is executed. |
27
|
|
|
*/ |
28
|
|
|
protected function setUp() |
29
|
|
|
{ |
30
|
|
|
$this->object = new Hooks; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @covers FlexiPeeHP\Hooks::register |
35
|
|
|
*/ |
36
|
|
|
public function testRegister() |
37
|
|
|
{ |
38
|
|
|
$this->changes = new Changes(); |
39
|
|
|
$this->changes->enable(); |
40
|
|
|
$this->object->setDataValue('skipUrlTest', 'true'); |
41
|
|
|
$result = $this->object->register('http://localhost/webhook.php'); |
42
|
|
|
$this->assertTrue($result); |
43
|
|
|
$result2 = $this->object->register('http://localhost/webhook.php'); |
44
|
|
|
$this->assertFalse($result2); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @covers FlexiPeeHP\Hooks::getFlexiData |
49
|
|
|
* @depends testRegister |
50
|
|
|
*/ |
51
|
|
|
public function testGetFlexiData() |
52
|
|
|
{ |
53
|
|
|
$flexidata = $this->object->getFlexiData(); |
54
|
|
|
$this->assertArrayHasKey(0, $flexidata); |
55
|
|
|
$this->assertArrayHasKey('id', $flexidata[0]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @covers FlexiPeeHP\Hooks::recordExists |
60
|
|
|
* @depends testRegister |
61
|
|
|
*/ |
62
|
|
|
public function testRecordExists() |
63
|
|
|
{ |
64
|
|
|
$this->assertNull($this->object->recordExists()); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @covers FlexiPeeHP\Hooks::refresh |
69
|
|
|
* @depends testRegister |
70
|
|
|
*/ |
71
|
|
|
public function testRefresh() |
72
|
|
|
{ |
73
|
|
|
$hooks = $this->object->getAllFromFlexibee(); |
74
|
|
|
$this->assertTrue($this->object->refresh(current(end($hooks)))); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @covers FlexiPeeHP\Hooks::unregister |
79
|
|
|
* @depends testRegister |
80
|
|
|
*/ |
81
|
|
|
public function testUnregister() |
82
|
|
|
{ |
83
|
|
|
$hooks = $this->object->getAllFromFlexibee(); |
84
|
|
|
$this->assertTrue($this->object->unregister(current(end($hooks)))); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Disable ChangesAPI |
89
|
|
|
*/ |
90
|
|
|
protected function tearDown() |
91
|
|
|
{ |
92
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
} |
96
|
|
|
|