mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat(describe): continues work around hooks
This commit is contained in:
@ -6,56 +6,73 @@ test('before each', function () {
|
||||
expect($this->count)->toBe(1);
|
||||
});
|
||||
|
||||
describe('describable', function () {
|
||||
describe('hooks', function () {
|
||||
beforeEach(function () {
|
||||
$this->count++;
|
||||
});
|
||||
|
||||
test('basic', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
test('before each', function () {
|
||||
test('value', function () {
|
||||
expect($this->count)->toBe(2);
|
||||
$this->count++;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
expect($this->count)->toBe(2);
|
||||
expect($this->count)->toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('another describable', function () {
|
||||
describe('hooks in different orders', function () {
|
||||
beforeEach(function () {
|
||||
$this->count++;
|
||||
});
|
||||
|
||||
test('basic', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
test('before each', function () {
|
||||
expect($this->count)->toBe(2);
|
||||
test('value', function () {
|
||||
expect($this->count)->toBe(3);
|
||||
$this->count++;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
expect($this->count)->toBe(2);
|
||||
expect($this->count)->toBe(4);
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->count++;
|
||||
});
|
||||
});
|
||||
|
||||
test('should not fail')->todo()->shouldNotRun();
|
||||
test('todo')->todo()->shouldNotRun();
|
||||
|
||||
test('previous describable before each does not get applied here', function () {
|
||||
expect($this->count)->toBe(1);
|
||||
});
|
||||
|
||||
afterEach(fn () => expect($this->count)->toBe(is_null($this->__describeDescription) ? 1 : 2));
|
||||
|
||||
describe('todo', function () {
|
||||
describe('todo on hook', function () {
|
||||
beforeEach()->todo();
|
||||
|
||||
test('should not fail')->shouldNotRun();
|
||||
test('should run')->expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
describe('todo after describe', function () {
|
||||
describe('todo on describe', function () {
|
||||
test('should not fail')->shouldNotRun();
|
||||
|
||||
test('should run')->expect(true)->toBeTrue();
|
||||
})->todo();
|
||||
|
||||
test('should run')->expect(true)->toBeTrue();
|
||||
|
||||
test('with', fn ($foo) => expect($foo)->toBe(1))->with([1]);
|
||||
|
||||
describe('with on hook', function () {
|
||||
beforeEach()->with([2]);
|
||||
|
||||
test('value', function ($foo) {
|
||||
expect($foo)->toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with on describe', function () {
|
||||
test('value', function ($foo) {
|
||||
expect($foo)->toBe(3);
|
||||
});
|
||||
})->with([3]);
|
||||
|
||||
Reference in New Issue
Block a user