Adds expect extend

This commit is contained in:
Nuno Maduro
2020-11-29 16:30:57 +01:00
parent b79ba5098b
commit 03dc11c2f6
6 changed files with 134 additions and 3 deletions

View File

@ -2,6 +2,12 @@
PASS Tests\CustomTestCase\ExecutedTest
✓ that gets executed
PASS Tests\Expect\extend
✓ it macros true is true
✓ it macros false is not true
✓ it macros true is true with argument
✓ it macros false is not true with argument
PASS Tests\Expect\not
✓ not property calls
@ -404,5 +410,5 @@
✓ depends run test only once
✓ depends works with the correct test name
Tests: 7 skipped, 238 passed
Tests: 7 skipped, 242 passed

29
tests/Expect/extend.php Normal file
View File

@ -0,0 +1,29 @@
<?php
expect()->extend('toBeAMacroExpectation', function () {
$this->toBeTrue();
return $this;
});
expect()->extend('toBeAMacroExpectationWithArguments', function (bool $value) {
$this->toBe($value);
return $this;
});
it('macros true is true', function () {
expect(true)->toBeAMacroExpectation();
});
it('macros false is not true', function () {
expect(false)->not->toBeAMacroExpectation();
});
it('macros true is true with argument', function () {
expect(true)->toBeAMacroExpectationWithArguments(true);
});
it('macros false is not true with argument', function () {
expect(false)->not->toBeAMacroExpectationWithArguments(true);
});