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