Peridot\Core\Test::run PHP Method

run() public method

Execute the test along with any setup and tear down functions.
public run ( Peridot\Core\TestResult $result ) : void
$result Peridot\Core\TestResult
return void
    public function run(TestResult $result)
    {
        $result->startTest($this);
        if ($this->getPending()) {
            $result->pendTest($this);
            return;
        }
        $this->executeTest($result);
        $result->endTest($this);
    }

Usage Example

Beispiel #1
0
         });
         it('should not result in a pass and fail if tear down fails', function () {
             $test = new Test("passing", function () {
             });
             $test->addTearDownFunction(function () {
                 throw new Exception("failure");
             });
             $emitter = new EventEmitter();
             $count = 0;
             $emitter->on('test.passed', function () use(&$count) {
                 $count++;
             });
             $emitter->on('test.failed', function () use(&$count) {
                 $count++;
             });
             $test->run(new TestResult($emitter));
             assert($count == 1, "should not have emitted a pass and fail event");
         });
     });
 });
 describe("->getTitle()", function () {
     it("should return the full text for a spec including parents", function () {
         $root = new Suite("parent", function () {
         });
         $child = new Suite("nested", function () {
         });
         $test = new Test("should be rad", function () {
         });
         $child->addTest($test);
         $root->addTest($child);
         assert($test->getTitle() == "parent nested should be rad", "title should include text from parents");