public function FileTest::testFetchUnreadableFile in Migrate Plus 8.4
Same name and namespace in other branches
- 8.5 tests/src/Unit/data_fetcher/FileTest.php \Drupal\Tests\migrate_plus\Unit\data_fetcher\FileTest::testFetchUnreadableFile()
Test trying to fetch an unreadable file results in exception.
File
- tests/
src/ Unit/ data_fetcher/ FileTest.php, line 162 - PHPUnit tests for the Migrate Plus File 'data fetcher' plugin.
Class
- FileTest
- @coversDefaultClass \Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher\File
Namespace
Drupal\Tests\migrate_plus\Unit\data_fetcherCode
public function testFetchUnreadableFile() {
$file_name = 'file.json';
$file_path = vfsStream::url(implode(DIRECTORY_SEPARATOR, [
self::BASE_DIRECTORY,
$file_name,
]));
$migration_config = $this->specificMigrationConfig + [
'urls' => [
$file_path,
],
];
$plugin = new File($migration_config, $this->dataFetcherPluginId, $this->pluginDefinition);
// Create an unreadable file.
vfsStream::newFile($file_name, 0300)
->withContent($this->testData)
->at($this->baseDir);
// Trigger exception trying to read the non-readable file.
$this
->setExpectedException(MigrateException::class, 'file parser plugin: could not retrieve data from vfs://migration_data/file.json');
$plugin
->getResponseContent($file_path);
}