Completed
Push — master ( e4a30a...1a3d0b )
by Tobias
07:42
created

FileStorageTest::testConstructorInvalidLoader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 3
cp 0.6667
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1.037
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\SymfonyStorage\Tests\Unit;
13
14
use Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader;
15
use Symfony\Component\Translation\Writer\TranslationWriter;
16
use Translation\SymfonyStorage\FileStorage;
17
18
/**
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21
class FileStorageTest extends \PHPUnit_Framework_TestCase
22
{
23 1
    public function testConstructor()
24
    {
25 1
        new FileStorage(new TranslationWriter(), new TranslationLoader(), ['foo']);
26 1
    }
27
28
    /**
29
     * @expectedException \LogicException
30
     */
31 1
    public function testConstructorInvalidLoader()
32
    {
33 1
        new FileStorage(new TranslationWriter(), new TranslationWriter(), ['foo']);
0 ignored issues
show
Documentation introduced by
new \Symfony\Component\T...ter\TranslationWriter() is of type object<Symfony\Component...iter\TranslationWriter>, but the function expects a object<Symfony\Bundle\Fr...rage\TranslationLoader>.

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...
34
    }
35
36
    /**
37
     * @expectedException \LogicException
38
     */
39 1
    public function testConstructorEmptyArray()
40
    {
41 1
        new FileStorage(new TranslationWriter(), new TranslationLoader(), []);
42
    }
43
}
44