Completed
Push — master ( c0f250...321e24 )
by Filipe
15:10
created

ControllerMethodsSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_holds_the_data_to_be_used_in_views() 0 4 1
A it_can_set_a_single_view_variable() 0 5 1
A it_can_set_an_array_of_values() 0 6 1
A it_can_be_used_with_compact() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of slick/web_stack package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace spec\Slick\WebStack\Controller;
11
12
use Slick\WebStack\Controller\ControllerMethods;
13
use PhpSpec\ObjectBehavior;
14
15
/**
16
 * ControllerMethodsSpec specs
17
 *
18
 * @package spec\Slick\WebStack\Controller
19
 */
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
53
class MyController
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
54
{
55
    use ControllerMethods;
56
}