Issues (283)

tests/unit/Serialiser/ArraySerialiserTest.php (2 issues)

1
<?php
2
3
/**
4
 * This file is part of graze/unicontroller-client.
5
 *
6
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://github.com/graze/unicontroller-client/blob/master/LICENSE.md
12
 * @link https://github.com/graze/unicontroller-client
13
 */
14
15
namespace Graze\UniControllerClient\Test\Unit;
16
17
use Mockery as m;
18
use Graze\UnicontrollerClient\Entity\Entity\EntityInterface;
19
use Graze\UnicontrollerClient\Serialiser\Serialiser\SerialiserInterface;
20
use Graze\UnicontrollerClient\Serialiser\SerialiserResolver;
21
use Graze\UnicontrollerClient\Serialiser\ArraySerialiser;
22
23
class ArraySerialiserTest extends \PHPUnit_Framework_TestCase
24
{
25
    public function testSerialise()
26
    {
27
        $entity = m::mock(EntityInterface::class);
28
        $entitySerialiser = m::mock(SerialiserInterface::class)
29
            ->shouldReceive('serialise')
0 ignored issues
show
The call to Mockery\MockInterface::shouldReceive() has too many arguments starting with 'serialise'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
            ->/** @scrutinizer ignore-call */ shouldReceive('serialise')

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. Please note the @ignore annotation hint above.

Loading history...
30
            ->with($entity)
31
            ->andReturn('serialised')
32
            ->times(3)
33
            ->getMock();
34
        $serialiserResolver = m::mock(SerialiserResolver::class)
35
            ->shouldReceive('resolve')
36
            ->with($entity)
37
            ->andReturn($entitySerialiser)
38
            ->once()
39
            ->getMock();
40
        $arraySerialiser = new ArraySerialiser($serialiserResolver);
0 ignored issues
show
$serialiserResolver of type Mockery\MockInterface is incompatible with the type Graze\UnicontrollerClien...iser\SerialiserResolver expected by parameter $serialiserResolver of Graze\UnicontrollerClien...rialiser::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
        $arraySerialiser = new ArraySerialiser(/** @scrutinizer ignore-type */ $serialiserResolver);
Loading history...
41
42
        $arraySerialised = $arraySerialiser->serialise([$entity, $entity, $entity], 'ItemName');
43
        $this->assertEquals(
44
            "\x02ItemName\x03,3,\r\n\tserialised\r\n\tserialised\r\n\tserialised\r\n",
45
            $arraySerialised
46
        );
47
    }
48
}
49