Passed
Push — master ( 345c9b...faecaf )
by Michiel
20:58
created

testGetReferencedObjectThrowsExceptionIfReferenceNotSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
class ReferenceTest extends \PHPUnit\Framework\TestCase
3
{
4
    /**
5
     * Test getProject method
6
     *
7
     * Test that getProject method works conclusively by setting random
8
     * description and checking for that as the description of the retrieved
9
     * project - e g not a default/hardcoded description.
10
     *
11
     * @return void
12
     */
13
    public function testGetProject()
14
    {
15
        $project = new Project();
16
        $description = "desc" . rand();
17
        $project->setDescription($description);
18
        $reference = new Reference($project);
19
        $retrieved = $reference->getProject();
20
        $this->assertEquals($retrieved->getDescription(), $description);
21
    }
22
23
    /**
24
     * @expectedException BuildException
25
     * @expectedExceptionMessage Reference refOne not found.
26
     */
27
    public function testGetReferencedObjectThrowsExceptionIfReferenceNotSet()
28
    {
29
        $project = new Project();
30
        $reference = new Reference($project, "refOne");
31
        $referenced = $reference->getReferencedObject(null);
0 ignored issues
show
Unused Code introduced by
The assignment to $referenced is dead and can be removed.
Loading history...
32
    }
33
34
    /**
35
     * @expectedException BuildException
36
     * @expectedExceptionMessage No reference specified
37
     */
38
    public function testGetReferencedObjectThrowsExceptionIfNoReferenceIsGiven()
39
    {
40
        $project = new Project();
41
        $reference = new Reference($project);
42
        $referenced = $reference->getReferencedObject(null);
0 ignored issues
show
Unused Code introduced by
The assignment to $referenced is dead and can be removed.
Loading history...
43
    }
44
}
45