HooksTest::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 2
c 0
b 0
f 0
rs 10
cc 1
eloc 0
nc 1
nop 0
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);
0 ignored issues
show
Bug introduced by
$data of type array is incompatible with the type string expected by parameter $name of PHPUnit\Framework\TestSuite::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
        parent::__construct($name, /** @scrutinizer ignore-type */ $data, $dataName);
Loading history...
Unused Code introduced by
The call to PHPUnit\Framework\TestSuite::__construct() has too many arguments starting with $dataName. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        parent::/** @scrutinizer ignore-call */ 
34
                __construct($name, $data, $dataName);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
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(): void
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);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not exist on Test\FlexiPeeHP\HooksTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
        $this->/** @scrutinizer ignore-call */ 
56
               assertTrue($result);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
        $result2       = $this->object->register($this->testHookName);
57
        $this->assertFalse($result2);
0 ignored issues
show
Bug introduced by
The method assertFalse() does not exist on Test\FlexiPeeHP\HooksTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
        $this->/** @scrutinizer ignore-call */ 
58
               assertFalse($result2);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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);
0 ignored issues
show
Bug introduced by
The method assertArrayHasKey() does not exist on Test\FlexiPeeHP\HooksTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

67
        $this->/** @scrutinizer ignore-call */ 
68
               assertArrayHasKey(0, $flexidata);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->object->recordExists() targeting FlexiPeeHP\Hooks::recordExists() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
The method assertNull() does not exist on Test\FlexiPeeHP\HooksTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

77
        $this->/** @scrutinizer ignore-call */ 
78
               assertNull($this->object->recordExists());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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(end($hooks)['id']));
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(): void
104
    {
105
        
106
    }
107
}
108