protected function FileTest::getModuleHandlerMock in Freelinking 4.0.x
Same name and namespace in other branches
- 8.3 tests/src/Unit/Plugin/freelinking/FileTest.php \Drupal\Tests\freelinking\Unit\Plugin\freelinking\FileTest::getModuleHandlerMock()
Get a mock of the module handler service depending on file_download result.
Parameters
int $fileAvailability: Whether the file should not exist (0), exist (1) or not be accessible (-1).
Return value
\Drupal\Core\Extension\ModuleHandlerInterface The module handler service mock.
2 calls to FileTest::getModuleHandlerMock()
- FileTest::setUp in tests/
src/ Unit/ Plugin/ freelinking/ FileTest.php - FileTest::testBuildLink in tests/
src/ Unit/ Plugin/ freelinking/ FileTest.php - Assert that buildLink is functional.
File
- tests/
src/ Unit/ Plugin/ freelinking/ FileTest.php, line 217
Class
- FileTest
- Tests the freelinking file plugin.
Namespace
Drupal\Tests\freelinking\Unit\Plugin\freelinkingCode
protected function getModuleHandlerMock($fileAvailability = 0) {
// Mock module handler service.
$moduleHandlerProphet = $this
->prophesize('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
$moduleHandlerProphet
->invokeAll('file_download', Argument::any())
->will(function ($args) use ($fileAvailability) {
$ret = [];
if ($fileAvailability === -1) {
$ret['file'] = -1;
}
return $ret;
});
return $moduleHandlerProphet
->reveal();
}