| 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\Parser\Parser\ParserInterface; |
||||
| 20 | use Graze\UnicontrollerClient\Parser\ParserResolver; |
||||
| 21 | use Graze\UnicontrollerClient\Parser\ArrayParser; |
||||
| 22 | |||||
| 23 | class ArrayParserTest extends \PHPUnit_Framework_TestCase |
||||
| 24 | { |
||||
| 25 | public function testParse() |
||||
| 26 | { |
||||
| 27 | $arrayName = 'ArrayName'; |
||||
| 28 | $arrayLength = 3; |
||||
| 29 | $entity = m::mock(EntityInterface::class); |
||||
| 30 | $entityParser = m::mock(ParserInterface::class) |
||||
| 31 | ->shouldReceive('parse') |
||||
|
0 ignored issues
–
show
|
|||||
| 32 | ->with('serialised') |
||||
| 33 | ->andReturn($entity) |
||||
| 34 | ->times($arrayLength) |
||||
| 35 | ->getMock(); |
||||
| 36 | $parserResolver = m::mock(ParserResolver::class) |
||||
| 37 | ->shouldReceive('resolve') |
||||
| 38 | ->with($arrayName) |
||||
| 39 | ->andReturn($entityParser) |
||||
| 40 | ->once() |
||||
| 41 | ->getMock(); |
||||
| 42 | $parser = new ArrayParser($parserResolver); |
||||
|
0 ignored issues
–
show
$parserResolver of type Mockery\MockInterface is incompatible with the type Graze\UnicontrollerClient\Parser\ParserResolver expected by parameter $parserResolver of Graze\UnicontrollerClien...ayParser::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 43 | |||||
| 44 | $parsed = $parser->parse( |
||||
| 45 | $arrayName, |
||||
| 46 | $arrayLength, |
||||
| 47 | "\tserialised\r\n\tserialised\r\n\tserialised\r\n" |
||||
| 48 | ); |
||||
| 49 | |||||
| 50 | $this->assertEquals([$entity, $entity, $entity], $parsed); |
||||
| 51 | } |
||||
| 52 | } |
||||
| 53 |
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.