public function FileTest::testBasicPull in Entity Share 8.3
Same name and namespace in other branches
- 8.2 modules/entity_share_client/tests/src/Functional/FileTest.php \Drupal\Tests\entity_share_client\Functional\FileTest::testBasicPull()
Test basic pull feature.
1 method overrides FileTest::testBasicPull()
- FileDeletedTest::testBasicPull in modules/
entity_share_client/ tests/ src/ Functional/ FileDeletedTest.php - Test basic pull feature.
File
- modules/
entity_share_client/ tests/ src/ Functional/ FileTest.php, line 316
Class
- FileTest
- Functional test class for file field.
Namespace
Drupal\Tests\entity_share_client\FunctionalCode
public function testBasicPull() {
$this
->commonBasicPull();
// Test again without the import plugin "Physical file".
$this
->removePluginFromImportConfig('physical_file');
// Need to remove all imported content (and files) prior to that.
$this
->resetImportedContent();
foreach (static::$filesData as $file_data) {
$this
->assertFalse(file_exists($file_data['uri']), 'The physical file ' . $file_data['filename'] . ' has been deleted.');
}
// Pull just one entity with attached file, and without this plugin
// the file should not exist.
$this
->pullEveryChannels();
$this
->checkCreatedEntities();
foreach (static::$filesData as $file_data) {
$this
->assertFalse(file_exists($file_data['uri']), 'The physical file ' . $file_data['filename'] . ' has not been pulled and recreated.');
}
// Test rename option.
// Re-enable the plugin.
$this
->mergePluginsToImportConfig([
'physical_file' => [
'rename' => FALSE,
'weights' => [
'process_entity' => 0,
],
],
]);
// Need to remove all imported content (and files) prior to that.
$this
->resetImportedContent();
// Pull twice to test that by default there are no duplicated physical
// files.
$this
->pullEveryChannels();
$this->importService
->getRuntimeImportContext()
->clearImportedEntities();
$this
->pullEveryChannels();
// Test that the files had been recreated without rename.
foreach (static::$filesData as $file_data) {
$this
->assertTrue(file_exists($file_data['uri']), 'The physical file ' . $file_data['filename'] . ' has been pulled and recreated.');
$replaced_file_info = $this
->getReplacedFileInfo($file_data);
$this
->assertFalse(file_exists($replaced_file_info['uri']), 'The physical file ' . $replaced_file_info['filename'] . ' has not been renamed.');
}
// Need to remove all imported content (and files) prior to that.
$this
->resetImportedContent();
// Update the 'rename' setting.
$this
->mergePluginsToImportConfig([
'physical_file' => [
'rename' => TRUE,
'weights' => [
'process_entity' => 0,
],
],
]);
$this
->pullEveryChannels();
$this->importService
->getRuntimeImportContext()
->clearImportedEntities();
// At the first import there should not be duplicated files.
foreach (static::$filesData as $file_data) {
$this
->assertTrue(file_exists($file_data['uri']), 'The physical file ' . $file_data['filename'] . ' has been pulled and recreated.');
$replaced_file_info = $this
->getReplacedFileInfo($file_data);
$this
->assertFalse(file_exists($replaced_file_info['uri']), 'The physical file ' . $replaced_file_info['filename'] . ' has not been renamed.');
}
$this
->pullEveryChannels();
// At the second import there should be duplicated files.
foreach (static::$filesData as $file_data) {
$this
->assertTrue(file_exists($file_data['uri']), 'The physical file ' . $file_data['filename'] . ' still exists.');
$replaced_file_info = $this
->getReplacedFileInfo($file_data);
$this
->assertTrue(file_exists($replaced_file_info['uri']), 'The physical file ' . $replaced_file_info['filename'] . ' has been created.');
}
}