예제 #1
0
파일: index.php 프로젝트: wikidi/envtesting
$returns->addTest('JSON', function () {
    return (object) array('stdClass' => 'ok');
}, 'return');
$returns->addTest('BOOL', function () {
    return false;
}, 'return');
$returns->addTest('BOOL', function () {
    return true;
}, 'return');
$returns->addTest('empty', function () {
    /* empty */
}, 'return');
$returns->addTest('NULL', function () {
    return null;
}, 'return');
// callbacks
$callback = Suite::instance()->callback;
$callback->addTest('MISSING', 'missing file', 'callback');
$callback->addTest('PHP BUG', function () {
    return $response;
}, 'callback');
$multiline = Suite::instance()->multiline;
$multiline->addTest('PHP BUG', function () {
    throw new Warning('add' . PHP_EOL . 'multiline' . PHP_EOL . 'text');
}, 'callback');
$multiline->addTest('PHP BUG', function () {
    return 'ok' . PHP_EOL . 'multiline' . PHP_EOL . 'text';
}, 'callback');
// render HTML
Suite::instance()->run()->render();
Throws::nothing();
예제 #2
0
<?php

namespace envtesting;

require_once dirname(__DIR__) . '/vendor/autoload.php';
/**
 * @author Roman Ozana <*****@*****.**>
 */
Throws::allErrors();
// throw WARNING and NOTICE as Exception
$filter = Filter::instanceFromArray($_GET);
$suite = Suite::instance('My Suite', $filter)->failGroupOnFirstError();
// ---------------------------------------------------------------------------------------------------------------------
// memcache
// ---------------------------------------------------------------------------------------------------------------------
$memcache = $suite->memcache;
/** @var Suit $memcache */
$memcache->addTest('Memcache', dirname(__DIR__) . '/envtests/library/Memcache.php', 'library');
$memcache->addTest('APP Memcache', new \envtests\application\memcache\Operations('127.0.0.1', 11211), 'application')->setNotice('server');
// ---------------------------------------------------------------------------------------------------------------------
// mongo
// ---------------------------------------------------------------------------------------------------------------------
$dsn = 'mongodb://localhost:27017/testomato';
// can be read from your config;
$options = array('connectTimeoutMS' => 3000);
$mongo = $suite->mongo;
/** @var Suit $mongo */
$mongo->addTest('Mongo', dirname(__DIR__) . '/envtests/library/Mongo.php', 'library');
$mongo->addTest('mongo:connect', new \envtests\services\mongo\Connection($dsn, $options), 'service');
$mongo->addTest('mongo:operations', new \envtests\application\mongo\Operations($dsn, $options), 'application');
// ---------------------------------------------------------------------------------------------------------------------
예제 #3
0
파일: csv.php 프로젝트: wikidi/envtesting
<?php

namespace envtesting;

require_once dirname(__DIR__) . '/vendor/autoload.php';
/**
 * Generat CSV output
 *
 * @author Roman Ozana <*****@*****.**>
 */
$suite = Suite::instance('CSV sample');
$suite->addTest('csv', function () {
    return 'response';
}, 'lib');
$suite->addTest('csv', function () {
    return new Error('test' . PHP_EOL . 'now line' . PHP_EOL);
}, 'lib');
$suite->run()->render('csv');