Exemplo n.º 1
0
function souk($app, $user_id = NULL)
{
    static $log;
    if (!isset($log)) {
        $log = function ($action, Gaia\Souk\Listing $listing) {
            Tap::debug('LOG: ' . $listing->id . ': ' . $action);
        };
    }
    return new Gaia\Souk\Logger(new Gaia\Souk($app, $user_id), $log);
}
Exemplo n.º 2
0
<?php

use Gaia\DB;
use Gaia\Test\Tap;
include __DIR__ . '/../lib/setup.php';
include __DIR__ . '/../../assert/pdo_installed.php';
include __DIR__ . '/../../assert/pdo_sqlite_installed.php';
DB\Connection::load(array('test' => function () {
    $db = new DB\Driver\PDO('sqlite:/tmp/souk.db');
    $cb = array('start' => function () {
        $i = \Gaia\DB\Transaction::internals();
        Tap::debug('TXN: start ' . $i['depth']);
    }, 'commit' => function () {
        $i = \Gaia\DB\Transaction::internals();
        Tap::debug('TXN: commit ' . $i['depth']);
    }, 'rollback' => function () {
        $i = \Gaia\DB\Transaction::internals();
        Tap::debug('TXN: rollback ' . $i['depth']);
    }, 'query' => function ($args) {
        $query = array_shift($args);
        $query = \Gaia\DB\Query::format($query, $args);
        Tap::debug('QUERY: ' . $query);
    });
    //$db = new DB\Observe( $db, $cb);
    return $db;
}));
    }
}
Tap::ok(!$res, 'none of the data exists before I write it in the cache');
if ($res) {
    Tap::debug($ret);
}
$res = TRUE;
$ret = array();
foreach ($data as $k => $v) {
    if (!($ret[$k] = $cache->set($k, $v, 10))) {
        $res = FALSE;
    }
}
Tap::ok($res, 'wrote all of my data into the cache');
if (!$res) {
    Tap::debug($ret);
}
$res = TRUE;
foreach ($data as $k => $v) {
    if ($cache->get($k) != $v) {
        $res = FALSE;
    }
}
Tap::ok($res, 'checked each key and got back what I wrote');
$ret = $cache->get(array_keys($data));
$res = TRUE;
foreach ($data as $k => $v) {
    if ($ret[$k] != $v) {
        $res = FALSE;
    }
}
Exemplo n.º 4
0
#!/usr/bin/env php
<?php 
include __DIR__ . '/../common.php';
include __DIR__ . '/../../tests/assert/memcache_installed.php';
include __DIR__ . '/../../tests/assert/curl_installed.php';
include __DIR__ . '/../../tests/assert/couchbase_running.php';
include __DIR__ . '/../../tests/assert/memcache_running.php';
use Gaia\Store;
use Gaia\Test\Tap;
include __DIR__ . '/../common.php';
$cb = new Store\Couchbase(array('app' => 'dev_jloehrer-zoo', 'rest' => 'http://127.0.0.1:8092/default/', 'socket' => '127.0.0.1:11211'));
$cb->view()->set('mammals', array('map' => 'function(doc){ if( doc.type=="mammal" ){ emit(doc._id, doc); }}'));
$http = new \Gaia\Http\Request("http://127.0.0.1:8092/default/_design/dev_jloehrer-zoo/");
$result = json_decode($http->exec()->body, TRUE);
Tap::debug($result['views']['mammals']['map']);
$cb->set('bear', array('type' => 'mammal', 'eats' => 'meat', 'legs' => 4));
Tap::debug($cb->get('bear'));
Tap::debug($cb->view()->query('mammals', array('full_set' => 'true', 'connection-timeout' => 6000)));
Exemplo n.º 5
0
<?php

use Gaia\Test\Tap;
if (!isset($db)) {
    die("\n do not access this file directly\n");
}
$db = new Gaia\DB($db);
Tap::debug($db, 'db object');
$rs = $db->execute('select 1 as test UNION select 2 as test');
Tap::debug($rs, 'result object');
Tap::debug($rs->affected(), 'affected rows');
$rows = array();
while ($row = $rs->fetch()) {
    $rows[] = $row;
}
Tap::debug($rows, 'result set');