Completed
Pull Request — master (#15)
by Christian
03:51
created

ContextActivitiesSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 58
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A its_properties_are_empty_by_default() 0 7 1
A it_returns_a_new_instance_with_parent_activity() 0 11 1
A it_returns_a_new_instance_with_grouping_activity() 0 11 1
A it_returns_a_new_instance_with_category_activity() 0 11 1
A it_returns_a_new_instance_with_other_activity() 0 11 1
1
<?php
2
3
namespace spec\Xabbuh\XApi\Model;
4
5
use PhpSpec\ObjectBehavior;
6
use Xabbuh\XApi\Model\Activity;
7
8
class ContextActivitiesSpec extends ObjectBehavior
9
{
10
    public function its_properties_are_empty_by_default()
11
    {
12
        $this->getParentActivity()->shouldBeNull();
13
        $this->getGroupingActivity()->shouldBeNull();
14
        $this->getCategoryActivity()->shouldBeNull();
15
        $this->getOtherActivity()->shouldBeNull();
16
    }
17
18
    public function it_returns_a_new_instance_with_parent_activity()
19
    {
20
        $activity = new Activity('http://tincanapi.com/conformancetest/activityid');
21
        $contextActivities = $this->withParentActivity($activity);
22
23
        $this->getParentActivity()->shouldBeNull();
24
25
        $contextActivities->shouldNotBe($this);
26
        $contextActivities->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\ContextActivities');
27
        $contextActivities->getParentActivity()->shouldReturn($activity);
28
    }
29
30
    public function it_returns_a_new_instance_with_grouping_activity()
31
    {
32
        $activity = new Activity('http://tincanapi.com/conformancetest/activityid');
33
        $contextActivities = $this->withGroupingActivity($activity);
34
35
        $this->getGroupingActivity()->shouldBeNull();
36
37
        $contextActivities->shouldNotBe($this);
38
        $contextActivities->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\ContextActivities');
39
        $contextActivities->getGroupingActivity()->shouldReturn($activity);
40
    }
41
42
    public function it_returns_a_new_instance_with_category_activity()
43
    {
44
        $activity = new Activity('http://tincanapi.com/conformancetest/activityid');
45
        $contextActivities = $this->withCategoryActivity($activity);
46
47
        $this->getCategoryActivity()->shouldBeNull();
48
49
        $contextActivities->shouldNotBe($this);
50
        $contextActivities->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\ContextActivities');
51
        $contextActivities->getCategoryActivity()->shouldReturn($activity);
52
    }
53
54
    public function it_returns_a_new_instance_with_other_activity()
55
    {
56
        $activity = new Activity('http://tincanapi.com/conformancetest/activityid');
57
        $contextActivities = $this->withOtherActivity($activity);
58
59
        $this->getOtherActivity()->shouldBeNull();
60
61
        $contextActivities->shouldNotBe($this);
62
        $contextActivities->shouldBeAnInstanceOf('\Xabbuh\XApi\Model\ContextActivities');
63
        $contextActivities->getOtherActivity()->shouldReturn($activity);
64
    }
65
}
66