GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SimpleWorkflowEntryTest::testSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: keanor
5
 * Date: 23.10.15
6
 * Time: 20:20
7
 */
8
namespace OldTown\Workflow\PhpUnitTest\Spi;
9
10
use OldTown\Workflow\Spi\SimpleWorkflowEntry;
11
use PHPUnit_Framework_TestCase as TestCase;
12
13
/**
14
 * Модульный тест для класса \OldTown\Workflow\Spi\SimpleWorkflowEntry
15
 *
16
 * @package OldTown\Workflow\PhpUnitTest\Spi
17
 */
18
class SimpleWorkflowEntryTest extends TestCase
19
{
20
    /**
21
     * Тестирование конструктора
22
     */
23
    public function testSetPropertiesViaConstructor()
24
    {
25
        $entry = new SimpleWorkflowEntry(1, 'wf.xml', 2);
26
27
        $refPropId = new \ReflectionProperty(SimpleWorkflowEntry::class, 'id');
28
        $refPropId->setAccessible(true);
29
        $this->assertEquals(1, $refPropId->getValue($entry));
30
31
        $refPropState = new \ReflectionProperty(SimpleWorkflowEntry::class, 'state');
32
        $refPropState->setAccessible(true);
33
        $this->assertEquals(2, $refPropState->getValue($entry));
34
35
        $refPropWfName = new \ReflectionProperty(SimpleWorkflowEntry::class, 'workflowName');
36
        $refPropWfName->setAccessible(true);
37
        $this->assertEquals('wf.xml', $refPropWfName->getValue($entry));
38
    }
39
40
    public function testGetId()
41
    {
42
        $entry = new SimpleWorkflowEntry(123, 'wf.xml', 2);
43
        $this->assertEquals(123, $entry->getId());
44
45
        $entry = new SimpleWorkflowEntry('asdasd', 'wf.xml', 2);
46
        $this->assertEquals(0, $entry->getId());
47
    }
48
49
    public function testSetCorrectId()
50
    {
51
        $entry = new SimpleWorkflowEntry(null, null, null);
52
        $this->assertEquals(0, $entry->getId());
53
54
        $entry->setId(254);
55
        $this->assertEquals(254, $entry->getId());
56
    }
57
58
    /**
59
     * @expectedException \OldTown\Workflow\Exception\ArgumentNotNumericException
60
     */
61
    public function testSetIncorrectId()
62
    {
63
        $entry = new SimpleWorkflowEntry(null, null, null);
64
        $entry->setId('nonumeric');
65
    }
66
67
    public function testGetInitialized()
68
    {
69
        $entry = new SimpleWorkflowEntry(null, null, null);
70
        $this->assertNull($entry->isInitialized()); // Это наверное косяк :)
71
72
        $refPropInit = new \ReflectionProperty(SimpleWorkflowEntry::class, 'initialized');
73
        $refPropInit->setAccessible(true);
74
        $refPropInit->setValue($entry, true);
75
        $this->assertTrue($entry->isInitialized());
76
77
        $refPropInit->setValue($entry, 'asasd');
78
        $this->assertEquals('asasd', $entry->isInitialized());
79
80
        $refPropInit->setValue($entry, 0);
81
        $this->assertEquals(0, $entry->isInitialized());
82
    }
83
84
    public function testSetInitialized()
85
    {
86
        $entry = new SimpleWorkflowEntry(null, null, null);
87
        $this->assertNull($entry->isInitialized()); // Это наверное косяк :)
88
89
        $refPropInit = new \ReflectionProperty(SimpleWorkflowEntry::class, 'initialized');
90
        $refPropInit->setAccessible(true);
91
92
        $entry->setInitialized(true);
93
        $this->assertTrue($refPropInit->getValue($entry));
94
95
        $entry->setInitialized('asdasd');
0 ignored issues
show
Documentation introduced by
'asdasd' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
96
        $this->assertTrue($refPropInit->getValue($entry));
97
98
        $entry->setInitialized(false);
99
        $this->assertFalse($refPropInit->getValue($entry));
100
101
        $entry->setInitialized('');
0 ignored issues
show
Documentation introduced by
'' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
102
        $this->assertFalse($refPropInit->getValue($entry));
103
    }
104
105 View Code Duplication
    public function testGetState()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
106
    {
107
        $entry = new SimpleWorkflowEntry(null, null, 2);
108
        $this->assertEquals(2, $entry->getState());
109
110
        $entry = new SimpleWorkflowEntry(null, null, 99);
111
        $this->assertEquals(99, $entry->getState());
112
    }
113
114
    public function testSetCorrectState()
115
    {
116
        $entry = new SimpleWorkflowEntry(null, null, null);
117
        $this->assertEquals(0, $entry->getState());
118
119
        $entry->setState(254);
120
        $this->assertEquals(254, $entry->getState());
121
    }
122
123
    /**
124
     * @expectedException \OldTown\Workflow\Exception\ArgumentNotNumericException
125
     */
126
    public function testSetIncorrectState()
127
    {
128
        $entry = new SimpleWorkflowEntry(null, null, null);
129
        $entry->setState('nonumeric');
130
    }
131
132 View Code Duplication
    public function testGetWorkflowName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
133
    {
134
        $entry = new SimpleWorkflowEntry(null, null, null);
135
        $this->assertEquals('', $entry->getWorkflowName());
136
137
        $entry = new SimpleWorkflowEntry(null, 'asdadssd', null);
138
        $this->assertEquals('asdadssd', $entry->getWorkflowName());
139
    }
140
141
    public function testSetWorkflowName()
142
    {
143
        $entry = new SimpleWorkflowEntry(null, null, null);
144
145
        $refPropInit = new \ReflectionProperty(SimpleWorkflowEntry::class, 'workflowName');
146
        $refPropInit->setAccessible(true);
147
148
        $this->assertEquals('', $refPropInit->getValue($entry));
149
150
        $entry->setWorkflowName('asdadsdas');
151
        $this->assertEquals('asdadsdas', $refPropInit->getValue($entry));
152
153
        $entry->setWorkflowName('wwww');
154
        $this->assertEquals('wwww', $refPropInit->getValue($entry));
155
    }
156
157 View Code Duplication
    public function testSerialize()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
158
    {
159
        set_error_handler(function () {
160
            TestCase::assertEquals('Метод OldTown\Workflow\Spi\SimpleWorkflowEntry::serialize класса OldTown\Workflow\Spi\SimpleWorkflowEntry требуется реализовать', func_get_arg(1));
161
        });
162
        $entry = new SimpleWorkflowEntry(null, null, null);
163
        $entry->serialize();
164
    }
165
166 View Code Duplication
    public function testUnserialize()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
167
    {
168
        set_error_handler(function () {
169
            TestCase::assertEquals('Метод OldTown\Workflow\Spi\SimpleWorkflowEntry::unserialize класса OldTown\Workflow\Spi\SimpleWorkflowEntry требуется реализовать', func_get_arg(1));
170
        });
171
        $entry = new SimpleWorkflowEntry(null, null, null);
172
        $entry->unserialize(null);
173
    }
174
}
175