mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
More tests
This commit is contained in:
@ -9,10 +9,10 @@
|
||||
|
||||
TODO Tests\Features\Describe - 5 todos
|
||||
↓ todo
|
||||
↓ todo on hook > should not fail
|
||||
↓ todo on hook > should run
|
||||
↓ todo on describe > should not fail
|
||||
↓ todo on describe > should run
|
||||
↓ todo on hook → should not fail
|
||||
↓ todo on hook → should run
|
||||
↓ todo on describe → should not fail
|
||||
↓ todo on describe → should run
|
||||
|
||||
TODO Tests\Features\Todo - 3 todos
|
||||
↓ something todo later
|
||||
|
||||
@ -7,7 +7,11 @@ beforeEach(function () use ($state) {
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
$this->state->bar = 2;
|
||||
$this->state->bar = 1;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
unset($this->state->bar);
|
||||
});
|
||||
|
||||
it('does not get executed before the test', function () {
|
||||
@ -18,3 +22,7 @@ it('gets executed after the test', function () {
|
||||
expect($this->state)->toHaveProperty('bar');
|
||||
expect($this->state->bar)->toBe(2);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
$this->state->bar = 2;
|
||||
});
|
||||
|
||||
@ -4,12 +4,24 @@ beforeEach(function () {
|
||||
$this->bar = 2;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->bar++;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->bar = 0;
|
||||
});
|
||||
|
||||
it('gets executed before each test', function () {
|
||||
expect($this->bar)->toBe(2);
|
||||
expect($this->bar)->toBe(1);
|
||||
|
||||
$this->bar = 'changed';
|
||||
});
|
||||
|
||||
it('gets executed before each test once again', function () {
|
||||
expect($this->bar)->toBe(2);
|
||||
expect($this->bar)->toBe(1);
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->bar++;
|
||||
});
|
||||
|
||||
@ -68,3 +68,11 @@ it('throws exception if no class nor method has been found', function () {
|
||||
|
||||
$testCall->covers('fakeName');
|
||||
})->throws(InvalidArgumentException::class, 'No class or method named "fakeName" has been found.');
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
it('does not append CoversNothing to method attributes', function () {
|
||||
$phpDoc = (new ReflectionClass($this))->getMethod($this->name());
|
||||
|
||||
expect(str_contains($phpDoc->getDocComment(), '* @coversNothing'))->toBeTrue();
|
||||
});
|
||||
})->coversNothing();
|
||||
|
||||
@ -29,3 +29,9 @@ trait Gettable
|
||||
get('foo'); // not incomplete because closure is created...
|
||||
get('foo')->get('bar')->expect(true)->toBeTrue();
|
||||
get('foo')->expect(true)->toBeTrue();
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
get('foo'); // not incomplete because closure is created...
|
||||
get('foo')->get('bar')->expect(true)->toBeTrue();
|
||||
get('foo')->expect(true)->toBeTrue();
|
||||
});
|
||||
@ -15,3 +15,7 @@ it('is not incompleted because of assert')->assertTrue(true);
|
||||
it('is not incompleted because of test with assertions', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
it('is incompleted');
|
||||
});
|
||||
|
||||
@ -5,3 +5,11 @@ it('is a test', function () {
|
||||
});
|
||||
|
||||
it('is a higher order message test')->expect(true)->toBeTrue();
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
it('is a test', function () {
|
||||
expect(['key' => 'foo'])->toHaveKey('key')->key->toBeString();
|
||||
});
|
||||
|
||||
it('is a higher order message test')->expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
@ -5,3 +5,11 @@ test('notice', function () {
|
||||
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
test('notice', function () {
|
||||
trigger_error('This is a notice description', E_USER_NOTICE);
|
||||
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
@ -9,3 +9,9 @@ it('allows access to the underlying expectNotToPerformAssertions method', functi
|
||||
it('allows performing no expectations without being risky', function () {
|
||||
$result = 1 + 1;
|
||||
})->throwsNoExceptions();
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
it('allows performing no expectations without being risky', function () {
|
||||
$result = 1 + 1;
|
||||
});
|
||||
})->throwsNoExceptions();
|
||||
|
||||
@ -11,3 +11,11 @@ test('user warning', function () {
|
||||
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
describe('a "describe" group of tests', function () {
|
||||
test('user warning', function () {
|
||||
trigger_error('This is a warning description', E_USER_WARNING);
|
||||
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user