<?php

namespace Preview\DSL\BDD;

require_once 'ok.php';
shared_example("stack", function ($group) {
    describe("#pop", function () {
        it("should return the last item", function () {
            $end = end($this->subject);
            ok(array_pop($this->subject) == $end);
        });
        it("remove the last item", function () {
        });
    })->group($group);
});
describe("world", function () {
    before_each(function () {
        $this->subject = array(1, 2, 3);
    });
    it_behaves_like("stack", "hello world");
});
<?php

namespace Preview\DSL\BDD;

require_once __DIR__ . '/../ok.php';
shared_example("to share test", function () {
    it("will use the caller's context", function () {
        ok($this->name == "wenjun.yan");
    });
    describe("create a test suite here", function () {
        it("and still have access to vars defined caller", function () {
            ok($this->name == "wenjun.yan");
        });
    });
});
describe("it_behaves_like", function () {
    before_each(function () {
        $this->name = "wenjun.yan";
    });
    /*
     * the following line will be replaced by
     * code defined in shared_exmaple "to share test";
     */
    it_behaves_like("to share test");
});
Exemple #3
0
            ok($e instanceof \Exception);
        });
    });
    describe("#error_or_failed", function () {
        it("should return failure exception", function () {
            $e = $this->result->error_or_failed();
            ok($e instanceof \Exception);
        });
    });
});
shared_example("error test result", function () {
    describe("#error", function () {
        it("should return error exception", function () {
            $e = $this->result->error();
            ok($e instanceof \ErrorException);
        });
    });
    describe("#error_or_failed", function () {
        it("should return failure exception", function () {
            $e = $this->result->error_or_failed();
            ok($e instanceof \ErrorException);
        });
    });
});
shared_example("grouped test result", function () {
    describe("#groups", function () {
        it("should return array of groups", function () {
            ok($this->result->groups() == $this->groups);
        });
    });
});