Completed
Push — master ( e91b2f...f5a28e )
by Phil
02:51
created

JobTest::testJobClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
/**
3
 * @author    Phil Taylor <[email protected]>
4
 * @source    https://github.com/PhilETaylor/
5
 * @copyright Copyright (C) 2016 Blue Flame IT Ltd. All rights reserved.
6
 */
7
8
namespace ResqueBundle\Resque;
9
10
11
class JobTest extends \PHPUnit_Framework_TestCase
12
{
13
    public function testJobClass()
14
    {
15
        $stub = $this->getMockForAbstractClass('ResqueBundle\Resque\Job', [[1, 2, 3]]);
16
17
        // test init correctly
18
        $this->assertContains('Job', $stub->getName());
19
        $this->assertEquals('default', $stub->queue);
0 ignored issues
show
Bug introduced by
Accessing queue on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
20
        $this->assertEquals([1, 2, 3], $stub->args);
0 ignored issues
show
Bug introduced by
Accessing args on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
21
22
23
        // test that perform calls run
24
        $stub
25
            ->expects($this->once())
26
            ->method('run');
27
28
        $stub->perform();
29
30
    }
31
}
32