fix: global afterEach being called twice

This commit is contained in:
Nuno Maduro
2024-09-11 00:40:41 +01:00
parent ea72461f1b
commit 32881774d2
6 changed files with 104 additions and 23 deletions

View File

@ -1,23 +1,79 @@
<?php
beforeEach(function () {
$this->ith = 0;
});
pest()->afterEach(function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)
->toBe(1);
->toBe(3);
$this->ith = 2;
$this->ith++;
});
pest()->afterEach(function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)
->toBe(4);
$this->ith++;
});
afterEach(function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)
->toBe(2);
->toBe(5);
$this->ith++;
});
describe('nested', function () {
afterEach(function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)
->toBe(6);
$this->ith++;
});
test('nested afterEach execution order', function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)
->toBe(0);
$this->ith++;
});
afterEach(function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)
->toBe(7);
$this->ith++;
});
});
afterEach(function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)
->toBeBetween(6, 8);
$this->ith++;
});
test('global afterEach execution order', function () {
expect($this)
->not()
->toHaveProperty('ith');
->toHaveProperty('ith')
->and($this->ith)
->toBe(0);
$this->ith++;
});