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
|
|
|
|