FileDeletedTest.php in Entity Share 8.2
File
modules/entity_share_client/tests/src/Functional/FileDeletedTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\entity_share_client\Functional;
use Drupal\node\NodeInterface;
class FileDeletedTest extends FileTest {
protected static $filesData = [
'public_file_deleted' => [
'filename' => 'test_deleted.txt',
'filemime' => 'text/plain',
'uri' => 'public://test_deleted.txt',
'file_content' => 'Drupal',
],
];
protected function postSetupFixture() {
$this
->prepareContent();
$file_system = \Drupal::service('file_system');
foreach (static::$filesData as $file_data) {
$file_system
->delete($file_data['uri']);
}
$this
->populateRequestService();
$this
->deleteContent();
}
protected function getEntitiesDataArray() {
return [
'file' => [
'en' => $this
->preparePhysicalFilesAndFileEntitiesData(),
],
'node' => [
'en' => [
'es_test_public_file' => $this
->getCompleteNodeInfos([
'field_es_test_file' => [
'value_callback' => function () {
return [
[
'target_id' => $this
->getEntityId('file', 'public_file_deleted'),
],
];
},
'checker_callback' => 'getFilteredStructureValues',
],
'status' => [
'value' => NodeInterface::PUBLISHED,
'checker_callback' => 'getValue',
],
]),
],
],
];
}
public function testBasicPull() {
foreach (static::$filesData as $file_data) {
$this
->assertFalse(file_exists($file_data['uri']), 'The physical file ' . $file_data['filename'] . ' has been deleted.');
}
$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 recreated.');
}
}
}
Classes
Name |
Description |
FileDeletedTest |
Test class for file field where the physical file had been deleted. |