Files
pest/tests/Features/AfterEach.php
Nuno Maduro 45cce6ce93 Style
2024-07-24 21:54:52 +01:00

29 lines
531 B
PHP

<?php
$state = new stdClass;
beforeEach(function () use ($state) {
$this->state = $state;
});
afterEach(function () {
$this->state->bar = 1;
});
afterEach(function () {
unset($this->state->bar);
});
it('does not get executed before the test', function () {
expect($this->state)->not->toHaveProperty('bar');
});
it('gets executed after the test', function () {
expect($this->state)->toHaveProperty('bar');
expect($this->state->bar)->toBe(2);
});
afterEach(function () {
$this->state->bar = 2;
});