示例#1
0
<?php

namespace Preview\DSL\Testify;

require_once 'ok.php';
$suite = new Suite("array functions");
$child = new Suite("String functions");
$suite->add_child($child);
$child->test(function () {
    ok(true);
});
$suite->before_each(function () {
    $this->arr = array(1, 2, 3, 4);
});
$suite->test("array_push", function () {
    array_push($this->arr, 1);
    ok(end($this->arr) == 1);
});
$suite->test("array_pop", "pop", function () {
    array_pop($this->arr);
    ok(end($this->arr) == 3);
});
$suite->load();
示例#2
0
<?php

namespace Preview\DSL\Testify;

require_once 'stack.php';
require_once __DIR__ . '/../ok.php';
$suite = new Suite("Stack[testify]");
$suite->before_each(function () {
    $this->stack = new \Stack(array(1, 2, 3));
})->test("#size returns the size of stack", function () {
    ok($this->stack->size() == 3);
})->test("#peek eturns the last element", function () {
    ok($this->stack->peek() == 3);
})->test("#push pushes an element to stack", function () {
    $this->stack->push(4);
    ok($this->stack->peek() == 4);
    ok($this->stack->size() == 4);
})->test("#pop pops out the last element", function () {
    ok($this->stack->pop() == 3);
    ok($this->stack->size() == 2);
})->load();
示例#3
0
<?php

/*
 * How to use before hooks.
 */
namespace Preview\DSL\Testify;

require_once __DIR__ . '/../ok.php';
$suite = new Suite("A sample test suite");
$suite->before(function () {
    $this->usage = "run before current test suite";
})->before(function () {
    $this->note_1 = "can have multiple before hooks";
})->before(function () {
    $this->note_2 = "before hooks are run in order";
})->before(function () {
    $this->ref = new \stdClass();
    $this->ref->name = "wenjun.yan";
    $this->value = "string";
});
$suite->test("It can access vars defined in before hook", function () {
    ok($this->note_1);
    ok($this->note_2);
    ok($this->note_3);
    ok($this->ref->name);
    ok($this->value);
    $this->value = null;
    $this->ref->name = null;
})->test("before hooks are run only once", function () {
    // $this-value and $this->ref are reassigned.
    ok($this->value);
示例#4
0
 /**
  * Check if input test is active
  *
  * @param Test $test
  * @param Suite $suite
  * @return boolean
  */
 public function isValid(Test $test, Suite $suite)
 {
     return $this->isActive() ? $this->name && $test->getName() === $this->name || $this->type && $test->getType() === $this->type || $this->group && $suite->getCurrentGroupName() === $this->group : true;
 }
示例#5
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');
// ---------------------------------------------------------------------------------------------------------------------
示例#6
0
<?php

/*
 * How to make a test suite/case pending.
 */
namespace Preview\DSL\Testify;

require_once __DIR__ . '/../ok.php';
$suite = new Suite("A sample test suite");
$suite->test("a test case", function () {
    ok(true);
});
$suite->test("a pending test case");
// load this test suite.
$suite->load();
示例#7
0
文件: ini.php 项目: wikidi/envtesting
<?php

namespace envtesting;

/**
 * Test chek php.ini variables
 *
 * @author Roman Ozana <*****@*****.**>
 */
require_once dirname(__DIR__) . '/vendor/autoload.php';
$suite = new Suite('php.ini settings');
// check log_errors
$suite->addTest('error_reporting', function () {
    Assert::true(Check::ini('log_errors', '1'), 'log_errors is OFF');
})->setType('INI');
// check display errors
$suite->addTest('display_errors', function () {
    Assert::true(Check::ini('display_errors', '1'), 'display_errors is OFF');
})->setType('INI');
// check post_max_size
$suite->addTest('post_max_size', function () {
    $size = Check::ini('post_max_size');
    Assert::true($size > 256, 'post_max_size = ' . $size . ' is smaller then 256MB');
})->setType('INI');
echo '<pre>' . $suite->run() . '</pre>';
try {
    Assert::true(Check::ini('post_max_size') > 10000, 'post_max_size is smaller then 10000 MB');
    Assert::true(Check::ini('log_errors', '1'), 'log_errors is OFF');
    Assert::true(Check::ini('display_errors', '1'), 'log_errors is OFF');
} catch (\envtesting\Error $e) {
    echo '<pre>Error: ' . $e->getMessage() . '</pre>';
示例#8
0
<?php

/*
 * Basic usage.
 */
namespace Preview\DSL\Testify;

require_once __DIR__ . '/../ok.php';
$suite = new Suite("A sample test suite");
$suite->test("a test case", function () {
    ok(true);
})->test(function () {
    // a test case with no description;
    ok(true);
});
$child = new Suite("Child test suite");
$child->test("test case in child test suite", function () {
    ok(true);
});
$suite->add_child($child);
// load this test suite.
$suite->load();
示例#9
0
文件: pecs.php 项目: eugeneware/pecs
 function __construct($description = null, $func = null, $parent = null)
 {
     parent::__construct($description, $func, $parent);
     $this->description = $description;
 }
示例#10
0
<?php

/*
 * How to use before each hooks.
 */
namespace Preview\DSL\Testify;

require_once __DIR__ . '/../ok.php';
$suite = new Suite("A sample test suite.");
$suite->before_each(function () {
    $this->usage = "run before each test case in current test suite";
})->before_each(function () {
    $this->note_1 = "can have multiple before each hooks";
})->before_each(function () {
    $this->note_2 = "before each hooks are run in order";
});
$suite->test("It can access vars defined in before each hook", function () {
    ok($this->note_1);
    ok($this->note_2);
    ok($this->note_3);
});
$suite->before_each(function () {
    $this->note_3 = "wherever you put the before each hook, " . "it will run before each test case";
});
// load this test suite.
$suite->load();
示例#11
0
$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();
示例#12
0
<?php

/*
 * How to skip a test suite/case pending.
 */
namespace Preview\DSL\Testify;

require_once __DIR__ . '/../ok.php';
$suite = new Suite("A sample test suite");
$suite->test("a skipped test case", "skip", function () {
    ok(true);
});
$yasuite = new Suite("skipped suite", "skip");
$yasuite->test("a test case", function () {
    ok(true);
});
// load this test suite.
$yasuite->load();
$suite->load();
示例#13
0
<?php

/*
 * How to use after_each hooks.
 */
namespace Preview\DSL\Testify;

require_once __DIR__ . '/../ok.php';
$suite = new Suite("A sample test suite");
$suite->after_each(function () {
    $this->usage = "run after each test case in current test suite";
})->after_each(function () {
    $this->note_1 = "can have multiple after_each hooks";
})->after_each(function () {
    $this->note_2 = "after_each hooks are run in order";
});
$suite->test("a sample test case", function () {
    ok(true);
});
$suite->after_each(function () {
    $this->note_3 = "wherever you put the after_each hook, " . "it will run after_each this suite";
});
// load this test suite.
$suite->load();
示例#14
0
<?php

namespace envtesting;

require_once dirname(__DIR__) . '/vendor/autoload.php';
/**
 * @author Roman Ozana <*****@*****.**>
 */
$suite = new Suite('Using PHP files for test');
// ---------------------------------------------------------------------------------------------------------------------
// Even simple require_once file test
// ---------------------------------------------------------------------------------------------------------------------
$suite->addTest('APC', 'envtests/library/Apc.php', 'apc');
$suite->addTest('APC2', 'envtests/library/Apc.php', 'apc');
$suite->addTest('bzip2', 'envtests/library/Bzip2.php');
$suite->addTest('curl', 'envtests/library/Curl.php');
$suite->addTest('gd', 'envtests/library/Gd.php');
$suite->addTest('warning', 'envtests/library/Warning.php');
$suite->addTest('error', 'envtests/library/Error.php');
echo $suite->shuffle()->run();
// randomize test oreder
// ---------------------------------------------------------------------------------------------------------------------
// print tests result yourself
// ---------------------------------------------------------------------------------------------------------------------
foreach ($suite as $tests) {
    foreach ($tests as $test) {
        echo ($test->isOk() ? '✓' : '☠') . ' ' . $test->getName() . PHP_EOL;
        // print resuly yourself
    }
}
示例#15
0
    $objType = new Suite();
    $objType->delete("type=" . TznDb::zValueToSql(getHttp($_REQUEST['type'])) . " AND " . "((finishDate < '" . strftime(TZN_DATE_SQL, PRJ_DTE_NOW) . "' " . " AND status = " . AAT_STATUS_LEVELS . ") OR (status = " . AAT_STATUS_LEVELS . "))");
    $pReload = true;
} else {
    if ($_REQUEST['mode'] == 'delete') {
        $objType = new Type();
        $objType->delete("type=" . TznDb::zValueToSql(getHttp($_REQUEST['type'])));
        $pReload = true;
    } else {
        if ($_REQUEST['mode'] == 'purgeAll') {
            $objType = new Suite();
            $objType->delete("(finishDate < " . "'" . strftime(TZN_DATE_SQL, PRJ_DTE_NOW) . "'" . " AND status = " . AAT_STATUS_LEVELS . ") OR (status = " . AAT_STATUS_LEVELS . ")");
            $pReload = true;
        } else {
            if ($_REQUEST['mode'] == 'deleteAll') {
                $objType = new Suite();
                $objType->emptyTable();
                $pReload = true;
            }
        }
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title>AAT Queue!</title>
    <link href="aat.css" rel="stylesheet" type="text/css" />
	<script language="JavaScript" src="aat.js" type="text/javascript"></script>
示例#16
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');