Completed
Push — master ( bd4c23...b341c0 )
by Filipe
10:29
created

ControllerSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 28
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_accepts_a_controller_context() 0 6 1
A it_can_set_view_data_model_variables() 0 5 1
A it_can_set_multiple_view_data_model_variables_passing_an_array() 0 7 1
1
<?php
2
3
namespace spec\Slick\Mvc;
4
5
use Slick\Mvc\Controller;
6
use PhpSpec\ObjectBehavior;
7
use Prophecy\Argument;
8
9
class ControllerSpec extends ObjectBehavior
10
{
11
    function let()
12
    {
13
        $this->beAnInstanceOf(TestController::class);
14
    }
15
16
    function it_accepts_a_controller_context(
17
        Controller\ControllerContextInterface $context
18
    ) {
19
        $this->setContext($context)->shouldBe($this->getWrappedObject());
20
        $this->getContext()->shouldBe($context);
21
    }
22
23
    function it_can_set_view_data_model_variables()
24
    {
25
        $this->set('foo', 'bar')->shouldBe($this->getWrappedObject());
26
        $this->getViewData()->shouldHaveKeyWithValue('foo', 'bar');
27
    }
28
29
    function it_can_set_multiple_view_data_model_variables_passing_an_array()
30
    {
31
        $foo = 'bar';
32
        $bas = 'baz';
33
        $this->set(compact('foo', 'bas'));
34
        $this->getViewData()->shouldHaveKeyWithValue('bas', 'baz');
35
    }
36
}
37
38
class TestController extends Controller
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...
39
{
40
41
    public function getContext()
42
    {
43
        return $this->context;
44
    }
45
}
46