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.

HandlersocketiTest::testDelete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
use HSAL\HSAL;
4
5 View Code Duplication
class HandlersocketiTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
	public function testFetchArray()
8
	{
9
		$hs = new HSAL('localhost', 'hstest', ['driver' => HSAL::DRIVER_HANDLERSOCKETI]);
10
11
		$result = $hs->fetchArray('test2', ['id','name','cnt'], [HSAL::INDEX_PRIMARY => 3]);
12
13
		$this->assertTrue(is_array($result));
14
		$this->assertEquals(3, count($result));
15
		$this->assertEquals(3, $result[0]);
16
		$this->assertEquals('page 3', $result[1]);
17
		$this->assertEquals(0, $result[2]);
18
	}
19
20
	public function testFetchAssoc()
21
	{
22
		$hs = new HSAL('localhost', 'hstest', ['driver' => HSAL::DRIVER_HANDLERSOCKETI]);
23
24
		$result = $hs->fetchAssoc('test2', ['id','name','cnt'], [HSAL::INDEX_PRIMARY => 3]);
25
26
		$this->assertTrue(is_array($result));
27
		$this->assertEquals(3, count($result));
28
		$this->assertEquals(3, $result['id']);
29
		$this->assertEquals('page 3', $result['name']);
30
		$this->assertEquals(0, $result['cnt']);
31
	}
32
33
	public function testFetchColumn()
34
	{
35
		$hs = new HSAL('localhost', 'hstest', ['driver' => HSAL::DRIVER_HANDLERSOCKETI]);
36
37
		$result = $hs->fetchColumn('test2', 'name', [HSAL::INDEX_PRIMARY => 3]);
38
39
		$this->assertEquals('page 3', $result);
40
	}
41
42
	public function testFetchAll()
43
	{
44
		$hs = new HSAL('localhost', 'hstest', ['driver' => HSAL::DRIVER_HANDLERSOCKETI]);
45
46
		$result = $hs->fetchAll('test2', ['id', 'name'], [HSAL::INDEX_PRIMARY => 3], HSAL::OPERATOR_LESS_EQUAL);
47
48
		$this->assertTrue(is_array($result));
49
		$this->assertEquals(3, count($result));
50
51
		$this->assertEquals(3, $result[0]['id']);
52
		$this->assertEquals(1, $result[2]['id']);
53
		
54
		$this->assertEquals('page 3', $result[0]['name']);
55
		$this->assertEquals('page 1', $result[2]['name']);
56
	}
57
58
	public function testDelete()
59
	{
60
		$hs = new HSAL('localhost', 'hstest', ['driver' => HSAL::DRIVER_HANDLERSOCKETI]);
61
62
		$result = $hs->delete('test2', [HSAL::INDEX_PRIMARY => 3]);
63
64
		$this->assertTrue($result);
65
66
		$result = $hs->delete('test2', [HSAL::INDEX_PRIMARY => 3]);
67
68
		$this->assertFalse($result);
69
	}
70
71
	public function testInsert()
72
	{
73
		$hs = new HSAL('localhost', 'hstest', ['driver' => HSAL::DRIVER_HANDLERSOCKETI]);
74
75
		$result = $hs->insert('test2', ['id' => 3, 'name' => 'new page', 'cnt' => 0]);
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
76
77
		$result = $hs->fetchColumn('test2', 'name', [HSAL::INDEX_PRIMARY => 3]);
78
79
		$this->assertEquals('new page', $result);
80
	}
81
82
	public function testUpdate()
83
	{
84
		$hs = new HSAL('localhost', 'hstest', ['driver' => HSAL::DRIVER_HANDLERSOCKETI]);
85
86
		$result = $hs->update('test2', ['name' => 'updated page'], [HSAL::INDEX_PRIMARY => 3]);
87
88
		$this->assertTrue($result);
89
90
		$result = $hs->fetchColumn('test2', 'name', [HSAL::INDEX_PRIMARY => 3]);
91
92
		$this->assertEquals('updated page', $result);
93
	}
94
95
	public function testIncrement()
96
	{
97
		$hs = new HSAL('localhost', 'hstest', ['driver' => HSAL::DRIVER_HANDLERSOCKETI]);
98
99
		$result = $hs->increment('test2', 'cnt', [HSAL::INDEX_PRIMARY => 3]);
100
101
		$this->assertTrue($result);
102
103
		$result = $hs->fetchColumn('test2', 'cnt', [HSAL::INDEX_PRIMARY => 3]);
104
105
		$this->assertEquals(1, $result);
106
	}
107
108
	public function testDecrement()
109
	{
110
		$hs = new HSAL('localhost', 'hstest', ['driver' => HSAL::DRIVER_HANDLERSOCKETI]);
111
112
		$result = $hs->decrement('test2', 'cnt', [HSAL::INDEX_PRIMARY => 3]);
113
114
		$this->assertTrue($result);
115
116
		$result = $hs->fetchColumn('test2', 'cnt', [HSAL::INDEX_PRIMARY => 3]);
117
118
		$this->assertEquals(0, $result);
119
	}
120
121
}
122