These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * phpDocumentor |
||
4 | * |
||
5 | * PHP Version 5.3 |
||
6 | * |
||
7 | * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
||
8 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
9 | * @link http://phpdoc.org |
||
10 | */ |
||
11 | |||
12 | namespace phpDocumentor\Transformer\Router\UrlGenerator\Standard; |
||
13 | |||
14 | use Mockery as m; |
||
15 | |||
16 | /** |
||
17 | * Test for the FunctionDescriptor URL Generator with the Standard Router |
||
18 | */ |
||
19 | class FunctionDescriptorTest extends \Mockery\Adapter\Phpunit\MockeryTestCase |
||
20 | { |
||
21 | /** |
||
22 | * @covers phpDocumentor\Transformer\Router\UrlGenerator\Standard\FunctionDescriptor::__invoke |
||
23 | * @covers phpDocumentor\Transformer\Router\UrlGenerator\Standard\QualifiedNameToUrlConverter::fromNamespace |
||
24 | */ |
||
25 | public function testGenerateUrlForFunctionDescriptor() |
||
26 | { |
||
27 | // Arrange |
||
28 | $fixture = new FunctionDescriptor(); |
||
29 | $functionDescriptorMock = m::mock('phpDocumentor\Descriptor\FunctionDescriptor'); |
||
30 | $functionDescriptorMock->shouldReceive('getNamespace')->andReturn('My\\Space'); |
||
0 ignored issues
–
show
|
|||
31 | $functionDescriptorMock->shouldReceive('getName')->andReturn('myFunction'); |
||
32 | |||
33 | // Act |
||
34 | $result = $fixture($functionDescriptorMock); |
||
35 | |||
36 | // Assert |
||
37 | $this->assertSame('/namespaces/My.Space.html#function_myFunction', $result); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @covers phpDocumentor\Transformer\Router\UrlGenerator\Standard\FunctionDescriptor::__invoke |
||
42 | * @covers phpDocumentor\Transformer\Router\UrlGenerator\Standard\QualifiedNameToUrlConverter::fromNamespace |
||
43 | */ |
||
44 | public function testGenerateUrlForFunctionDescriptorWithGlobalNamespace() |
||
45 | { |
||
46 | // Arrange |
||
47 | $fixture = new FunctionDescriptor(); |
||
48 | $functionDescriptorMock = m::mock('phpDocumentor\Descriptor\FunctionDescriptor'); |
||
49 | $functionDescriptorMock->shouldReceive('getNamespace')->andReturn('\\'); |
||
0 ignored issues
–
show
The method
andReturn does only exist in Mockery\ExpectationInterface , but not in Mockery\HigherOrderMessage .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
50 | $functionDescriptorMock->shouldReceive('getName')->andReturn('myFunction'); |
||
51 | |||
52 | // Act |
||
53 | $result = $fixture($functionDescriptorMock); |
||
54 | |||
55 | // Assert |
||
56 | $this->assertSame('/namespaces/default.html#function_myFunction', $result); |
||
57 | } |
||
58 | } |
||
59 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: