Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Description
-----------

[![Build Status](https://api.travis-ci.org/Timandes/php-zookeeper.svg?branch=master)](https://travis-ci.org/Timandes/php-zookeeper)
[![Build Status](https://img.shields.io/travis/fabiorphp/php-zookeeper/master.svg?style=flat-square)](https://travis-ci.org/fabiorphp/php-zookeeper)
[![Coveralls](https://img.shields.io/coveralls/fabiorphp/php-zookeeper.svg?style=flat-square)](https://coveralls.io/r/fabiorphp/php-zookeeper?branch=master)


This extension uses libzookeeper library to provide API for communicating with
Expand Down
13 changes: 13 additions & 0 deletions tests/add_auth.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should add auth
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
echo $client->addAuth('test', 'test');
--EXPECT--
1
13 changes: 13 additions & 0 deletions tests/check_if_exists_without_connect.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should check if node exists without connect
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper();
$client->exists('/test1');
--EXPECTF--
Warning: Zookeeper::exists(): Zookeeper connect was not called in %s on line %d
20 changes: 20 additions & 0 deletions tests/create_node_without_connect.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Should create node without connect
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper();

$client->create('/test6', null, array(
array(
'perms' => Zookeeper::PERM_ALL,
'scheme' => 'world',
'id' => 'anyone'
)
));
--EXPECTF--
Warning: Zookeeper::create(): Zookeeper connect was not called in %s on line %d
25 changes: 25 additions & 0 deletions tests/extension_info.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Show extension info
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php

ob_start();
phpinfo(INFO_MODULES);

$data = ob_get_clean();

if (preg_match('/zookeeper/', $data)) {
echo true;
}

if (preg_match('/zookeeper support([ =>\t]*)(.*)/', $data, $match)) {
echo trim(end($match));
}

--EXPECTF--
1enabled
13 changes: 13 additions & 0 deletions tests/remove_node_without_connect.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should delete node without connect
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper();
$client->delete('/test5');
--EXPECTF--
Warning: Zookeeper::delete(): Zookeeper connect was not called in %s on line %d
16 changes: 16 additions & 0 deletions tests/retrieve_acl.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Should retrieve acl
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
$acl = $client->getAcl('/zookeeper');
echo $acl[1][0]['perms'] === Zookeeper::PERM_ALL;
echo $acl[1][0]['scheme'];
echo $acl[1][0]['id'];
--EXPECTF--
1worldanyone
13 changes: 13 additions & 0 deletions tests/retrieve_acl_error_with_invalid_node.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve error when set invalid node
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
$client->getAcl('/zoo');
--EXPECTF--
Warning: Zookeeper::getAcl(): error: no node in %s on line %d
13 changes: 13 additions & 0 deletions tests/retrieve_acl_without_connect.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve acl without connect
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper();
$client->getAcl('/zookeeper');
--EXPECTF--
Warning: Zookeeper::getAcl(): Zookeeper connect was not called in %s on line %d
13 changes: 13 additions & 0 deletions tests/retrieve_bool_is_recoverable.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve bool if is recoverable
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
echo $client->isRecoverable();
--EXPECT--
1
13 changes: 13 additions & 0 deletions tests/retrieve_bool_is_recoverable_without_conect.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve bool if is recoverable without connect
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper();
$client->isRecoverable();
--EXPECTF--
Warning: Zookeeper::isRecoverable(): Zookeeper connect was not called in %s on line %d
13 changes: 13 additions & 0 deletions tests/retrieve_children.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve children
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
echo count($client->getChildren('/zookeeper'));
--EXPECTF--
%d
13 changes: 13 additions & 0 deletions tests/retrieve_children_with_invalid_node.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve children with invalid node
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
$client->getChildren('/zoo');
--EXPECTF--
Warning: Zookeeper::getChildren(): error: no node in %s on line %d
13 changes: 13 additions & 0 deletions tests/retrieve_children_with_watcher_callback.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve children with watcher callback
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
echo count($client->getChildren('/zookeeper', function(){}));
--EXPECTF--
%d
13 changes: 13 additions & 0 deletions tests/retrieve_children_without_connect.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve children without connect
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper();
$client->getChildren('/zookeeper');
--EXPECTF--
Warning: Zookeeper::getChildren(): Zookeeper connect was not called in %s on line %d
13 changes: 13 additions & 0 deletions tests/retrieve_client_id_without_connect.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should get client id without_connect
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper();
$client->getClientId();
--EXPECTF--
Warning: Zookeeper::getClientId(): Zookeeper connect was not called in %s on line %d
13 changes: 13 additions & 0 deletions tests/retrieve_error_recv_timeout_with_invalid_param.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve error recv timeout with invalid parameter
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
$client->getRecvTimeout(array());
--EXPECTF--
Warning: Zookeeper::getRecvTimeout() expects exactly %d parameters, %d given in %s on line %d
13 changes: 13 additions & 0 deletions tests/retrieve_error_when_get_node_with_invalid_param.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should get Zookeeper node with invalid parameter
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
$client->get(array());
--EXPECTF--
Warning: Zookeeper::get() expects parameter %d to be string, array given in %s on line %d
13 changes: 13 additions & 0 deletions tests/retrieve_error_when_getchildren_with_invalid_param.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve error when get children with invalid param
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
$client->getChildren(array());
--EXPECTF--
Warning: Zookeeper::getChildren() expects parameter %d to be string, array given in %s on line %d
13 changes: 13 additions & 0 deletions tests/retrieve_error_with_invalid_acl_param.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should retrieve error when set invalid acl parameter
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
$client->getAcl(array());
--EXPECTF--
Warning: Zookeeper::getAcl() expects parameter %d to be string, array given in %s on line %d
23 changes: 23 additions & 0 deletions tests/retrieve_node.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Should get Zookeeper node
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
$client->create('/test1', 'something', array(
array(
'perms' => Zookeeper::PERM_ALL,
'scheme' => 'world',
'id' => 'anyone'
)
));

echo $client->get('/test1');

$client->delete('/test1');
--EXPECT--
something
24 changes: 24 additions & 0 deletions tests/retrieve_node_with_maxsize_param.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
Should get node with max size
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper('localhost:2181');
$client->create('/test1', 'something', array(
array(
'perms' => Zookeeper::PERM_ALL,
'scheme' => 'world',
'id' => 'anyone'
)
));

$stat = '';
echo $client->get('/test1', null, $stat, 10);

$client->delete('/test1');
--EXPECT--
something
21 changes: 21 additions & 0 deletions tests/retrieve_node_with_watcher_callback.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Should get Zookeeper node with watcher callback
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
class Test extends Zookeeper
{
public function watcher($i, $type, $key)
{
$this->get('/zookeeper', array($this, 'watcher'));
}
}

$test = new Test('127.0.0.1:2181');
echo gettype($test->get('/zookeeper', array($test, 'watcher')));
--EXPECT--
NULL
13 changes: 13 additions & 0 deletions tests/retrieve_node_without_connect.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Should get node without connect
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded'
};
--FILE--
<?php
$client = new Zookeeper();
$client->get('/test1');
--EXPECTF--
Warning: Zookeeper::get(): Zookeeper connect was not called in %s on line %d
Loading