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
T::ok(Transaction::rollback(), 'rolled back the transaction at the global level');
T::ok($rs = $dbmain->execute("select id from {$table}"), 'selected all rows from the table');
$ct = $rs->affected();
T::is($ct, 2, '2 rows in the table, new rows rolled back');
$rs = $conn1->execute("select id from {$table}");
T::is($rs, FALSE, 'after rolling back, new queries fail on rolled back db object');
$dbmain->execute("drop table {$table}");
$db = $newconn();
$raw = file_get_contents(__DIR__ . '/sample/i_can_eat_glass.txt');
$lines = explode("\n", $raw);
$lines = array_slice($lines, 0, 10) + array_slice($lines, 100, 10) + array_slice($lines, 200, 10) + array_slice($lines, 200, 10);
$raw = implode("\n", $lines);
$sql = "CREATE TEMPORARY TABLE t1utf8 (`i` INT UNSIGNED NOT NULL PRIMARY KEY, `line` VARCHAR(5000) ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8";
$db->execute($sql);
foreach ($lines as $i => $line) {
    //$lines[ $i ] = $line = mb_convert_encoding($line, 'UTF-8', 'auto');
    $db->execute('INSERT INTO t1utf8 (`i`, `line`) VALUES (%i, %s)', $i, $line);
}
$rs = $db->execute('SELECT * FROM t1utf8');
$readlines = array();
while ($row = $rs->fetch()) {
    $readlines[$row['i']] = $row['line'];
}
$rs->free();
T::cmp_ok($readlines, '===', $lines, 'inserted all the rows and read them back, worked as expected');
//T::debug( $readlines );
$rs = $db->execute('SELECT %s AS `d`', $raw);
$row = $rs->fetch();
$rs->free();
T::cmp_ok($row['d'], '===', $raw, 'passed a huge chunk of utf-8 data to db and asked for it back. got what I sent.');
//T::debug( $row['d'] );
Esempio n. 7
0
$each = array();
while (list($k, $v) = $c->each()) {
    $each[$k] = $v;
}
T::is($c->all(), $each, 'each loop returns all the data in the container');
T::is(array_keys($input), $c->keys(), 'keys returns all the keys passed to input');
T::is(array_keys($input, 'a'), $c->keys('a'), 'search for a key');
T::is($c->pop(), $v = array_pop($input), 'popped off an element, same as input');
T::is($c->push($v), array_push($input, $v), 'pushed an element back onto the container');
T::is($c->all(), $input, 'after pop and push, input matches container');
T::is($c->shift(), $v = array_shift($input), 'shifted off an element, same as input');
T::is($c->unshift($v), array_unshift($input, $v), 'unshift an element back onto the container');
T::is($c->all(), $input, 'after shift and unshift, input matches container');
@asort($input);
@$c->sort();
T::is($c->all(), $input, 'after sorting, matches sorted input');
ksort($input);
$c->ksort();
T::is($c->all(), $input, 'after key sorting, matches sorted input');
krsort($input);
T::is($c->all(), $input, 'after reverse key sorting, matches sorted input');
$c->flush();
T::is($c->all(), array(), 'flush removes everything from the container');
$c->load($input);
T::is($c->all(), $input, 'load puts it all back in again');
$c->push(0);
$c->push(NULL);
array_push($input, 0);
array_push($input, NULL);
T::is($c->keys(NULL, TRUE), array_keys($input, NULL, TRUE), 'strict match works');
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
T::is($cache->set($k, $v = '0'), TRUE, 'setting a key to zero returns true');
T::cmp_ok($cache->get($k), '===', $v, 'after setting the key to 0, get returns zero value');
T::cmp_ok($cache->get(array($k)), '===', array($k => $v), 'multi-get returns the key with zero value');
T::ok($cache->set($k, 1, $ttl = 3600 * 24 * 30), 'setting with a huge timeout');
T::cmp_ok(strval($cache->get($k)), '===', '1', 'get returns correct value');
$incr = 1000000;
T::ok($cache->increment($k, $incr), 'incrementing with a large number');
T::cmp_ok(strval($cache->get($k)), '===', strval($incr + 1), 'get returns correct value');
T::ok($cache->decrement($k, $incr), 'decrementing with a large number');
T::cmp_ok(intval($cache->get($k)), '===', 1, 'get returns correct value');
$huge_number = 9223372036854775806;
if (!is_int($huge_number)) {
    $huge_number = 2147483646;
}
T::Debug("testing with {$huge_number}");
T::ok($cache->set($k, $v = $huge_number), 'setting a huge number');
T::cmp_ok(strval($cache->get($k)), '===', strval($v), 'get returns correct value');
$v = $v + 1;
T::cmp_ok(strval($cache->increment($k, 1)), '===', strval($v), 'increment a huge number by 1');
T::cmp_ok(strval($cache->get($k)), '===', strval($v), 'get returns correct value');
$cache->set($k, $v);
$v = $v - 1;
T::cmp_ok(strval($cache->decrement($k, 1)), '===', strval($v), 'decrement a huge number by 1');
T::cmp_ok(strval($cache->get($k)), '===', strval($v), 'get returns correct value');
$k = 'wukka/cache/test/' . microtime(TRUE) . '/' . mt_rand(1, 10000);
$v = '我能吞下玻璃而不傷身體';
T::ok($cache->set($k, $v), 'setting a string with utf-8 chars in it');
T::cmp_ok(strval($cache->get($k)), '===', $v, 'get returns correct value');
T::ok($cache->delete($k), 'deleting the key');
T::cmp_ok($cache->get($k), '===', NULL, 'after deleting, get returns NULL');
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');
}