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 FlexiBeeTest |
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
|
|
|
$this->changes = new Changes(); |
32
|
|
|
$this->changes->enable(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @covers FlexiPeeHP\Hooks::register |
37
|
|
|
*/ |
38
|
|
|
public function testRegister() |
39
|
|
|
{ |
40
|
|
|
$this->object->setDataValue('skipUrlTest', 'true'); |
41
|
|
|
$result = $this->object->register('http://lms.vyvojar.spoje.net/webhook.php'); |
42
|
|
|
$this->assertEmpty($result); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @covers FlexiPeeHP\FlexiBee::getFlexiData |
47
|
|
|
*/ |
48
|
|
|
public function testGetFlexiData() |
49
|
|
|
{ |
50
|
|
|
$flexidata = $this->object->getFlexiData(); |
51
|
|
|
$this->assertArrayHasKey(0, $flexidata); |
52
|
|
|
$this->assertArrayHasKey('id', $flexidata[0]); |
53
|
|
|
/* Zde nefunguje vyhledávání ? |
|
|
|
|
54
|
|
|
$filtrered = $this->object->getFlexiData(null, |
55
|
|
|
key($flexidata[0])." = ".current($flexidata[0])); |
56
|
|
|
$this->assertArrayHasKey(0, $filtrered); |
57
|
|
|
$this->assertArrayHasKey('id', $filtrered[0]); |
58
|
|
|
*/ |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @covers FlexiPeeHP\Hooks::unregister |
63
|
|
|
*/ |
64
|
|
|
public function testUnregister() |
65
|
|
|
{ |
66
|
|
|
$hooks = $this->object->getAllFromFlexibee(); |
67
|
|
|
$this->assertTrue($this->object->unregister(current(end($hooks)))); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Disable ChangesAPI |
72
|
|
|
*/ |
73
|
|
|
protected function tearDown() |
74
|
|
|
{ |
75
|
|
|
$this->changes->disable(); |
76
|
|
|
} |
77
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.