expect($expectation->not())->toBe(false); expect($expectation->not)->toBe($expectation); expect($expectation->not())->toBe(true); }); it("throws an exception with unsupported attributes", function () { $closure = function () { $expectation = new Expectation(); $expectation->abc; }; expect($closure)->toThrow(new Exception('Unsupported attribute `abc`.')); }); }); describe("->clear()", function () { it("clears an expectation", function () { $actual = new stdClass(); $expectation = Expectation::expect($actual, 10); $matcher = $expectation->not->toReceive('helloWorld'); expect($expectation->actual())->toBe($actual); expect($expectation->deferred())->toHaveLength(1); expect($expectation->timeout())->toBe(10); expect($expectation->not())->toBe(true); expect($expectation->passed())->toBe(true); expect($expectation->logs())->toHaveLength(1); $expectation->clear(); expect($expectation->actual())->toBe(null); expect($expectation->deferred())->toHaveLength(0); expect($expectation->timeout())->toBe(-1); expect($expectation->not())->toBe(false); expect($expectation->passed())->toBe(true); expect($expectation->logs())->toHaveLength(0); });
}); it("loops until the timeout is reached on failure", function () { $start = microtime(true); $spec = new Specification(['closure' => function () { expect(true)->toBe(false); }]); $actual = expectation($spec, 0.1)->passed(); expect($actual)->toBe(false); $end = microtime(true); expect($end - $start)->toBeGreaterThan(0.1); expect($end - $start)->toBeLessThan(0.2); }); }); describe("->__get()", function () { it("sets the not value using `'not'`", function () { $expectation = new Expectation(); expect($expectation->not())->toBe(false); expect($expectation->not)->toBe($expectation); expect($expectation->not())->toBe(true); }); it("throws an exception with unsupported attributes", function () { $closure = function () { $expectation = new Expectation(); $expectation->abc; }; expect($closure)->toThrow(new Exception('Unsupported attribute `abc`.')); }); }); describe("->clear()", function () { it("clears an expectation", function () { $actual = Double::instance();