Skip to content

Commit c3f9122

Browse files
committed
Fixed build and various tests
1 parent 0d2159e commit c3f9122

File tree

5 files changed

+65
-36
lines changed

5 files changed

+65
-36
lines changed

ext/config.m4

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if test "$PHP_CASSANDRA" != "no"; then
3131
src/Cassandra/Cluster/Builder.c \
3232
src/Cassandra/Collection.c \
3333
src/Cassandra/Column.c \
34+
src/Cassandra/Date.c \
3435
src/Cassandra/Decimal.c \
3536
src/Cassandra/DefaultAggregate.c \
3637
src/Cassandra/DefaultCluster.c \
@@ -65,15 +66,18 @@ if test "$PHP_CASSANDRA" != "no"; then
6566
src/Cassandra/Session.c \
6667
src/Cassandra/Set.c \
6768
src/Cassandra/SimpleStatement.c \
69+
src/Cassandra/Smallint.c \
6870
src/Cassandra/SSLOptions.c \
6971
src/Cassandra/SSLOptions/Builder.c \
7072
src/Cassandra/Statement.c \
7173
src/Cassandra/Table.c \
74+
src/Cassandra/Time.c \
7275
src/Cassandra/Timestamp.c \
7376
src/Cassandra/TimestampGenerator.c \
7477
src/Cassandra/TimestampGenerator/Monotonic.c \
7578
src/Cassandra/TimestampGenerator/ServerSide.c \
7679
src/Cassandra/Timeuuid.c \
80+
src/Cassandra/Tinyint.c \
7781
src/Cassandra/Tuple.c \
7882
src/Cassandra/Type.c \
7983
src/Cassandra/UserTypeValue.c \

support/ccm.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,19 @@ public function setupClientVerification()
267267
}
268268
}
269269

270+
public function setupUserDefinedFunctions()
271+
{
272+
$this->ssl = false;
273+
$this->clientAuth = false;
274+
$this->internalSetup(1, 0);
275+
if (version_compare($this->version, "2.2.0", ">=")) {
276+
$this->run('updateconf', 'enable_user_defined_functions: true');
277+
}
278+
if (version_compare($this->version, "3.0.0", ">=")) {
279+
$this->run('updateconf', 'enable_scripted_user_defined_functions: true');
280+
}
281+
}
282+
270283
public function enableTracing($isEnabled)
271284
{
272285
$nodes = $this->dataCenterOneNodes + $this->dataCenterTwoNodes;

tests/integration/Cassandra/DatatypeIntegrationTests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected function verifyValue($tableName, $type, $key, $value) {
158158

159159
$this->assertEquals($row['value'], $value);
160160
$this->assertTrue($row['value'] == $value);
161-
if ($row['value']) {
161+
if (isset($row['value'])) {
162162
$this->assertEquals(count($row['value']), count($value));
163163
if (is_object($row['value'])) {
164164
$this->assertEquals($row['value']->type(), $type);

tests/integration/Cassandra/SchemaMetadataIntegrationTest.php

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ protected function assertIndex($index, $kind, $target, $className, $isCustom) {
125125
$this->assertCount(1, $index->options());
126126
$this->assertEquals($target, $index->option("target"));
127127
}
128-
129-
//echo "${index}" . PHP_EOL;
130-
var_dump($index);
131128
}
132129

133130
/**
@@ -208,6 +205,7 @@ protected function assertMaterializedViewsEqual($materializedViewOne, $materiali
208205
$this->assertEquals($materializedViewOne->maxIndexInterval(), $materializedViewTwo->maxIndexInterval());
209206
$this->assertEquals($materializedViewOne->minIndexInterval(), $materializedViewTwo->minIndexInterval());
210207
$this->assertEquals($materializedViewOne->columns(), $materializedViewTwo->columns());
208+
$this->assertEquals($materializedViewOne->partitionKey(), $materializedViewTwo->partitionKey());
211209
$this->assertEquals($materializedViewOne->primaryKey(), $materializedViewTwo->primaryKey());
212210
$this->assertEquals($materializedViewOne->clusteringKey(), $materializedViewTwo->clusteringKey());
213211
$this->assertEquals($materializedViewOne->clusteringOrder(), $materializedViewTwo->clusteringOrder());
@@ -221,24 +219,29 @@ protected function assertMaterializedViewsEqual($materializedViewOne, $materiali
221219
* @param $name Name to assert
222220
* @param $tableName Table name to assert
223221
* @param $columns Columns names to assert
224-
* @param $primaryKeyColumns Primary key column names to assert
222+
* @param $partitionKeyColumns Primary key column names to assert
225223
* @param $clusteringKeyColumns Cluster key column names to assert
226224
*/
227-
protected function assertMaterializedView($materializedView, $name, $tableName, $columns, $primaryKeyColumns, $clusteringKeyColumns) {
225+
protected function assertMaterializedView($materializedView, $name, $tableName, $columns, $partitionKeyColumns, $clusteringKeyColumns) {
228226
$this->assertEquals($materializedView->name(), $name);
229227
$this->assertEquals($materializedView->baseTable()->name(), $tableName);
230228
$i = 0;
231229
foreach ($materializedView->columns() as $column) {
232230
$this->assertEquals($columns[$i++], $column->name());
233231
}
234232
$i = 0;
235-
foreach ($materializedView->primaryKey() as $column) {
236-
$this->assertEquals($primaryKeyColumns[$i++], $column->name());
233+
foreach ($materializedView->partitionKey() as $column) {
234+
$this->assertEquals($partitionKeyColumns[$i++], $column->name());
237235
}
238236
$i = 0;
239237
foreach ($materializedView->clusteringKey() as $column) {
240238
$this->assertEquals($clusteringKeyColumns[$i++], $column->name());
241239
}
240+
$primaryKeyColumns = array_merge($partitionKeyColumns, $clusteringKeyColumns);
241+
$i = 0;
242+
foreach ($materializedView->primaryKey() as $column) {
243+
$this->assertEquals($primaryKeyColumns[$i++], $column->name());
244+
}
242245
}
243246

244247
/**
@@ -510,15 +513,17 @@ public function testGetKeyspaceByName() {
510513
* This test ensures that driver correctly enumerates over table and column
511514
* metadata.
512515
*
516+
* @todo: Add "varchar" and "text" tests
517+
*
513518
* @test
514519
*/
515520
public function testEnumerateTablesAndColumns() {
516521
$keyspaceName = self::generateKeyspaceName("enumerate");
517522

518523
$tableSchemas = array(
519-
"table_int_varchar" => array("key" => "int", "value" => "varchar"),
520-
"table_varchar_bigint" => array("key" => "varchar", "value" => "bigint"),
521-
"table_varchar_map" => array("key" => "varchar", "value" => "map<bigint, varchar>")
524+
"table_int_int" => array("key" => "int", "value" => "int"),
525+
"table_int_bigint" => array("key" => "int", "value" => "bigint"),
526+
"table_decimal_map" => array("key" => "decimal", "value" => "map<bigint, uuid>")
522527
);
523528

524529
$this->createKeyspaceWithSchema($keyspaceName, $tableSchemas);
@@ -542,15 +547,17 @@ public function testEnumerateTablesAndColumns() {
542547
* This test ensures that the driver is able to access table and column
543548
* metadata by name.
544549
*
550+
* @todo: Add "varchar" and "text" tests
551+
*
545552
* @test
546553
*/
547554
public function testGetTableAndColumnByName() {
548555
$keyspaceName = self::generateKeyspaceName("by_name");
549556

550557
$tableSchemas = array(
551-
"table_int_varchar" => array("key" => "int", "value" => "varchar"),
552-
"table_varchar_bigint" => array("key" => "varchar", "value" => "bigint"),
553-
"table_varchar_map" => array("key" => "varchar", "value" => "map<bigint, varchar>")
558+
"table_int_int" => array("key" => "int", "value" => "int"),
559+
"table_int_bigint" => array("key" => "int", "value" => "bigint"),
560+
"table_decimal_map" => array("key" => "decimal", "value" => "map<bigint, uuid>")
554561
);
555562

556563
$this->createKeyspaceWithSchema($keyspaceName, $tableSchemas);
@@ -636,35 +643,37 @@ public function testSchemaMetadataWithNullFields() {
636643
* This test ensures that the validator parser correctly parses and builds
637644
* columns with deeply nested collection types.
638645
*
646+
* @todo: Add "varchar" and "text" tests
647+
*
639648
* @test
640649
* @ticket PHP-62
641650
*/
642651
public function testSchemaMetadataWithNestedColumnTypes() {
643652
$statement = new SimpleStatement(
644-
"CREATE TABLE {$this->tableNamePrefix}_nested1 (key int PRIMARY KEY, value map<frozen<list<varchar>>, varchar>)"
653+
"CREATE TABLE {$this->tableNamePrefix}_nested1 (key int PRIMARY KEY, value map<frozen<list<int>>, int>)"
645654
);
646655
$this->session->execute($statement);
647656

648657
$statement = new SimpleStatement(
649-
"CREATE TABLE {$this->tableNamePrefix}_nested2 (key int PRIMARY KEY, value map<varchar, frozen<list<varchar>>>)"
658+
"CREATE TABLE {$this->tableNamePrefix}_nested2 (key int PRIMARY KEY, value map<int, frozen<list<int>>>)"
650659
);
651660
$this->session->execute($statement);
652661

653662
$statement = new SimpleStatement(
654-
"CREATE TABLE {$this->tableNamePrefix}_nested3 (key int PRIMARY KEY, value list<frozen<map<varchar, frozen<set<varchar>>>>>)"
663+
"CREATE TABLE {$this->tableNamePrefix}_nested3 (key int PRIMARY KEY, value list<frozen<map<int, frozen<set<int>>>>>)"
655664
);
656665
$this->session->execute($statement);
657666

658667
$keyspace = $this->session->schema()->keyspace($this->keyspaceName);
659668

660669
$table1 = $keyspace->table("{$this->tableNamePrefix}_nested1");
661-
$this->assertEquals((string)$table1->column("value")->type(), "map<list<varchar>, varchar>");
670+
$this->assertEquals((string)$table1->column("value")->type(), "map<list<int>, int>");
662671

663672
$table2 = $keyspace->table("{$this->tableNamePrefix}_nested2");
664-
$this->assertEquals((string)$table2->column("value")->type(), "map<varchar, list<varchar>>");
673+
$this->assertEquals((string)$table2->column("value")->type(), "map<int, list<int>>");
665674

666675
$table3 = $keyspace->table("{$this->tableNamePrefix}_nested3");
667-
$this->assertEquals((string)$table3->column("value")->type(), "list<map<varchar, set<varchar>>>");
676+
$this->assertEquals((string)$table3->column("value")->type(), "list<map<int, set<int>>>");
668677
}
669678

670679
/**
@@ -805,7 +814,7 @@ public function testMaterializedViews() {
805814
$materializedView = $keyspace->materializedView("simple");
806815
$this->assertMaterializedViewsEqual($materializedView, $table->materializedView("simple"));
807816
$this->assertMaterializedView($materializedView, "simple", "{$this->tableNamePrefix}_1",
808-
array("value1", "key1"), array("value1"), array("key1"));
817+
array("value1", "key1"), array("value1", "key1"), array("key1"));
809818
}
810819

811820
/**

tests/integration/Cassandra/SimpleStatementIntegrationTest.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,29 +120,29 @@ public function testCaseSensitiveByName() {
120120
$values = array(
121121
// Reversed order from table and insert queries
122122
array(
123-
"value_BooLeaN" => false,
124-
"value_boolean" => true,
125-
"value_iNT" => 11,
126-
"value_int" => 1,
123+
"\"value_BooLeaN\"" => false,
124+
"\"value_boolean\"" => true,
125+
"\"value_iNT\"" => 11,
126+
"\"value_int\"" => 1,
127127
"key" => new Timeuuid()
128128
),
129129

130130
// Random order
131131
array(
132-
"value_int" => 2,
133-
"value_BooLeaN" => true,
132+
"\"value_int\"" => 2,
133+
"\"value_BooLeaN\"" => true,
134134
"key" => new Timeuuid(),
135-
"value_boolean" => false,
136-
"value_iNT" => 22
135+
"\"value_boolean\"" => false,
136+
"\"value_iNT\"" => 22
137137
),
138138

139-
// In order
139+
#// In order
140140
array(
141141
"key" => new Timeuuid(),
142-
"value_int" => 3,
143-
"value_iNT" => 33,
144-
"value_boolean" => false,
145-
"value_BooLeaN" => true
142+
"\"value_int\"" => 3,
143+
"\"value_iNT\"" => 33,
144+
"\"value_boolean\"" => false,
145+
"\"value_BooLeaN\"" => true
146146
)
147147
);
148148
$statement = new SimpleStatement($query);
@@ -157,8 +157,11 @@ public function testCaseSensitiveByName() {
157157
$rows = $this->session->execute($statement);
158158
$this->assertCount(count($values), $rows);
159159
foreach ($rows as $i => $row) {
160-
$values[$i];
161-
$this->assertEquals($values[$i], $row);
160+
$expected = array();
161+
foreach ($values[$i] as $key => $value) {
162+
$expected[trim($key, "\"")] = $value;
163+
}
164+
$this->assertEquals($expected, $row);
162165
}
163166
}
164167

0 commit comments

Comments
 (0)