mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
fix: global afterEach being called twice
This commit is contained in:
@ -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++;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user