forked from michal-harish/kafka-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest
More file actions
executable file
·58 lines (46 loc) · 1.45 KB
/
test
File metadata and controls
executable file
·58 lines (46 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/php
<?php
/*
*. Usage: ./test [system_test_host]
*.
*/
error_reporting(E_ALL | E_STRICT);
set_error_handler(function($errno,$errstr,$file,$line) {
throw new ErrorException($errstr,$errno,0,$file,$line);
});
class SkippedException extends RuntimeException {}
function dump($data) {
for($i=0; $i<strlen($data); $i++) {
echo 'chr('.ord($data[$i]).').';
}
}
function runtests(array $files) {
foreach($files as $testCase)
{
$testName = substr($testCase,strlen(__DIR__)+1);
echo "\033[1;35m{$testName}\033[0m";
try {
require $testCase;
echo " - SUCCESS";
} catch ( SkippedException $se) {
echo " -\033[1;1;33m SKIPPED " . $se->getMessage() . "\033[0m";
}
echo "\n";
}
}
try {
echo "\nKafka-PHP Unit Tests\n====================\n";
runtests(array_merge(glob(__DIR__. "/tests/Kafka/*.php"), glob(__DIR__. "/tests/Kafka/*/*.php")));
$testHost = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'localhost';
echo "\nKafka-PHP System Tests ($testHost) \n==========================================\n";
$kafka = new \Kafka\Kafka($testHost, 9092, 3, 0.7);
$consumer = \Kafka\ConsumerConnector::Create("{$testHost}:2181", "kafka-php-system-test");
runtests(array_merge(glob(__DIR__. "/tests/System/*.php")));
echo "\n\033[1;32mSUCCESS\033[0m";
} catch(Exception $e) {
echo "\033[1;31m";
echo " - FAILURE: " . $e->getMessage() . "\n";
echo $e->getTraceAsString ();
echo "\033[0m";
}
echo "\n\n";