ActionsBagTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A test_add_if_not_exists_method() 0 13 1
A test_delete_if_exists_method() 0 15 1
A test_get_method() 0 9 1
A test_is_empty_method() 0 9 1
1
<?php
2
3
namespace Hivokas\LaravelHandlers\Tests;
4
5
use Hivokas\LaravelHandlers\Support\ActionsBag;
6
7
class ActionsBagTest extends AbstractTestCase
8
{
9
    public function test_add_if_not_exists_method()
10
    {
11
        $bag = new ActionsBag;
12
13
        $this->assertEquals(count($bag->get()), 0);
14
15
        $bag->addIfNotExists('index');
16
17
        $this->assertEquals(count($bag->get()), 1);
18
19
        $bag->addIfNotExists('index');
20
21
        $this->assertEquals(count($bag->get()), 1);
22
    }
23
24
    public function test_delete_if_exists_method()
25
    {
26
        $bag = new ActionsBag;
27
28
        $bag->addIfNotExists('index');
29
30
        $this->assertEquals(count($bag->get()), 1);
31
32
        $bag->deleteIfExists('show');
33
34
        $this->assertEquals(count($bag->get()), 1);
35
36
        $bag->deleteIfExists('index');
37
38
        $this->assertEquals(count($bag->get()), 0);
39
    }
40
41
    public function test_get_method()
42
    {
43
        $bag = new ActionsBag;
44
45
        $bag->addIfNotExists('index');
46
47
        $bag->addIfNotExists('show');
48
49
        $this->assertEquals(array_sort_recursive(['index', 'show']), array_sort_recursive($bag->get()));
50
    }
51
52
    public function test_is_empty_method()
53
    {
54
        $bag = new ActionsBag;
55
56
        $this->assertTrue($bag->isEmpty());
57
58
        $bag->addIfNotExists('show');
59
60
        $this->assertFalse($bag->isEmpty());
61
    }
62
}
63