Passed
Push — main ( 4ee39f...33155d )
by Justin
03:54
created

HandlerStackTest::test_flush()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 1
eloc 5
c 1
b 1
f 1
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Workbench\App\Tests\Unit;
4
5
use Modulate\Artisan\Interceptor\HandlerStack;
6
use Modulate\Artisan\Interceptor\Handlers\CallbackHandler;
7
use PHPUnit\Framework\TestCase;
8
9
class HandlerStackTest extends TestCase
10
{
11
    protected HandlerStack $stack;
12
13
    public function setUp(): void
14
    {
15
        $this->stack = new HandlerStack();
16
    }
17
    /**
18
     * A basic unit test example.
19
     */
20
    public function test_empty(): void
21
    {
22
        $this->assertTrue($this->stack->empty());
23
    }
24
25
    public function test_add_handler(): void
26
    {
27
        $this->stack->push(new CallbackHandler(
28
            fn() => []
29
        ));
30
31
        $this->assertTrue(!$this->stack->empty());
32
    }
33
   
34
   public function test_flush(): void
35
    {
36
        $this->stack->push(new CallbackHandler(
37
            fn() => []
38
        ));
39
40
        $this->assertTrue(!$this->stack->empty());
41
        $this->stack->flush();
42
        $this->assertTrue($this->stack->empty());
43
    }
44
    
45
}
46