QueryVarIntTest::testVarIntColumn()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace evseevnn\Cassandra\Tests;
4
5
use evseevnn\Cassandra;
6
7
class QueryVarIntTest extends Setup\QueryTestCase
8
{
9
10
		public function testVarIntColumn()
11
		{
12
				self::$connection->query('CREATE TABLE VarIntTest (foo varint PRIMARY KEY, bar varint, realybigint varint)');
13
				self::$connection->query(
14
						'INSERT INTO VarIntTest (foo, bar, realybigint) VALUES (:foo, :bar, :realybigint)',
15
						['foo' => '2', 'bar' => '52', 'realybigint' => '14156250080000000000003002']
16
				);
17
				$result = self::$connection->query('SELECT * FROM VarIntTest WHERE foo = :foo', ['foo' => '2']);
18
				$this->assertEquals('52', $result[0]['bar']);
19
				$this->assertEquals('2', $result[0]['foo']);
20
				$this->assertEquals('14156250080000000000003002', $result[0]['realybigint']);
21
		}
22
23
		public function testVarIntMap()
24
		{
25
				self::$connection->query('CREATE TABLE VarIntMapTest (foo varint PRIMARY KEY, bar map<varint,varint>)');
26
				self::$connection->query(
27
						'INSERT INTO VarIntMapTest (foo, bar) VALUES (:foo, :bar)',
28
						['foo' => '2', 'bar' => ['52' => '25']]
29
				);
30
				$result = self::$connection->query('SELECT * FROM VarIntMapTest WHERE foo = :foo', ['foo' => '2']);
31
				$this->assertEquals(['52' => '25'], $result[0]['bar']);
32
				$this->assertEquals('2', $result[0]['foo']);
33
34
				self::$connection->query(
35
						'INSERT INTO VarIntMapTest (foo, bar) VALUES (:foo, :bar)',
36
						['foo' => '22', 'bar' => ['522' => '14156250080000000000003002']]
37
				);
38
				$result = self::$connection->query('SELECT * FROM VarIntMapTest WHERE foo = :foo', ['foo' => '22']);
39
				$this->assertEquals(['522' => '14156250080000000000003002'], $result[0]['bar']);
40
				$this->assertEquals('22', $result[0]['foo']);
41
		}
42
43 View Code Duplication
		public function testVarIntSet()
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...
44
		{
45
				self::$connection->query('CREATE TABLE VarIntSetTest (foo varint PRIMARY KEY, bar set<varint>)');
46
				self::$connection->query(
47
						'INSERT INTO VarIntSetTest (foo, bar) VALUES (:foo, :bar)',
48
						['foo' => '2', 'bar' => ['25', '14156250080000000000003002', '52']]
49
				);
50
				$result = self::$connection->query('SELECT * FROM VarIntSetTest WHERE foo = :foo', ['foo' => '2']);
51
				$this->assertEquals(['25', '52', '14156250080000000000003002'], $result[0]['bar']);
52
				$this->assertEquals('2', $result[0]['foo']);
53
				//according to Spec, this should always be returned alphabetically.
54
				self::$connection->query(
55
						'INSERT INTO VarIntSetTest (foo, bar) VALUES (:foo, :bar)',
56
						['foo' => '22', 'bar' => ['52', '14156250080000000000003002', '25']]
57
				);
58
				$result = self::$connection->query('SELECT * FROM VarIntSetTest WHERE foo = :foo', ['foo' => '22']);
59
				$this->assertEquals(['25', '52', '14156250080000000000003002'], $result[0]['bar']);
60
		}
61
62 View Code Duplication
		public function testVarIntList()
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...
63
		{
64
				self::$connection->query('CREATE TABLE VarIntListTest (foo varint PRIMARY KEY, bar list<varint>)');
65
				self::$connection->query(
66
						'INSERT INTO VarIntListTest (foo, bar) VALUES (:foo, :bar)',
67
						['foo' => '2', 'bar' => ['52', '25', '14156250080000000000003002']]
68
				);
69
				$result = self::$connection->query('SELECT * FROM VarIntListTest WHERE foo = :foo', ['foo' => '2']);
70
				$this->assertEquals(['52', '25', '14156250080000000000003002'], $result[0]['bar']);
71
				$this->assertEquals('2', $result[0]['foo']);
72
				//according to Spec, this should be returned in index order
73
				self::$connection->query(
74
						'INSERT INTO VarIntListTest (foo, bar) VALUES (:foo, :bar)',
75
						['foo' => '22', 'bar' => ['25', '52', '14156250080000000000003002']]
76
				);
77
				$result = self::$connection->query('SELECT * FROM VarIntListTest WHERE foo = :foo', ['foo' => '22']);
78
				$this->assertEquals(['25', '52', '14156250080000000000003002'], $result[0]['bar']);
79
		}
80
81
}