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.
Completed
Push — master ( 66713b...da287b )
by Dmitry
06:13
created

HSPHPTest::testFetchColumn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
use HSAL\HSAL;
4
5
class HSPHPTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
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 View Code Duplication
	public function testFetchArray()
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...
8
	{
9
		$hs = new HSAL('localhost', 'hstest', HSAL::DRIVER_HSPHP);
10
11
		$result = $hs->fetchArray('test', ['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 View Code Duplication
	public function testFetchAssoc()
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...
21
	{
22
		$hs = new HSAL('localhost', 'hstest', HSAL::DRIVER_HSPHP);
23
24
		$result = $hs->fetchArray('test', ['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', HSAL::DRIVER_HSPHP);
36
37
		$result = $hs->fetchArray('test', 'name', [HSAL::INDEX_PRIMARY => 3]);
0 ignored issues
show
Documentation introduced by
'name' is of type string, but the function expects a array.

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...
38
39
		$this->assertEquals('page 3', $result);
40
	}
41
42
	public function testFetchAll()
43
	{
44
		$hs = new HSAL('localhost', 'hstest', HSAL::DRIVER_HSPHP);
45
46
		$result = $hs->fetchAll('test', ['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(1, $result[0]['id']);
52
		$this->assertEquals(3, $result[2]['id']);
53
		
54
		$this->assertEquals('page 1', $result[0]['name']);
55
		$this->assertEquals('page 3', $result[2]['name']);
56
	}
57
}
58