Completed
Push — master ( 463d73...47ba96 )
by Gerrit
02:04
created

AdditionalDataArgumentTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A shouldResolveAdditionalDataArgument() 0 7 1
1
<?php
2
/**
3
 * Copyright (C) 2017  Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 * @license GPL-3.0
8
 * @author Gerrit Addiks <[email protected]>
9
 */
10
11
namespace Addiks\SymfonyGenerics\Tests\Unit\Arguments;
12
13
use PHPUnit\Framework\TestCase;
14
use Addiks\SymfonyGenerics\Arguments\AdditionalDataArgument;
15
use Addiks\SymfonyGenerics\Arguments\ArgumentContextInterface;
16
17
final class AdditionalDataArgumentTest extends TestCase
18
{
19
20
    /**
21
     * @test
22
     */
23
    public function shouldResolveAdditionalDataArgument()
24
    {
25
        $context = $this->createMock(ArgumentContextInterface::class);
26
        $context->method('get')->willReturn(12345);
27
        $argument = new AdditionalDataArgument("some-key", $context);
0 ignored issues
show
Documentation introduced by
$context is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Addiks\SymfonyGen...gumentContextInterface>.

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...
28
        $this->assertEquals(12345, $argument->resolve());
29
    }
30
31
}
32