Files
pest/tests/Features/BeforeEach.php

44 lines
758 B
PHP

<?php
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(1);
$this->bar = 'changed';
});
it('gets executed before each test once again', function () {
expect($this->bar)->toBe(1);
});
beforeEach(function () {
$this->bar++;
});
describe('outer', function () {
beforeEach(function () {
$this->bar++;
});
describe('inner', function () {
beforeEach(function () {
$this->bar++;
});
it('should call all parent beforeEach functions', function () {
expect($this->bar)->toBe(3);
});
});
});