Preview::$world = $this->test_world; Preview::$config = $this->test_config; ok($message == array("test first", "then teardown", "test first", "then teardown")); }); }); describe("#before", function () { it("should run before the testsuite", function () { // start new env Preview::$world = $this->world; Preview::$config = $this->config; // -- test start -- $message = array(); $total = 0; $suite = new Suite("sample suite"); $suite->before(function () use(&$message, &$total) { $message[] = "before"; $total++; }); $suite->before_each(function () use(&$message) { $message[] = "before_each first"; }); $suite->test("add a new message", function () use(&$message) { $message[] = "then it"; }); $suite->test("add a new message", function () use(&$message) { $message[] = "then it"; }); $suite->load(); $this->world->run(); // -- test end -- // end new env Preview::$world = $this->test_world;