ConfigFileCacheWarmerTest::testIsOptional()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Dekalee\AdbackAnalyticsBundle\Tests\Unit\CacheWarmer;
4
5
use Dekalee\AdbackAnalytics\Query\ScriptUrlQuery;
6
use Dekalee\AdbackAnalyticsBundle\CacheWarmer\ConfigFileCacheWarmer;
7
use Phake;
8
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
9
10
/**
11
 * Class ConfigFileCacheWarmerTest
12
 */
13
class ConfigFileCacheWarmerTest extends \PHPUnit_Framework_TestCase
14
{
15
    /**
16
     * @var ConfigFileCacheWarmer
17
     */
18
    protected $warmer;
19
20
    protected $query;
21
22
    /**
23
     * Set up the test
24
     */
25 3
    public function setUp()
26
    {
27 3
        $this->query = Phake::mock(ScriptUrlQuery::CLASS);
28
29 3
        $this->warmer = new ConfigFileCacheWarmer($this->query);
0 ignored issues
show
Documentation introduced by
$this->query is of type object<Phake_IMock>, but the function expects a object<Dekalee\AdbackAna...s\Query\ScriptUrlQuery>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
30 3
    }
31
32
    /**
33
     * Test instance
34
     */
35 1
    public function testInstance()
36
    {
37 1
        $this->assertInstanceOf(CacheWarmerInterface::CLASS, $this->warmer);
38 1
    }
39
40
    /**
41
     * Test query call
42
     */
43 1
    public function testWarmup()
44
    {
45 1
        $this->warmer->warmUp('');
46
47 1
        Phake::verify($this->query)->execute();
48 1
    }
49
50
    /**
51
     * Test optionnal
52
     */
53 1
    public function testIsOptional()
54
    {
55 1
        $this->assertFalse($this->warmer->isOptional());
56 1
    }
57
}
58