test: adding tests for beforeEach and afterEach + empty tests for *All

This commit is contained in:
jordanbrauer
2021-04-06 19:26:42 -05:00
parent 99500d0cae
commit 53333b56ab
5 changed files with 82 additions and 7 deletions

View File

@ -0,0 +1,11 @@
<?php
uses()->afterAll(function () {
});
afterAll(function () {
});
test('global afterAll execution order', function () {
});

View File

@ -0,0 +1,24 @@
<?php
uses()->afterEach(function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)
->toBe(0);
$this->ith = 1;
});
afterEach(function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)
->toBe(1);
});
test('global afterEach execution order', function () {
expect($this)
->not()
->toHaveProperty('ith');
});

View File

@ -0,0 +1,11 @@
<?php
uses()->beforeAll(function () {
});
beforeAll(function () {
});
test('global beforeAll execution order', function () {
});

View File

@ -1,11 +1,27 @@
<?php
beforeEach(function (): void {
expect($this->baz)->toBe(1); // set from Pest.php global/shared hook
uses()->beforeEach(function () {
expect($this)
->toHaveProperty('baz')
->and($this->baz)
->toBe(0);
$this->baz = 1;
});
beforeEach(function () {
expect($this)
->toHaveProperty('baz')
->and($this->baz)
->toBe(1);
$this->baz = 2;
});
test('global before each', function (): void {
expect($this->baz)->toBe(2);
test('global beforeEach execution order', function () {
expect($this)
->toHaveProperty('baz')
->and($this->baz)
->toBe(2);
});

View File

@ -1,6 +1,19 @@
<?php
uses()->group('integration')->in('Visual');
uses()->beforeEach(function (): void {
$this->baz = 1;
})->in('Hooks');
uses()
->beforeEach(function () {
$this->baz = 0;
})
// ->beforeAll(function () {
// dump(0);
// })
->afterEach(function () {
$this->ith = 0;
})
// ->afterAll(function () {
// dump(0);
// })
->in('Hooks');