New set of tests
parent
543a6a18a3
commit
3f518917fe
|
@ -1,52 +1,10 @@
|
|||
--TEST--
|
||||
Check stomp
|
||||
Check for stomp presence
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("stomp")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$queue = '/queue/test' . md5(uniqid());
|
||||
|
||||
if ($stomp = stomp_connect('tcp://localhost:61613')) {
|
||||
var_dump(stomp_send($stomp, $queue, 'test'));
|
||||
var_dump(stomp_subscribe($stomp, $queue));
|
||||
$msg = stomp_read_frame($stomp);
|
||||
echo $msg['command'] . '=>' . $msg['body'] . PHP_EOL;
|
||||
var_dump(stomp_ack($stomp, $msg['headers']['message-id']));
|
||||
var_dump(stomp_read_frame($stomp));
|
||||
var_dump(stomp_unsubscribe($stomp, $queue));
|
||||
var_dump(stomp_close($stomp));
|
||||
}
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
$stomp = new Stomp('tcp://localhost:61613');
|
||||
try {
|
||||
var_dump($stomp->send($queue, 'test'));
|
||||
var_dump($stomp->subscribe($queue));
|
||||
$msg = $stomp->readFrame();
|
||||
echo $msg->command . '=>' . $msg->body . PHP_EOL;
|
||||
var_dump($stomp->ack($msg->headers['message-id']));
|
||||
var_dump($stomp->readFrame());
|
||||
var_dump($stomp->unsubscribe($queue));
|
||||
var_dump($stomp->disconnect());
|
||||
} catch(StompException $e) {
|
||||
}
|
||||
|
||||
<?php
|
||||
echo "stomp extension is available";
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
MESSAGE=>test
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
bool(true)
|
||||
bool(true)
|
||||
MESSAGE=>test
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
stomp extension is available
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
--TEST--
|
||||
Check stomp_version
|
||||
Test stomp_version()
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("stomp")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
echo stomp_version();
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
[0-9]\.[0-9]\.[0-9]
|
||||
--EXPECTF--
|
||||
%d.%d.%d
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
--TEST--
|
||||
Check stomp_connect
|
||||
Test stomp_connect() - URI validation
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("stomp")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
stomp_connect('');
|
||||
stomp_connect(1);
|
||||
stomp_connect('foo');
|
||||
stomp_connect('foo://bar');
|
||||
var_dump(stomp_connect(''), stomp_connect_error());
|
||||
var_dump(stomp_connect(1), stomp_connect_error());
|
||||
var_dump(stomp_connect('foo'), stomp_connect_error());
|
||||
var_dump(stomp_connect('foo://bar'), stomp_connect_error());
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: stomp_connect(): Invalid Broker URI in %s on line %d
|
||||
|
||||
Warning: stomp_connect(): Invalid Broker URI in %s on line %d
|
||||
|
||||
Warning: stomp_connect(): Invalid Broker URI in %s on line %d
|
||||
|
||||
Warning: stomp_connect(): Invalid Broker URI scheme in %s on line %d
|
||||
--EXPECT--
|
||||
NULL
|
||||
string(18) "Invalid Broker URI"
|
||||
NULL
|
||||
string(18) "Invalid Broker URI"
|
||||
NULL
|
||||
string(18) "Invalid Broker URI"
|
||||
NULL
|
||||
string(25) "Invalid Broker URI scheme"
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
--TEST--
|
||||
Test stomp_connect() - Test connection
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("stomp")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(stomp_connect());
|
||||
var_dump(stomp_connect_error());
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(%d) of type (stomp connection)
|
||||
NULL
|
|
@ -1,14 +1,14 @@
|
|||
--TEST--
|
||||
Check stomp_get_session_id
|
||||
Test stomp_get_session_id()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect("tcp://localhost:61613")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = stomp_connect("tcp://localhost:61613");
|
||||
echo stomp_get_session_id($s);
|
||||
$link = stomp_connect();
|
||||
var_dump(stomp_get_session_id($link));
|
||||
?>
|
||||
--EXPECTF--
|
||||
%s
|
||||
string(%d) "%s"
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
--TEST--
|
||||
Check stomp_close
|
||||
Test stomp_close() - tests parameters
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect("tcp://localhost:61613")) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = stomp_connect("tcp://localhost:61613");
|
||||
if(stomp_close($s)) echo "close";
|
||||
stomp_close(null);
|
||||
?>
|
||||
--EXPECT--
|
||||
close
|
||||
--EXPECTF--
|
||||
Warning: stomp_close() expects parameter 1 to be resource, null given in %s on line %d
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
--TEST--
|
||||
Test stomp_close()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$link = stomp_connect();
|
||||
if($link) echo "success" . PHP_EOL;
|
||||
if(stomp_close($link)) echo "closed";
|
||||
?>
|
||||
--EXPECT--
|
||||
success
|
||||
closed
|
|
@ -1,21 +1,28 @@
|
|||
--TEST--
|
||||
Check stomp_send
|
||||
Test stomp_send() - tests parameters
|
||||
--SKIPIF--
|
||||
<?php
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect("tcp://localhost:61613")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = new Stomp('tcp://localhost:61613');
|
||||
try {
|
||||
$s->send('', array());
|
||||
} catch(StompException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
$link = stomp_connect();
|
||||
|
||||
stomp_send($link, '', array());
|
||||
stomp_send($link, '/queue/test-06', array());
|
||||
var_dump(stomp_send($link, '/queue/test-06', ''));
|
||||
var_dump(stomp_send($link, '/queue/test-06', 'A realMessage'));
|
||||
var_dump(stomp_send($link, '/queue/test-06', 'بياريك شارون'));
|
||||
var_dump(stomp_send($link, 'بياريك شارون', 'بياريك شارون', array('receipt' => 'message-123')), stomp_error($link));
|
||||
|
||||
$s->send('/queue/test', array());
|
||||
?>
|
||||
--EXPECTF--
|
||||
Destination can not be empty
|
||||
Fatal error: Stomp::send(): Expects parameter 2 to be a string or a StompFrame object. in %s on line %d
|
||||
Warning: stomp_send(): Destination can not be empty in %s on line %d
|
||||
|
||||
Warning: stomp_send(): Expects parameter %d to be a string or a StompFrame object. in %s on line %d
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
string(%d) "%s"
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
--TEST--
|
||||
Test stomp::send() - tests parameters
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = new Stomp();
|
||||
|
||||
$s->send('', array());
|
||||
$s->send('/queue/test-06', array());
|
||||
var_dump($s->send('/queue/test-06', ''));
|
||||
var_dump($s->send('/queue/test-06', 'A realMessage'));
|
||||
var_dump($s->send('/queue/test-06', 'بياريك شارون'));
|
||||
var_dump($s->send('بياريك شارون', 'بياريك شارون', array('receipt' => 'message-123')), $s->error());
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Stomp::send(): Destination can not be empty in %s on line %d
|
||||
|
||||
Warning: Stomp::send(): Expects parameter %d to be a string or a StompFrame object. in %s on line %d
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
string(%d) "%s"
|
|
@ -1,21 +1,17 @@
|
|||
--TEST--
|
||||
Check stomp_subscribe
|
||||
Test Stomp::subscribe()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect("tcp://localhost:61613")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = new Stomp('tcp://localhost:61613');
|
||||
try {
|
||||
$s->subscribe('', array());
|
||||
} catch(StompException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
$s = new Stomp();
|
||||
$s->subscribe('', array());
|
||||
$s->subscribe('/queue/test', 'string');
|
||||
?>
|
||||
--EXPECTF--
|
||||
Destination can not be empty
|
||||
Warning: Stomp::subscribe(): Destination can not be empty in %s on line %d
|
||||
|
||||
Catchable fatal error: Argument 2 passed to Stomp::subscribe() must be an array, string given in %s on line %d
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
--TEST--
|
||||
Check stomp_unsubscribe
|
||||
Test Stomp::unsubscribe()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect("tcp://localhost:61613")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = new Stomp('tcp://localhost:61613');
|
||||
try {
|
||||
$s->unsubscribe('', array());
|
||||
} catch(StompException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
$s = new Stomp();
|
||||
$s->unsubscribe('', array());
|
||||
$s->unsubscribe('/queue/test', 'string');
|
||||
?>
|
||||
--EXPECTF--
|
||||
Destination can not be empty
|
||||
Warning: Stomp::unsubscribe(): Destination can not be empty in %s on line %d
|
||||
|
||||
Catchable fatal error: Argument 2 passed to Stomp::unsubscribe() must be an array, string given in %s on line %d
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
--TEST--
|
||||
Test stomp::readFrame() - tests functionnality and parameters
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = new Stomp();
|
||||
$s->send('/queue/test-09', 'A test Message');
|
||||
$s->subscribe('/queue/test-09');
|
||||
var_dump($s->readFrame()->body);
|
||||
var_dump($s->readFrame('frame'));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(14) "A test Message"
|
||||
bool(false)
|
|
@ -0,0 +1,22 @@
|
|||
--TEST--
|
||||
Test stomp_read_frame() - test functionnality and parameters
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$link = stomp_connect();
|
||||
stomp_send($link, '/queue/test-09', 'A test Message');
|
||||
stomp_subscribe($link, '/queue/test-09');
|
||||
$result = stomp_read_frame($link);
|
||||
var_dump($result['body']);
|
||||
var_dump(stomp_read_frame($link, 'frame'));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(14) "A test Message"
|
||||
|
||||
Warning: stomp_read_frame() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
NULL
|
|
@ -0,0 +1,91 @@
|
|||
--TEST--
|
||||
Test Stomp::getReadTimout() and Stomp::setReadTimeout() - tests functionnality and parameters
|
||||
--INI--
|
||||
stomp.default_read_timeout_sec=5
|
||||
stomp.default_read_timeout_usec=5
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = new Stomp();
|
||||
|
||||
// First test, read from ini variables, expected to return 5.5
|
||||
var_dump($s->getReadTimeout());
|
||||
|
||||
// Set read timout with an integer as seconds
|
||||
var_dump($s->setReadTimeout(10));
|
||||
// Second test, read supposed to return 10.0
|
||||
var_dump($s->getReadTimeout());
|
||||
|
||||
// Set read timout with an integer as seconds
|
||||
var_dump($s->setReadTimeout(10, 5));
|
||||
// Third test, read supposed to return 10.5
|
||||
var_dump($s->getReadTimeout());
|
||||
|
||||
// Set read timout with the first param as a string, supposed to trigger a warning
|
||||
var_dump($s->setReadTimeout(''));
|
||||
// Fourth test, read supposed to get the last value set : 10.5
|
||||
var_dump($s->getReadTimeout());
|
||||
|
||||
// Set read timout with the second param as a string, supposed to trigger a warning
|
||||
var_dump($s->setReadTimeout(10, ''));
|
||||
// Fourth test, read supposed to get the last value set : 10.5
|
||||
var_dump($s->getReadTimeout());
|
||||
|
||||
// Set read timout with the params as null
|
||||
var_dump($s->setReadTimeout(null, null));
|
||||
// Fifth test, read supposed to get the last value set : 0.0
|
||||
var_dump($s->getReadTimeout());
|
||||
|
||||
|
||||
unset($s);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(5)
|
||||
["usec"]=>
|
||||
int(5)
|
||||
}
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(10)
|
||||
["usec"]=>
|
||||
int(0)
|
||||
}
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(10)
|
||||
["usec"]=>
|
||||
int(5)
|
||||
}
|
||||
|
||||
Warning: Stomp::setReadTimeout() expects parameter 1 to be long, string given in %s on line %d
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(10)
|
||||
["usec"]=>
|
||||
int(5)
|
||||
}
|
||||
|
||||
Warning: Stomp::setReadTimeout() expects parameter 2 to be long, string given in %s on line %d
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(10)
|
||||
["usec"]=>
|
||||
int(5)
|
||||
}
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(0)
|
||||
["usec"]=>
|
||||
int(0)
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
--TEST--
|
||||
Test stomp_get_read_timout() and stomp_set_read_timeout() - tests functionnality and parameters
|
||||
--INI--
|
||||
stomp.default_read_timeout_sec=5
|
||||
stomp.default_read_timeout_usec=5
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$link = stomp_connect();
|
||||
|
||||
// First test, read from ini variables, expected to return 5.5
|
||||
var_dump(stomp_get_read_timeout($link));
|
||||
|
||||
// Set read timout with an integer as seconds
|
||||
var_dump(stomp_set_read_timeout($link, 10));
|
||||
// Second test, read supposed to return 10.0
|
||||
var_dump(stomp_get_read_timeout($link));
|
||||
|
||||
// Set read timout with an integer as seconds
|
||||
var_dump(stomp_set_read_timeout($link, 10, 5));
|
||||
// Third test, read supposed to return 10.5
|
||||
var_dump(stomp_get_read_timeout($link));
|
||||
|
||||
// Set read timout with the first param as a string, supposed to trigger a warning
|
||||
var_dump(stomp_set_read_timeout($link, ''));
|
||||
// Fourth test, read supposed to get the last value set : 10.5
|
||||
var_dump(stomp_get_read_timeout($link));
|
||||
|
||||
// Set read timout with the second param as a string, supposed to trigger a warning
|
||||
var_dump(stomp_set_read_timeout($link, 10, ''));
|
||||
// Fourth test, read supposed to get the last value set : 10.5
|
||||
var_dump(stomp_get_read_timeout($link));
|
||||
|
||||
// Set read timout with the params as null
|
||||
var_dump(stomp_set_read_timeout($link, null, null));
|
||||
// Fifth test, read supposed to get the last value set : 0.0
|
||||
var_dump(stomp_get_read_timeout($link));
|
||||
|
||||
|
||||
unset($s);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(5)
|
||||
["usec"]=>
|
||||
int(5)
|
||||
}
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(10)
|
||||
["usec"]=>
|
||||
int(0)
|
||||
}
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(10)
|
||||
["usec"]=>
|
||||
int(5)
|
||||
}
|
||||
|
||||
Warning: stomp_set_read_timeout() expects parameter 2 to be long, string given in %s on line %d
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(10)
|
||||
["usec"]=>
|
||||
int(5)
|
||||
}
|
||||
|
||||
Warning: stomp_set_read_timeout() expects parameter 3 to be long, string given in %s on line %d
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(10)
|
||||
["usec"]=>
|
||||
int(5)
|
||||
}
|
||||
NULL
|
||||
array(2) {
|
||||
["sec"]=>
|
||||
int(0)
|
||||
["usec"]=>
|
||||
int(0)
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
--TEST--
|
||||
Test Stomp::commit() - tests functionnality and parameters
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("stomp")) print "skip";
|
||||
if (!stomp_connect()) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = new Stomp();
|
||||
|
||||
/* begin a transaction */
|
||||
var_dump($s->begin('t1'));
|
||||
|
||||
// sends a message to the queue and specifies a good transaction
|
||||
var_dump($s->send('/queue/test-011-commit', 'bar', array('transaction' => 't1')));
|
||||
|
||||
// sends a message to the queue and asks for a receipt
|
||||
$s->send('/queue/test-011-commit', 'bar', array('transaction' => 't2', 'receipt' => 'tptp'));
|
||||
var_dump($s->error());
|
||||
|
||||
// commits a valid transaction
|
||||
var_dump($s->commit('t1'));
|
||||
|
||||
// commits non valid transaction (null as a parameter) and asks for a receipt
|
||||
var_dump($s->commit(null, array('receipt' => 'commit-key')));
|
||||
var_dump($s->commit(null));
|
||||
|
||||
// commits a non valid transaction (a transaction id that does not exist) and asks for a receipt
|
||||
$s->commit('t2', array('receipt' => 'commit-key'));
|
||||
var_dump($s->error());
|
||||
|
||||
unset($s);
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
bool(true)
|
||||
string(%d) "Invalid transaction id: %s"
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
string(%d) "Must specify the transaction you are committing"
|
Loading…
Reference in New Issue