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\Plugin\Scrybe\Converter\RestructuredText\Visitors; |
||
13 | |||
14 | use Mockery as m; |
||
15 | use phpDocumentor\Plugin\Scrybe\Converter\Metadata\TableOfContents; |
||
16 | |||
17 | /** |
||
18 | * Test class for the Discovery Visitor. |
||
19 | */ |
||
20 | class DiscoverTest extends \Mockery\Adapter\Phpunit\MockeryTestCase |
||
21 | { |
||
22 | const FILENAME = 'test'; |
||
23 | |||
24 | protected $document = null; |
||
25 | |||
26 | protected $converter = null; |
||
27 | |||
28 | protected $table_of_contents = null; |
||
29 | |||
30 | /** |
||
31 | * @var Discover |
||
32 | */ |
||
33 | protected $object; |
||
34 | |||
35 | /** |
||
36 | * Sets up the fixture, for example, opens a network connection. |
||
37 | * This method is called before a test is executed. |
||
38 | */ |
||
39 | protected function setUp() |
||
40 | { |
||
41 | $this->object = new Discover($this->getDocumentMock(), ''); |
||
42 | } |
||
43 | |||
44 | protected function getDocumentMock() |
||
45 | { |
||
46 | if (!$this->document) { |
||
47 | $file = m::mock('\phpDocumentor\Fileset\File'); |
||
48 | $file->shouldReceive('getFileName') |
||
0 ignored issues
–
show
|
|||
49 | ->andReturn(self::FILENAME); |
||
50 | |||
51 | $this->document = m::mock('\phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Document'); |
||
52 | $this->document->shouldDeferMissing(); |
||
53 | $this->document->shouldReceive('getConverter') |
||
54 | ->andReturn($this->getConverterMock()); |
||
55 | |||
56 | $this->document->shouldReceive('getFile') |
||
57 | ->andReturn($file); |
||
58 | } |
||
59 | |||
60 | return $this->document; |
||
61 | } |
||
62 | |||
63 | protected function getConverterMock() |
||
64 | { |
||
65 | if (!$this->converter) { |
||
66 | $this->converter = m::mock('\phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\ToHtml'); |
||
67 | $this->converter->shouldReceive('getTableOfContents') |
||
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...
|
|||
68 | ->andReturn($this->getTableOfContents()); |
||
69 | } |
||
70 | |||
71 | return $this->converter; |
||
72 | } |
||
73 | |||
74 | protected function getTableOfContents() |
||
75 | { |
||
76 | if (!$this->table_of_contents) { |
||
77 | $this->table_of_contents = new TableOfContents(); |
||
78 | } |
||
79 | |||
80 | return $this->table_of_contents; |
||
81 | } |
||
82 | |||
83 | public function testRetrieveTableOfContents() |
||
84 | { |
||
85 | $this->assertSame( |
||
86 | $this->getTableOfContents(), |
||
87 | $this->object->getTableOfContents() |
||
88 | ); |
||
89 | } |
||
90 | |||
91 | public function testRetrieveDocument() |
||
92 | { |
||
93 | $this->assertSame( |
||
94 | $this->getDocumentMock(), |
||
95 | $this->object->getDocument() |
||
96 | ); |
||
97 | } |
||
98 | } |
||
99 |
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: