Skip to content

Commit

Permalink
update test code. With SWIG 4.1, there is not any php wrapper file an…
Browse files Browse the repository at this point in the history
…ymore.
  • Loading branch information
knonomura committed Mar 4, 2022
1 parent 6e0ed0e commit bd6764a
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 78 deletions.
5 changes: 4 additions & 1 deletion test/testCode/BS001ContainerBasicScenario.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
165 changes: 101 additions & 64 deletions test/testCode/BS004ContainerPutGet.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
require_once('config.php');
require_once('utility.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once ('griddb_php_client.php');
}
require_once ('config.php');
require_once ('utility.php');

class BS004ContainerPutGet extends TestCase {
class BS004ContainerPutGet extends TestCase
{
protected static $gridstore;

public static function setUpBeforeClass(): void {
$factory = \StoreFactory::getInstance();
try {
$storeInfo = ["host" => GRIDDB_NOTIFICATION_ADDRESS,
"port" => (int)GRIDDB_NOTIFICATION_PORT,
"clusterName" => GRIDDB_CLUSTER_NAME,
"username" => GRIDDB_USERNAME,
"password" => GRIDDB_PASSWORD];
$storeInfo = [
"host" => GRIDDB_NOTIFICATION_ADDRESS,
"port" => (int) GRIDDB_NOTIFICATION_PORT,
"clusterName" => GRIDDB_CLUSTER_NAME,
"username" => GRIDDB_USERNAME,
"password" => GRIDDB_PASSWORD,
];

self::$gridstore = $factory->getStore($storeInfo);
} catch (\GSException $e){
for ($i= 0; $i < $e->getErrorStackSize(); $i++) {
echo("\n[$i]\n");
echo($e->getErrorCode($i)."\n");
echo($e->getLocation($i)."\n");
echo($e->getErrorMessage($i)."\n");
} catch (\GSException $e) {
for ($i = 0; $i < $e->getErrorStackSize(); $i++) {
echo "\n[$i]\n";
echo $e->getErrorCode($i) . "\n";
echo $e->getLocation($i) . "\n";
echo $e->getErrorMessage($i) . "\n";
}
} catch (\Exception $e1) {
echo($e1."\n");
echo $e1 . "\n";
}
}

Expand All @@ -40,12 +46,20 @@ public function providerDataTest() {
/**
* @dataProvider providerDataTest
*/
public function testContainerPutGet($testId, $containerType,
$stringVal, $timestampVal, $byteVal,
$shortVal, $integerVal, $boolVal,
$floatVal, $doubleVal, $blobVal,
$expectedOutput)
{
public function testContainerPutGet(
$testId,
$containerType,
$stringVal,
$timestampVal,
$byteVal,
$shortVal,
$integerVal,
$boolVal,
$floatVal,
$doubleVal,
$blobVal,
$expectedOutput
) {
echo sprintf("Test case: %s put: %s:\n", $testId, $containerType);
echo sprintf(" Expected has exception = %s\n", $expectedOutput);

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

// Test putRow
try {
if ($containerType == "GS_CONTAINER_COLLECTION") {
if (strcmp($containerType, "GS_CONTAINER_COLLECTION")) {
$containerName = "col01Collection";
$columnInfoList = [["A", \Type::STRING],
["B", \Type::TIMESTAMP],
["C", \Type::BYTE],
["D", \Type::SHORT],
["E", \Type::INTEGER],
["F", \Type::BOOL],
["G", \Type::FLOAT],
["H", \Type::DOUBLE],
["I", \Type::BLOB]];
$containerType = \ContainerType::COLLECTION;
$columnInfoList = [
["A", \Type::STRING],
["B", \Type::TIMESTAMP],
["C", \Type::BYTE],
["D", \Type::SHORT],
["E", \Type::INTEGER],
["F", \Type::BOOL],
["G", \Type::FLOAT],
["H", \Type::DOUBLE],
["I", \Type::BLOB],
];
$containerTypeObj = \ContainerType::COLLECTION;
} else {
$containerName = "col01Timeseries";
$columnInfoList = [["A", \Type::TIMESTAMP],
["B", \Type::STRING],
["C", \Type::BYTE],
["D", \Type::SHORT],
["E", \Type::INTEGER],
["F", \Type::BOOL],
["G", \Type::FLOAT],
["H", \Type::DOUBLE],
["I", \Type::BLOB]];
$containerType = \ContainerType::TIME_SERIES;
$columnInfoList = [
["A", \Type::TIMESTAMP],
["B", \Type::STRING],
["C", \Type::BYTE],
["D", \Type::SHORT],
["E", \Type::INTEGER],
["F", \Type::BOOL],
["G", \Type::FLOAT],
["H", \Type::DOUBLE],
["I", \Type::BLOB],
];
$containerTypeObj = \ContainerType::TIME_SERIES;
}
$containerInfo = new \ContainerInfo(["name" => $containerName,
"columnInfoArray" => $columnInfoList,
"type" => $containerType,
"rowKey" => $rowKeyAssigned]);
$containerInfo = new \ContainerInfo([
"name" => $containerName,
"columnInfoArray" => $columnInfoList,
"type" => $containerTypeObj,
"rowKey" => $rowKeyAssigned,
]);
self::$gridstore->dropContainer($containerName);
$container = self::$gridstore->putContainer($containerInfo,
$modifiable);
if ($containerType == "GS_CONTAINER_COLLECTION") {
$rowData = [$stringVal, $timestampVal, $byteVal,
$shortVal, $integerVal, $boolVal,
$floatVal, $doubleVal, $blobVal];
$container = self::$gridstore->putContainer(
$containerInfo,
$modifiable
);
if (strcmp($containerType, "GS_CONTAINER_COLLECTION")) {
$rowData = [
$stringVal,
$timestampVal,
$byteVal,
$shortVal,
$integerVal,
$boolVal,
$floatVal,
$doubleVal,
$blobVal,
];
} else {
$rowData = [$timestampVal, $stringVal, $byteVal,
$shortVal, $integerVal, $boolVal,
$floatVal, $doubleVal, $blobVal];
$rowData = [
$timestampVal,
$stringVal,
$byteVal,
$shortVal,
$integerVal,
$boolVal,
$floatVal,
$doubleVal,
$blobVal,
];
}
$existed = $container->put($rowData);
if ($containerType == "GS_CONTAINER_COLLECTION") {
if (strcmp($containerType, "GS_CONTAINER_COLLECTION")) {
$rowDataGet = $container->get($stringVal);
} else {
$rowDataGet = $container->get($timestampVal);
}
self::$gridstore->dropContainer($containerName);
} catch (\GSException $e) {
for ($i= 0; $i < $e->getErrorStackSize(); $i++) {
echo("\n[$i]\n");
echo($e->getErrorCode($i)."\n");
echo($e->getLocation($i)."\n");
echo($e->getErrorMessage($i)."\n");
for ($i = 0; $i < $e->getErrorStackSize(); $i++) {
echo "\n[$i]\n";
echo $e->getErrorCode($i) . "\n";
echo $e->getLocation($i) . "\n";
echo $e->getErrorMessage($i) . "\n";
}
$hasException = "1";
} catch (\Exception $e1) {
echo($e1."\n");
echo $e1 . "\n";
$hasException = "1";
}

Expand All @@ -132,4 +170,3 @@ public function testContainerPutGet($testId, $containerType,
}
}
?>

5 changes: 4 additions & 1 deletion test/testCode/BS004ContainerPutGetNullSpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS005ContainerIndex.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS007AggregationWithDoubleTimestamp.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS008ContainerPutGetRemoveSpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS009RowSetManualCommitSpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS010QueryWithLimitSpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS012ErrorUtilitySpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS013PartitionController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS015ContainerInfoSetGetSpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS016ExpirationInfoSetGetSpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS018EnumSpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS019AttributeSpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down
5 changes: 4 additions & 1 deletion test/testCode/BS021KeywordParametersSpec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
require_once ('griddb_php_client.php');
if (file_exists('griddb_php_client.php')) {
// File php wrapper is generated with SWIG 4.0.2 and below
require_once('griddb_php_client.php');
}
require_once('config.php');
require_once('utility.php');

Expand Down

0 comments on commit bd6764a

Please sign in to comment.