QueryUuidTest::testUuidMap()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Importance

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