1 | <?php |
||
2 | |||
3 | /** |
||
4 | * ContainerSpec.php |
||
5 | * |
||
6 | * This file tests the behavior of the Container class. |
||
7 | * |
||
8 | * PHP version 7.4 |
||
9 | * |
||
10 | * @category Core |
||
11 | * @package RedboxTestSuite |
||
12 | * @author Johnny Mast <[email protected]> |
||
13 | * @license https://opensource.org/licenses/MIT MIT |
||
14 | * @link https://github.com/johnnymast/redbox-testsuite |
||
15 | * @since 1.0 |
||
16 | */ |
||
17 | |||
18 | namespace spec\Redbox\Testsuite; |
||
19 | |||
20 | use PhpSpec\ObjectBehavior; |
||
21 | use Redbox\Testsuite\Container; |
||
22 | |||
23 | /** |
||
24 | * Class ContainerSpec |
||
25 | * |
||
26 | * @package spec\Redbox\Testsuite |
||
27 | */ |
||
28 | class ContainerSpec extends ObjectBehavior |
||
29 | { |
||
30 | /** |
||
31 | * Check to see if the class can be initialized. |
||
32 | * |
||
33 | * @return void |
||
34 | */ |
||
35 | function it_is_initializable() |
||
0 ignored issues
–
show
|
|||
36 | { |
||
37 | $this->shouldHaveType(Container::class); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Check if there is a function called has. |
||
42 | * |
||
43 | * @return void |
||
44 | */ |
||
45 | function it_should_have_a_workable_has_function() |
||
46 | { |
||
47 | $this->set('__HELLO__', 'world'); |
||
48 | $this->has('__HELLO__')->shouldReturn(true); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Check if there is a function called get. |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | function it_should_workable_get_and_set_function() |
||
57 | { |
||
58 | $this->set('__GOODBYE__', 'world'); |
||
59 | $this->get('__GOODBYE__'); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Test that get should return false if a key does not exist. |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | function it_should_return_false_on_get_if_a_given_key_does_not_exist() |
||
68 | { |
||
69 | $this->get('__NON_EXISTING_KEY')->shouldReturn(false); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Check if there is a workable forget function. |
||
74 | * |
||
75 | * @return void |
||
76 | */ |
||
77 | function it_should_have_a_workable_forget_function() |
||
78 | { |
||
79 | $this->set('__BLEEP__', 'world'); |
||
80 | $this->has('__BLEEP__')->shouldReturn(true); |
||
81 | |||
82 | $this->forget('__BLEEP__'); |
||
83 | |||
84 | $this->has('__BLEEP__')->shouldReturn(false); |
||
85 | } |
||
86 | } |
||
87 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.