PreTaskEventTest::testGetJob()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of Bldr.io
4
 *
5
 * (c) Aaron Scherer <[email protected]>
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE
9
 */
10
11
namespace Bldr\Test\Event;
12
13
use Bldr\Event\PreCallEvent;
14
use Bldr\Event\PreTaskEvent;
15
16
/**
17
 * @author Mauricio Walters <[email protected]>
18
 */
19
class PreTaskEventTest extends \PHPUnit_Framework_TestCase
20
{
21
    public static function createPreTaskEvent()
22
    {
23
        $jobDefinition  = \Mockery::mock('Bldr\Definition\JobDefinition');
24
        $taskDefinition = \Mockery::mock('Bldr\Definition\TaskDefinition');
25
26
        return new PreTaskEvent($jobDefinition, $taskDefinition, false);
0 ignored issues
show
Unused Code introduced by
The call to PreTaskEvent::__construct() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
27
    }
28
29
    /**
30
     * Tests the __construct($call, $task) method
31
     * @throws \PHPUnit_Framework_Exception
32
     * @return PreCallEvent
33
     */
34
    public function testFactory()
35
    {
36
        $preTaskEvent = self::createPreTaskEvent();
37
38
        $this->assertInstanceOf(
39
            'Bldr\Event\PreTaskEvent',
40
            $preTaskEvent
41
        );
42
43
        $this->assertInstanceOf(
44
            'Bldr\Event\AbstractEvent',
45
            $preTaskEvent
46
        );
47
48
        return $preTaskEvent;
49
    }
50
51
    public function testGetTask()
52
    {
53
        $preTaskEvent = self::createPreTaskEvent();
54
55
        $this->assertInstanceOf(
56
            'Bldr\Definition\TaskDefinition',
57
            $preTaskEvent->getTask()
58
        );
59
    }
60
61
    public function testGetJob()
62
    {
63
        $preTaskEvent = self::createPreTaskEvent();
64
65
        $this->assertInstanceOf(
66
            'Bldr\Definition\JobDefinition',
67
            $preTaskEvent->getJob()
68
        );
69
    }
70
71
    public function testSetTask()
72
    {
73
        $task = \Mockery::mock('Bldr\Definition\TaskDefinition');
74
        $task->shouldReceive('getType')
75
            ->once()
76
            ->andReturn('test');
77
78
        $preTaskEvent = self::createPreTaskEvent();
79
        $preTaskEvent->setTask($task);
80
81
        $this->assertEquals('test', $preTaskEvent->getTask()->getType());
82
    }
83
}
84