These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * This file is part of phpDocumentor. |
||
4 | * |
||
5 | * For the full copyright and license information, please view the LICENSE |
||
6 | * file that was distributed with this source code. |
||
7 | * |
||
8 | * @copyright 2010-2018 Mike van Riel<[email protected]> |
||
9 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
10 | * @link http://phpdoc.org |
||
11 | */ |
||
12 | |||
13 | namespace phpDocumentor\Application\Stage\Parser; |
||
14 | |||
15 | use \Mockery as m; |
||
16 | use Mockery\Adapter\Phpunit\MockeryTestCase; |
||
17 | use phpDocumentor\DomainModel\Path; |
||
18 | use Zend\Cache\Storage\StorageInterface; |
||
19 | |||
20 | class ConfigureCacheTest extends MockeryTestCase |
||
21 | { |
||
22 | /** |
||
23 | * @dataProvider cacheDirProvider |
||
24 | * @throws \Exception |
||
25 | */ |
||
26 | public function testInvokeWithCachePath($configuredPath, $expectedPath) |
||
27 | { |
||
28 | $configuration = [ |
||
29 | 'phpdocumentor' => [ |
||
30 | 'paths' => [ |
||
31 | 'cache' => $configuredPath, |
||
32 | ], |
||
33 | ], |
||
34 | ]; |
||
35 | |||
36 | $cacheStorage = m::mock(StorageInterface::class); |
||
37 | $cacheStorage->shouldReceive('getOptions->setCacheDir')->withArgs([$expectedPath])->once(); |
||
0 ignored issues
–
show
|
|||
38 | |||
39 | $stage = new ConfigureCache($cacheStorage); |
||
40 | |||
41 | self::assertSame($configuration, $stage($configuration)); |
||
42 | } |
||
43 | |||
44 | public function cacheDirProvider() |
||
45 | { |
||
46 | return [ |
||
47 | [ |
||
48 | '/tmp/cache', |
||
49 | '/tmp/cache', |
||
50 | ], |
||
51 | [ |
||
52 | 'cache/relative', |
||
53 | getcwd() . DIRECTORY_SEPARATOR . 'cache/relative', |
||
54 | ], |
||
55 | [ |
||
56 | new Path('/tmp/cache'), |
||
57 | '/tmp/cache', |
||
58 | ], |
||
59 | [ |
||
60 | new Path('cache/relative'), |
||
61 | getcwd() . DIRECTORY_SEPARATOR . 'cache/relative', |
||
62 | ], |
||
63 | ]; |
||
64 | } |
||
65 | } |
||
66 |
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: