Esempio n. 1
0
<?php

use Wukka\Test as T;
if (!in_array('mysql', PDO::getAvailableDrivers())) {
    T::plan('skip_all', 'this version of PDO does not support mysql');
}
Esempio n. 2
0
<?php

use Wukka\Test as T;
if (!@fsockopen('127.0.0.1', 5432)) {
    T::plan('skip_all', 'postgres not running on 127.0.0.1:5432');
}
Esempio n. 3
0
<?php

use Wukka\Test as T;
if (!function_exists('curl_init')) {
    T::plan('skip_all', 'php curl library not installed');
}
Esempio n. 4
0
<?php

use Wukka\Test as T;
if (!@fsockopen('127.0.0.1', '3306')) {
    T::plan('skip_all', 'mysql-server not running on localhost');
}
Esempio n. 5
0
<?php

use Wukka\Test as T;
if (!function_exists('mysql_connect')) {
    T::plan('skip_all', 'php-postgres not installed');
}
Esempio n. 6
0
<?php

use Wukka\Test as T;
use Wukka\DB;
use Wukka\DB\Transaction;
$original = $db;
T::plan(51);
$db = new DB($db);
T::is(spl_object_hash($original), $db->hash(), 'the hash function returns the hash of the original db object');
DB\Connection::load(array('test' => function () use($db) {
    return $db;
}));
T::ok(DB\Connection::instance('test') === $db, 'db instance returns same object we instantiated at first');
T::is($db->isa('mysql'), TRUE, 'driver is mysql');
$rs = $db->execute('SELECT %s as foo, %s as bar', 'dummy\'', 'rummy');
T::ok($rs, 'query executed successfully');
T::is($rs->fetch(), array('foo' => 'dummy\'', 'bar' => 'rummy'), 'sql query preparation works on strings');
$rs = $db->execute('SELECT %i as test', '1112122445543333333333');
T::is($rs->fetch(), array('test' => '1112122445543333333333'), 'query execute works injecting big integer in');
$rs = $db->execute('SELECT %i as test', 'dummy');
T::is($rs->fetch(), array('test' => '0'), 'query execute sanitizes non integer');
$rs = $db->execute('SELECT %f as test', '1112.122445543333333333');
T::is($rs->fetch(), array('test' => '1112.122445543333333333'), 'query execute works injecting big float in');
$rs = $db->execute('SELECT %f as test', 'dummy');
T::is($rs->fetch(), array('test' => '0'), 'query execute sanitizes non float');
$query = $db->prep('%s', array('dummy', 'rummy'));
T::is($query, "'dummy', 'rummy'", 'format query handles arrays of strings');
$query = $db->prep('%i', array(1, 2, 3));
T::is($query, '1, 2, 3', 'format query handles arrays of integers');
$query = $db->prep('%f', array(1.545, 2.2, 3));
T::is($query, '1.545, 2.2, 3', 'format query handles arrays of floats');
Esempio n. 7
0
<?php

include_once __DIR__ . '/../autoload.php';
use Wukka\Test as T;
use Wukka\Store\Iterator as Container;
T::plan(22);
$c = new Container();
foreach (array('result_set', 'result_get', 'result_isset', 'result_unset') as $key) {
    ${$key} = array();
}
if (!isset($input) || !is_array($input)) {
    $input = array();
}
foreach ($input as $k => $v) {
    $result_set[$k] = $c->{$k} = $v;
    $result_isset[$k] = isset($c->{$k});
    $result_get[$k] = $c->{$k};
    unset($c->{$k});
    $result_unset[$k] = $c->{$k};
}
T::is($input, $result_set, 'set works properly');
T::is($input, $result_get, 'get works properly');
T::is(array_fill_keys(array_keys($input), TRUE), $result_isset, 'isset works properly');
T::is(array_fill_keys(array_keys($input), NULL), $result_unset, 'unset works properly');
T::is($c->non_existent, NULL, 'non-existent variables are null');
$c->load($input);
T::is($c->get(array_keys($input)), $input, 'multi-get works properly');
T::is($c->all(), $input, 'grabbed all of the data at once');
$each = array();
while (list($k, $v) = $c->each()) {
    $each[$k] = $v;
Esempio n. 8
0
File: setup.php Progetto: wukka/http
<?php

use Wukka\Test as T;
include __DIR__ . '/../autoload.php';
$host = '127.0.0.1';
$port = 11295;
if (!function_exists('curl_init')) {
    T::plan('skip_all', 'php curl library not installed');
}
if (!@fsockopen($host, $port)) {
    T::plan('skip_all', "http://{$host}:{$port}/ not started. run ./tests/start_webservice.sh");
}
$baseurl = "http://{$host}:{$port}";
Esempio n. 9
0
<?php

use Wukka\Test as T;
if (!class_exists('\\PDO')) {
    T::plan('skip_all', 'php-pdo not installed');
}
Esempio n. 10
0
<?php

use Wukka\Test as T;
if (!function_exists('apc_fetch') || !ini_get('apc.enable_cli')) {
    T::plan('skip_all', 'php5-apc extension not installed or enabled (check apc.enable_cli=1)');
}
Esempio n. 11
0
<?php

use Wukka\Test as T;
if (!@fsockopen('127.0.0.1', '11211')) {
    T::plan('skip_all', 'memcache not running on 127.0.0.1:11211');
}
Esempio n. 12
0
<?php

use Wukka\Test as T;
if (!in_array('sqlite', PDO::getAvailableDrivers())) {
    T::plan('skip_all', 'this version of PDO does not support sqlite');
}
Esempio n. 13
0
<?php

use Wukka\Test as T;
if (!@fsockopen('127.0.0.1', 11298)) {
    T::plan('skip_all', 'http://127.0.0.1:11298/ not started. run ./tests/app.start.php.sh');
}
Esempio n. 14
0
<?php

use Wukka\Test as T;
if (!class_exists('Memcache') && !class_exists('Memcached')) {
    T::plan('skip_all', 'no pecl-memcache or pecl-memcached extension installed');
}
Esempio n. 15
0
<?php

use Wukka\Test as T;
if (!class_exists('\\MySQLi')) {
    T::plan('skip_all', 'php-mysqli not installed');
}
Esempio n. 16
0
<?php

include __DIR__ . '/time_override.php';
use Wukka\Test as T;
if (!isset($skip_expiration_tests)) {
    $skip_expiration_tests = FALSE;
}
if (!isset($plan_ct)) {
    $plan_ct = 0;
}
T::plan(40 + $plan_ct);
$data = array();
for ($i = 1; $i <= 3; $i++) {
    $data['wukka/cache/test/' . microtime(TRUE) . '/' . mt_rand(1, 10000)] = $i;
}
$res = FALSE;
$ret = array();
foreach ($data as $k => $v) {
    if ($ret[$k] = $cache->get($k)) {
        $res = TRUE;
    }
}
T::ok(!$res, 'none of the data exists before I write it in the cache');
if ($res) {
    T::debug($ret);
}
$res = TRUE;
$ret = array();
foreach ($data as $k => $v) {
    if (!($ret[$k] = $cache->set($k, $v, 10))) {
        $res = FALSE;
Esempio n. 17
0
<?php

use Wukka\Test as T;
if (!in_array('pgsql', PDO::getAvailableDrivers())) {
    T::plan('skip_all', 'this version of PDO does not support postgres');
}