<?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");
});
Exemplo n.º 2
0
<?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");
});