Passed
Push — develop ( f33517...37b14c )
by Ilya
02:41
created

ActionsBagTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A test_delete_if_exists_method() 0 16 1
A test_get_method() 0 9 1
A test_is_empty_method() 0 9 1
A test_add_if_not_exists_method() 0 13 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
27
        $bag = new ActionsBag;
28
29
        $bag->addIfNotExists('index');
30
31
        $this->assertEquals(count($bag->get()), 1);
32
33
        $bag->deleteIfExists('show');
34
35
        $this->assertEquals(count($bag->get()), 1);
36
37
        $bag->deleteIfExists('index');
38
39
        $this->assertEquals(count($bag->get()), 0);
40
    }
41
42
    public function test_get_method()
43
    {
44
        $bag = new ActionsBag;
45
46
        $bag->addIfNotExists('index');
47
48
        $bag->addIfNotExists('show');
49
50
        $this->assertEquals(array_sort_recursive(['index', 'show']), array_sort_recursive($bag->get()));
51
    }
52
53
    public function test_is_empty_method()
54
    {
55
        $bag = new ActionsBag;
56
57
        $this->assertTrue($bag->isEmpty());
58
59
        $bag->addIfNotExists('show');
60
61
        $this->assertFalse($bag->isEmpty());
62
    }
63
}
64