Exemple #1
0
<?php

use Peridot\EventEmitter;
use Peridot\Core\Test;
use Peridot\Core\TestResult;
use Peridot\Core\Suite;
use Peridot\Core\Scope;
describe("Suite", function () {
    beforeEach(function () {
        $this->eventEmitter = new EventEmitter();
    });
    context("when constructed with null definition", function () {
        it("it should default to a pending state", function () {
            $suite = new Suite("should be pending");
            assert($suite->getPending(), "suite should be pending if definition is null");
        });
    });
    describe('->run()', function () {
        it("should run multiple tests", function () {
            $suite = new Suite("Suite", function () {
            });
            $suite->addTest(new Test("should pass", function () {
            }));
            $suite->addTest(new Test('should fail', function () {
                throw new \Exception('woooooo!');
            }));
            $result = new TestResult($this->eventEmitter);
            $suite->setEventEmitter($this->eventEmitter);
            $suite->run($result);
            assert('2 run, 1 failed' == $result->getSummary(), "result summary should show 2/1");
        });