QueryTextTest::testTextSet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 18
Ratio 100 %

Importance

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