HandlerStackTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
eloc 12
c 1
b 1
f 1
dl 0
loc 34
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A test_add_handler() 0 7 1
A test_empty() 0 3 1
A test_flush() 0 9 1
A setUp() 0 3 1
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