-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathNegativeIntTest.php
More file actions
69 lines (61 loc) · 2.75 KB
/
NegativeIntTest.php
File metadata and controls
69 lines (61 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace evseevnn\Cassandra\Tests;
use evseevnn\Cassandra;
class QueryNegativeIntTest extends Setup\QueryTestCase
{
public function testIntRow()
{
self::$connection->query('CREATE TABLE IntTest (foo int PRIMARY KEY, bar int)');
self::$connection->query('INSERT INTO IntTest (foo, bar) VALUES (:foo, :bar)', ['foo' => '-2', 'bar' => '-52']);
$result = self::$connection->query('SELECT * FROM IntTest WHERE foo = :foo', ['foo' => '-2']);
$this->assertEquals('-52', $result[0]['bar']);
$this->assertEquals('-2', $result[0]['foo']);
}
public function testIntMap()
{
self::$connection->query('CREATE TABLE IntMapTest (foo int PRIMARY KEY, bar map<int,int>)');
self::$connection->query(
'INSERT INTO IntMapTest (foo, bar) VALUES (:foo, :bar)',
['foo' => '-2', 'bar' => ['-52' => '-25']]
);
$result = self::$connection->query('SELECT * FROM IntMapTest WHERE foo = :foo', ['foo' => '-2']);
$this->assertEquals(['-52' => '-25'], $result[0]['bar']);
$this->assertEquals('-2', $result[0]['foo']);
}
public function testIntSet()
{
self::$connection->query('CREATE TABLE IntSetTest (foo int PRIMARY KEY, bar set<int>)');
self::$connection->query(
'INSERT INTO IntSetTest (foo, bar) VALUES (:foo, :bar)',
['foo' => '-2', 'bar' => ['-25', '-52']]
);
$result = self::$connection->query('SELECT * FROM IntSetTest WHERE foo = :foo', ['foo' => '-2']);
$this->assertEquals([-52, -25], $result[0]['bar']);
$this->assertEquals('-2', $result[0]['foo']);
//according to Spec, this should always be returned alphabetically.
self::$connection->query(
'INSERT INTO IntSetTest (foo, bar) VALUES (:foo, :bar)',
['foo' => '-22', 'bar' => ['-52', '-25']]
);
$result = self::$connection->query('SELECT * FROM IntSetTest WHERE foo = :foo', ['foo' => '-22']);
$this->assertEquals([-52, -25], $result[0]['bar']);
}
public function testIntList()
{
self::$connection->query('CREATE TABLE IntListTest (foo int PRIMARY KEY, bar list<int>)');
self::$connection->query(
'INSERT INTO IntListTest (foo, bar) VALUES (:foo, :bar)',
['foo' => '-2', 'bar' => ['-52', '-25']]
);
$result = self::$connection->query('SELECT * FROM IntListTest WHERE foo = :foo', ['foo' => '-2']);
$this->assertEquals(['-52', '-25'], $result[0]['bar']);
$this->assertEquals('-2', $result[0]['foo']);
//according to Spec, this should be returned in index order
self::$connection->query(
'INSERT INTO IntListTest (foo, bar) VALUES (:foo, :bar)',
['foo' => '-22', 'bar' => ['-25', '-52']]
);
$result = self::$connection->query('SELECT * FROM IntListTest WHERE foo = :foo', ['foo' => '-22']);
$this->assertEquals(['-25', '-52'], $result[0]['bar']);
}
}