Ejemplo n.º 1
0
<?php

namespace Preview\DSL\TDD;

require_once 'ok.php';
suite("array_pop", function () {
    suite_setup(function () {
        // connect to database.
    });
    // run before each test case;
    setup(function () {
        $this->arr = array(1, 2);
    });
    // use the variable set in the setup function
    test("return last element", function () {
        ok(array_pop($this->arr) == 2);
    });
    // skip this case
    test("return null for empty string", function () {
        $tmp = array_pop(array());
        ok(empty($tmp));
    })->skip();
    // pending test case
    test("array_pop a string?");
});
Ejemplo n.º 2
0
        $this->usage = "run suite_setup the current test suite";
    });
    suite_setup(function () {
        $this->note_1 = "suite_setup hooks are run in order";
    });
    suite_setup(function () {
        $this->ref = new \stdClass();
        $this->ref->name = "wenjun.yan";
        $this->value = "string";
    });
    test("can access the variable set in suite_setup hooks", function () {
        ok($this->note_1);
        ok($this->note_2);
        ok($this->value);
        ok($this->ref->name);
        $this->value = null;
        $this->ref->name = null;
    });
    test("suite_setup hooks run only once in current test suite", function () {
        /*
         * run tests in order, this will pass.
         */
        ok($this->value);
        // string is passed by value
        ok(empty($this->ref->name));
        // object is passed by "ref".
    });
    suite_setup(function () {
        $this->note_2 = "wherever you put the suite_setup each hook, " . "it will run suite_setup this suite";
    });
});