add php pdo mysql client integration test

This commit is contained in:
Stephanie You
2023-05-26 09:54:51 -07:00
parent 4b6a42a90e
commit 1cba57d290
3 changed files with 44 additions and 2 deletions

View File

@@ -167,8 +167,13 @@ EOF" -m "postgres"
cargo run --bin mysql_connector_test $USER $PORT $REPO_NAME
}
@test "php mysql client" {
@test "php mysqli mysql client" {
cd $BATS_TEST_DIRNAME/php
php mysql_connector_test.php $USER $PORT $REPO_NAME
php mysqli_connector_test.php $USER $PORT $REPO_NAME
}
@test "php pdo mysql client" {
cd $BATS_TEST_DIRNAME/php
php pdo_connector_test.php $USER $PORT $REPO_NAME
}

View File

@@ -0,0 +1,37 @@
<?php
$user = $argv[1];
$port = $argv[2];
$db = $argv[3];
$conn = new PDO("mysql:host=127.0.0.1;port={$port};dbname={$db}", $user, '');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$queries = [
"create table test (pk int, `value` int, primary key(pk))" => 0,
"describe test" => 2,
"insert into test (pk, `value`) values (0,0)" => 1,
"select * from test" => 1,
"call dolt_add('-A');" => 1,
"call dolt_commit('-m', 'my commit')" => 1,
"call dolt_checkout('-b', 'mybranch')" => 1,
"insert into test (pk, `value`) values (1,1)" => 1,
"call dolt_commit('-a', '-m', 'my commit2')" => 1,
"call dolt_checkout('main')" => 1,
"call dolt_merge('mybranch')" => 1,
"select COUNT(*) FROM dolt_log" => 1
];
foreach ($queries as $query => $expected) {
$result = $conn->query($query);
if ($result->rowCount() != $expected) {
echo "LENGTH: {$result->rowCount()}\n";
echo "QUERY: {$query}\n";
echo "EXPECTED: {$expected}\n";
echo "RESULT: {$result}";
exit(1);
}
}
exit(0)
?>