add php mysql client integration test

This commit is contained in:
Stephanie You
2023-05-25 18:57:30 -07:00
parent bbec1c4168
commit 4b6a42a90e
3 changed files with 55 additions and 1 deletions
+2
View File
@@ -31,6 +31,8 @@ RUN apt update -y && \
ca-certificates-java \
bats \
perl \
php \
php-mysqli \
cpanminus \
cmake \
g++ \
@@ -162,8 +162,13 @@ EOF" -m "postgres"
Rscript $BATS_TEST_DIRNAME/r/rmariadb-test.r $USER $PORT $REPO_NAME
}
@test "rust mysql.connector client" {
@test "rust mysql client" {
cd $BATS_TEST_DIRNAME/rust
cargo run --bin mysql_connector_test $USER $PORT $REPO_NAME
}
@test "php mysql client" {
cd $BATS_TEST_DIRNAME/php
php mysql_connector_test.php $USER $PORT $REPO_NAME
}
@@ -0,0 +1,47 @@
<?php
$user = $argv[1];
$port = $argv[2];
$db = $argv[3];
$conn = mysqli_connect('127.0.0.1', $user, '', $db, $port)
or die('Could not connect: ' . mysql_error());
$queries = [
"create table test (pk int, `value` int, primary key(pk))" => 0,
"describe test" => 2,
"insert into test (pk, `value`) values (0,0)" => 0,
"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)" => 0,
"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 = mysqli_query($conn, $query);
if (is_bool($result)) {
if (!$result) {
echo "LENGTH: {mysqli_num_rows($result)}\n";
echo "QUERY: {$query}\n";
echo "EXPECTED: {$expected}\n";
echo "RESULT: {$result}";
exit(1);
}
} else if (mysqli_num_rows($result) != $expected) {
echo "LENGTH: {mysqli_num_rows($result)}\n";
echo "QUERY: {$query}\n";
echo "EXPECTED: {$expected}\n";
echo "RESULT: {$result}";
exit(1);
}
}
mysqli_close($conn);
exit(0)
?>