Skip to content

Commit bd6764a

Browse files
committed
update test code. With SWIG 4.1, there is not any php wrapper file anymore.
1 parent 6e0ed0e commit bd6764a

15 files changed

+157
-78
lines changed

test/testCode/BS001ContainerBasicScenario.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once('griddb_php_client.php');
7+
}
58
require_once('config.php');
69
require_once('utility.php');
710

test/testCode/BS004ContainerPutGet.php

Lines changed: 101 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
5-
require_once('config.php');
6-
require_once('utility.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once ('griddb_php_client.php');
7+
}
8+
require_once ('config.php');
9+
require_once ('utility.php');
710

8-
class BS004ContainerPutGet extends TestCase {
11+
class BS004ContainerPutGet extends TestCase
12+
{
913
protected static $gridstore;
1014

1115
public static function setUpBeforeClass(): void {
1216
$factory = \StoreFactory::getInstance();
1317
try {
14-
$storeInfo = ["host" => GRIDDB_NOTIFICATION_ADDRESS,
15-
"port" => (int)GRIDDB_NOTIFICATION_PORT,
16-
"clusterName" => GRIDDB_CLUSTER_NAME,
17-
"username" => GRIDDB_USERNAME,
18-
"password" => GRIDDB_PASSWORD];
18+
$storeInfo = [
19+
"host" => GRIDDB_NOTIFICATION_ADDRESS,
20+
"port" => (int) GRIDDB_NOTIFICATION_PORT,
21+
"clusterName" => GRIDDB_CLUSTER_NAME,
22+
"username" => GRIDDB_USERNAME,
23+
"password" => GRIDDB_PASSWORD,
24+
];
1925

2026
self::$gridstore = $factory->getStore($storeInfo);
21-
} catch (\GSException $e){
22-
for ($i= 0; $i < $e->getErrorStackSize(); $i++) {
23-
echo("\n[$i]\n");
24-
echo($e->getErrorCode($i)."\n");
25-
echo($e->getLocation($i)."\n");
26-
echo($e->getErrorMessage($i)."\n");
27+
} catch (\GSException $e) {
28+
for ($i = 0; $i < $e->getErrorStackSize(); $i++) {
29+
echo "\n[$i]\n";
30+
echo $e->getErrorCode($i) . "\n";
31+
echo $e->getLocation($i) . "\n";
32+
echo $e->getErrorMessage($i) . "\n";
2733
}
2834
} catch (\Exception $e1) {
29-
echo($e1."\n");
35+
echo $e1 . "\n";
3036
}
3137
}
3238

@@ -40,12 +46,20 @@ public function providerDataTest() {
4046
/**
4147
* @dataProvider providerDataTest
4248
*/
43-
public function testContainerPutGet($testId, $containerType,
44-
$stringVal, $timestampVal, $byteVal,
45-
$shortVal, $integerVal, $boolVal,
46-
$floatVal, $doubleVal, $blobVal,
47-
$expectedOutput)
48-
{
49+
public function testContainerPutGet(
50+
$testId,
51+
$containerType,
52+
$stringVal,
53+
$timestampVal,
54+
$byteVal,
55+
$shortVal,
56+
$integerVal,
57+
$boolVal,
58+
$floatVal,
59+
$doubleVal,
60+
$blobVal,
61+
$expectedOutput
62+
) {
4963
echo sprintf("Test case: %s put: %s:\n", $testId, $containerType);
5064
echo sprintf(" Expected has exception = %s\n", $expectedOutput);
5165

@@ -66,64 +80,88 @@ public function testContainerPutGet($testId, $containerType,
6680

6781
// Test putRow
6882
try {
69-
if ($containerType == "GS_CONTAINER_COLLECTION") {
83+
if (strcmp($containerType, "GS_CONTAINER_COLLECTION")) {
7084
$containerName = "col01Collection";
71-
$columnInfoList = [["A", \Type::STRING],
72-
["B", \Type::TIMESTAMP],
73-
["C", \Type::BYTE],
74-
["D", \Type::SHORT],
75-
["E", \Type::INTEGER],
76-
["F", \Type::BOOL],
77-
["G", \Type::FLOAT],
78-
["H", \Type::DOUBLE],
79-
["I", \Type::BLOB]];
80-
$containerType = \ContainerType::COLLECTION;
85+
$columnInfoList = [
86+
["A", \Type::STRING],
87+
["B", \Type::TIMESTAMP],
88+
["C", \Type::BYTE],
89+
["D", \Type::SHORT],
90+
["E", \Type::INTEGER],
91+
["F", \Type::BOOL],
92+
["G", \Type::FLOAT],
93+
["H", \Type::DOUBLE],
94+
["I", \Type::BLOB],
95+
];
96+
$containerTypeObj = \ContainerType::COLLECTION;
8197
} else {
8298
$containerName = "col01Timeseries";
83-
$columnInfoList = [["A", \Type::TIMESTAMP],
84-
["B", \Type::STRING],
85-
["C", \Type::BYTE],
86-
["D", \Type::SHORT],
87-
["E", \Type::INTEGER],
88-
["F", \Type::BOOL],
89-
["G", \Type::FLOAT],
90-
["H", \Type::DOUBLE],
91-
["I", \Type::BLOB]];
92-
$containerType = \ContainerType::TIME_SERIES;
99+
$columnInfoList = [
100+
["A", \Type::TIMESTAMP],
101+
["B", \Type::STRING],
102+
["C", \Type::BYTE],
103+
["D", \Type::SHORT],
104+
["E", \Type::INTEGER],
105+
["F", \Type::BOOL],
106+
["G", \Type::FLOAT],
107+
["H", \Type::DOUBLE],
108+
["I", \Type::BLOB],
109+
];
110+
$containerTypeObj = \ContainerType::TIME_SERIES;
93111
}
94-
$containerInfo = new \ContainerInfo(["name" => $containerName,
95-
"columnInfoArray" => $columnInfoList,
96-
"type" => $containerType,
97-
"rowKey" => $rowKeyAssigned]);
112+
$containerInfo = new \ContainerInfo([
113+
"name" => $containerName,
114+
"columnInfoArray" => $columnInfoList,
115+
"type" => $containerTypeObj,
116+
"rowKey" => $rowKeyAssigned,
117+
]);
98118
self::$gridstore->dropContainer($containerName);
99-
$container = self::$gridstore->putContainer($containerInfo,
100-
$modifiable);
101-
if ($containerType == "GS_CONTAINER_COLLECTION") {
102-
$rowData = [$stringVal, $timestampVal, $byteVal,
103-
$shortVal, $integerVal, $boolVal,
104-
$floatVal, $doubleVal, $blobVal];
119+
$container = self::$gridstore->putContainer(
120+
$containerInfo,
121+
$modifiable
122+
);
123+
if (strcmp($containerType, "GS_CONTAINER_COLLECTION")) {
124+
$rowData = [
125+
$stringVal,
126+
$timestampVal,
127+
$byteVal,
128+
$shortVal,
129+
$integerVal,
130+
$boolVal,
131+
$floatVal,
132+
$doubleVal,
133+
$blobVal,
134+
];
105135
} else {
106-
$rowData = [$timestampVal, $stringVal, $byteVal,
107-
$shortVal, $integerVal, $boolVal,
108-
$floatVal, $doubleVal, $blobVal];
136+
$rowData = [
137+
$timestampVal,
138+
$stringVal,
139+
$byteVal,
140+
$shortVal,
141+
$integerVal,
142+
$boolVal,
143+
$floatVal,
144+
$doubleVal,
145+
$blobVal,
146+
];
109147
}
110148
$existed = $container->put($rowData);
111-
if ($containerType == "GS_CONTAINER_COLLECTION") {
149+
if (strcmp($containerType, "GS_CONTAINER_COLLECTION")) {
112150
$rowDataGet = $container->get($stringVal);
113151
} else {
114152
$rowDataGet = $container->get($timestampVal);
115153
}
116154
self::$gridstore->dropContainer($containerName);
117155
} catch (\GSException $e) {
118-
for ($i= 0; $i < $e->getErrorStackSize(); $i++) {
119-
echo("\n[$i]\n");
120-
echo($e->getErrorCode($i)."\n");
121-
echo($e->getLocation($i)."\n");
122-
echo($e->getErrorMessage($i)."\n");
156+
for ($i = 0; $i < $e->getErrorStackSize(); $i++) {
157+
echo "\n[$i]\n";
158+
echo $e->getErrorCode($i) . "\n";
159+
echo $e->getLocation($i) . "\n";
160+
echo $e->getErrorMessage($i) . "\n";
123161
}
124162
$hasException = "1";
125163
} catch (\Exception $e1) {
126-
echo($e1."\n");
164+
echo $e1 . "\n";
127165
$hasException = "1";
128166
}
129167

@@ -132,4 +170,3 @@ public function testContainerPutGet($testId, $containerType,
132170
}
133171
}
134172
?>
135-

test/testCode/BS004ContainerPutGetNullSpec.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once('griddb_php_client.php');
7+
}
58
require_once('config.php');
69
require_once('utility.php');
710

test/testCode/BS005ContainerIndex.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once('griddb_php_client.php');
7+
}
58
require_once('config.php');
69
require_once('utility.php');
710

test/testCode/BS007AggregationWithDoubleTimestamp.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once('griddb_php_client.php');
7+
}
58
require_once('config.php');
69
require_once('utility.php');
710

test/testCode/BS008ContainerPutGetRemoveSpec.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once('griddb_php_client.php');
7+
}
58
require_once('config.php');
69
require_once('utility.php');
710

test/testCode/BS009RowSetManualCommitSpec.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once('griddb_php_client.php');
7+
}
58
require_once('config.php');
69
require_once('utility.php');
710

test/testCode/BS010QueryWithLimitSpec.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once('griddb_php_client.php');
7+
}
58
require_once('config.php');
69
require_once('utility.php');
710

test/testCode/BS012ErrorUtilitySpec.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once('griddb_php_client.php');
7+
}
58
require_once('config.php');
69
require_once('utility.php');
710

test/testCode/BS013PartitionController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
namespace Tests;
33
use PHPUnit\Framework\TestCase;
4-
require_once ('griddb_php_client.php');
4+
if (file_exists('griddb_php_client.php')) {
5+
// File php wrapper is generated with SWIG 4.0.2 and below
6+
require_once('griddb_php_client.php');
7+
}
58
require_once('config.php');
69
require_once('utility.php');
710

0 commit comments

Comments
 (0)