|
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
|
|
|
* Onetime Hook for tests |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
public $testHookName = null; |
|
29
|
|
|
|
|
30
|
|
|
public function __construct($name = null, array $data = array(), |
|
31
|
|
|
$dataName = '') |
|
32
|
|
|
{ |
|
33
|
|
|
parent::__construct($name, $data, $dataName); |
|
34
|
|
|
$this->testHookName = 'http://localhost/'.\Ease\Sand::randomString().'webhook.php'; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Sets up the fixture, for example, opens a network connection. |
|
39
|
|
|
* This method is called before a test is executed. |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function setUp() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->object = new Hooks(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @covers FlexiPeeHP\Hooks::register |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testRegister() |
|
50
|
|
|
{ |
|
51
|
|
|
$this->changes = new Changes(); |
|
52
|
|
|
$this->changes->enable(); |
|
53
|
|
|
$this->object->setDataValue('skipUrlTest', 'true'); |
|
54
|
|
|
$result = $this->object->register($this->testHookName); |
|
55
|
|
|
$this->assertTrue($result); |
|
56
|
|
|
$result2 = $this->object->register($this->testHookName); |
|
57
|
|
|
$this->assertFalse($result2); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @covers FlexiPeeHP\Hooks::getFlexiData |
|
62
|
|
|
* @depends testRegister |
|
63
|
|
|
*/ |
|
64
|
|
|
public function testGetFlexiData() |
|
65
|
|
|
{ |
|
66
|
|
|
$flexidata = $this->object->getFlexiData(); |
|
67
|
|
|
$this->assertArrayHasKey(0, $flexidata); |
|
68
|
|
|
$this->assertArrayHasKey('id', $flexidata[0]); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @covers FlexiPeeHP\Hooks::recordExists |
|
73
|
|
|
* @depends testRegister |
|
74
|
|
|
*/ |
|
75
|
|
|
public function testRecordExists() |
|
76
|
|
|
{ |
|
77
|
|
|
$this->assertNull($this->object->recordExists()); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @covers FlexiPeeHP\Hooks::refreshWebHook |
|
82
|
|
|
* @depends testRegister |
|
83
|
|
|
*/ |
|
84
|
|
|
public function testRefreshWebHook() |
|
85
|
|
|
{ |
|
86
|
|
|
$hooks = $this->object->getAllFromFlexibee(); |
|
87
|
|
|
$this->assertTrue($this->object->refreshWebHook(current(end($hooks)))); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @covers FlexiPeeHP\Hooks::unregister |
|
92
|
|
|
* @depends testRegister |
|
93
|
|
|
*/ |
|
94
|
|
|
public function testUnregister() |
|
95
|
|
|
{ |
|
96
|
|
|
$hooks = $this->object->getAllFromFlexibee(); |
|
97
|
|
|
$this->assertTrue($this->object->unregister(current(end($hooks)))); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Disable ChangesAPI |
|
102
|
|
|
*/ |
|
103
|
|
|
protected function tearDown() |
|
104
|
|
|
{ |
|
105
|
|
|
|
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|