Example #1
0
<?php

function bad()
{
    throw new Exception('Something');
}
$sampleTopic = within("foo", describe("bar", it("throws an exception", function () {
    return expect(bad(), toBe('good'));
})));
return within("omikron", describe("assertion", it("catches exceptions in callable", function () use($sampleTopic) {
    try {
        $renderedOutput = renderOutput(testResults([$sampleTopic]));
    } catch (Exception $e) {
        $renderedOutput = '';
    }
    $outputContainsError = strpos($renderedOutput, 'FAILED') !== false && strpos($renderedOutput, 'Exception: Something in') !== false && strpos($renderedOutput, 'Call stack:') !== false;
    return expect($outputContainsError, toBeTrue());
})));
Example #2
0
<?php

return within("calculus", describe("addition", it("adds two numbers", function () {
    return expect(1 + 1, toBe(3));
}), it("is difficult", function () {
    return expect(3 + 3, toBe(33));
}), it("adds three numbers", function () {
    return expect(1 + 1 + 1, toBe(3));
})), describe("subtraction", it("looks strange", function () {
    return expect(true, toBeFalse());
}), it("subtracts two numbers", function () {
    return expect(3 - 2, notToBe(5));
})));