kahlan\Log::add PHP Method

add() public method

Adds an expectation report and emits a report event.
public add ( $type, array $data = [] )
$data array The report data.
    public function add($type, $data = [])
    {
        if ($this->type() === 'passed' && $type === 'failed') {
            $this->type('failed');
        }
        $data['type'] = $type;
        if (!isset($data['backtrace'])) {
            $data['backtrace'] = [];
        } else {
            $data['backtrace'] = Debugger::focus($this->scope()->backtraceFocus(), $data['backtrace'], 1);
        }
        $child = new static($data + ['scope' => $this->_scope]);
        $this->_children[] = $child;
        return $child;
    }

Usage Example

Beispiel #1
0
        it("returns `true` type is `'skipped'`", function () {
            $log = new Log(['type' => 'skipped']);
            expect($log->passed())->toBe(true);
        });
        it("returns `true` type is `'excluded'`", function () {
            $log = new Log(['type' => 'excluded']);
            expect($log->passed())->toBe(true);
        });
        it("returns `false` type is `'failed'`", function () {
            $log = new Log(['type' => 'failed']);
            expect($log->passed())->toBe(false);
        });
        it("returns `false` type is `'errored'`", function () {
            $log = new Log(['type' => 'errored']);
            expect($log->passed())->toBe(false);
        });
        it("returns `true` when logged exceptions passed", function () {
            $log = new Log();
            $log->add('passed', []);
            $log->add('passed', []);
            expect($log->passed())->toBe(true);
        });
        it("returns `false` when some logged exceptions failed", function () {
            $log = new Log();
            $log->add('passed', []);
            $log->add('passed', []);
            $log->add('failed', []);
            expect($log->passed())->toBe(false);
        });
    });
});
All Usage Examples Of kahlan\Log::add