Skip to content

Commit 542653a

Browse files
committed
add some basic tests
[skip ci]
1 parent b35953a commit 542653a

File tree

6 files changed

+88
-2
lines changed

6 files changed

+88
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ before_script:
8383
script:
8484
- netstat -tlnp |grep 6253
8585
- ${CP_PATH}/pool_server status
86-
- env TEST_PHP_EXECUTABLE=$PHP_BIN $PHP_BIN -c "${PHP_PATH}/config/php.ini" "${PHP_PATH}/run-tests.php" "${CP_PATH}/tests" |tee /tmp/php_cp_test.result && fail_num=$(grep -o -E "Tests\s+failed\s*:\s*[0-9]{1,}\s*\(" /tmp/php_cp_test.result |grep -o -E "[0-9]{1,}" -) && echo $fail_num && [ "$fail_num"=="0" ]
86+
- env TEST_PHP_EXECUTABLE=$PHP_BIN $PHP_BIN -c "${PHP_PATH}/config/php.ini" "${PHP_PATH}/run-tests.php" --show-diff "${CP_PATH}/tests" |tee /tmp/php_cp_test.result && fail_num=$(grep -o -E "Tests\s+failed\s*:\s*[0-9]{1,}\s*\(" /tmp/php_cp_test.result |grep -o -E "[0-9]{1,}" -) && fail_num=$((fail_num+0)) && echo $fail_num && [ $fail_num -eq 0 ]
8787

8888
after_success: true
8989

tests/environment.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
if (extension_loaded("connect_pool") === false) {
1010
$php_test_exit(2, "Skip this test, connection pool extension NOT loaded");
1111
}
12+
if (extension_loaded("redis") === false) {
13+
$php_test_exit(2, "Skip this test, redis extension NOT loaded");
14+
}
1215

tests/mysql/basic-select1.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Testing php-cp platform
3+
4+
--SKIPIF--
5+
<?php
6+
require(dirname(__DIR__) . DIRECTORY_SEPARATOR . "environment.php");
7+
?>
8+
9+
--FILE--
10+
<?php
11+
try{
12+
$db = new pdoProxy('mysql:dbname=mysql;host=127.0.0.1;port=3306;charset=utf8', "travis", "");
13+
$result = $db->query("SELECT 1")->fetchAll();
14+
$db->release();
15+
var_dump((bool) $result);
16+
} catch (\Exception $e) {
17+
var_dump($e);
18+
}
19+
?>
20+
--EXPECT--
21+
bool(true)
22+
23+
--CLEAN--
24+
<?php
25+
?>
26+

tests/mysql/basic-showtables.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Testing php-cp platform
3+
4+
--SKIPIF--
5+
<?php
6+
require(dirname(__DIR__) . DIRECTORY_SEPARATOR . "environment.php");
7+
?>
8+
9+
--FILE--
10+
<?php
11+
try{
12+
$db = new pdoProxy('mysql:dbname=mysql;host=127.0.0.1;port=3306;charset=utf8', "travis", "");
13+
$tables = $db->query("show tables")->fetchAll();
14+
$db->release();
15+
var_dump((bool) $tables);
16+
} catch (\Exception $e) {
17+
var_dump($e);
18+
}
19+
?>
20+
--EXPECT--
21+
bool(true)
22+
23+
--CLEAN--
24+
<?php
25+
?>
26+

tests/redis/basic-setget.phpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Testing php-cp platform
3+
4+
--SKIPIF--
5+
<?php
6+
require(__DIR__ . DIRECTORY_SEPARATOR . "environment.php");
7+
?>
8+
9+
--FILE--
10+
<?php
11+
try {
12+
$now = time();
13+
$key = "time_stamp";
14+
$db = new redisProxy();
15+
$db->connect("127.0.0.1");
16+
$db->select(1);
17+
$db->set($key, $now);
18+
$stored = $db->get($key);
19+
$db->release();
20+
var_dump($stored === $now);
21+
} catch (\Exception $e) {
22+
var_dump($e);
23+
}
24+
?>
25+
26+
--EXPECTF--
27+
bool(true)
28+
29+
--CLEAN--
30+
<?php
31+
?>
32+

tests/try.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require(__DIR__ . DIRECTORY_SEPARATOR . "environment.php");
88

99
--FILE--
1010
<?php
11-
$s = '123';
1211
var_dump(time());
1312
?>
1413

0 commit comments

Comments
 (0)