1 | <?php |
||
20 | class ControllerMethodsSpec extends ObjectBehavior |
||
21 | { |
||
22 | function let() |
||
23 | { |
||
24 | $this->beAnInstanceOf(MyController::class); |
||
25 | } |
||
26 | |||
27 | function it_holds_the_data_to_be_used_in_views() |
||
28 | { |
||
29 | $this->data()->shouldBeArray(); |
||
30 | } |
||
31 | |||
32 | function it_can_set_a_single_view_variable() |
||
33 | { |
||
34 | $this->set('foo', 'bar')->shouldBeAnInstanceOf($this->getWrappedObject()); |
||
35 | $this->data()->shouldHaveKeyWithValue('foo', 'bar'); |
||
36 | } |
||
37 | |||
38 | function it_can_set_an_array_of_values() |
||
39 | { |
||
40 | $this->set(['foo' => 'bar', 'bar' => 'baz']); |
||
41 | $this->data()->shouldHaveKeyWithValue('foo', 'bar'); |
||
42 | $this->data()->shouldHaveKeyWithValue('bar', 'baz'); |
||
43 | } |
||
44 | |||
45 | function it_can_be_used_with_compact() |
||
46 | { |
||
47 | $foo = 'bar'; |
||
48 | $this->set(compact('foo')); |
||
49 | $this->data()->shouldHaveKeyWithValue('foo', 'bar'); |
||
50 | } |
||
51 | } |
||
52 | |||
56 | } |