Browse Source

Updated test cases to include file deletion

pull/905/head
shriram 2 years ago
parent
commit
ef1f36f283
  1. 7
      islandora.module
  2. 13
      tests/src/Functional/DeleteNodeWithMediaAndFile.php

7
islandora.module

@ -347,9 +347,12 @@ function islandora_form_alter(&$form, FormStateInterface $form_state, $form_id)
'#title' => t('Delete all associated medias and nodes'),
];
$media_list = [];
foreach ($medias as $media) {
$media_list[] = $media->getName();
}
$form['media_items'] = [
'#theme' => 'item_list',
'#type' => 'ul',
@ -451,9 +454,9 @@ function islandora_object_delete_form_submit($form, &$form_state) {
if ($delete_files) {
$file_storage->delete($delete_files);
foreach ($delete_files as $media) {
foreach ($delete_files as $file) {
$logger->notice('The file %label has been deleted.', [
'%label' => $media->label(),
'%label' => $file->label(),
]);
}
}

13
tests/src/Functional/DeleteNodeWithMedia.php → tests/src/Functional/DeleteNodeWithMediaAndFile.php

@ -7,17 +7,18 @@ namespace Drupal\Tests\islandora\Functional;
*
* @group islandora
*/
class DeleteNodeWithMedia extends IslandoraFunctionalTestBase {
class DeleteNodeWithMediaAndFile extends IslandoraFunctionalTestBase {
/**
* Tests delete Node and its assoicated media.
*/
public function testDeleteNodeWithMedia() {
public function testDeleteNodeWithMediaAndFile() {
$account = $this->drupalCreateUser([
'delete any media',
'create media',
'view media',
'bypass node access',
'access files overview',
]);
$this->drupalLogin($account);
@ -81,14 +82,18 @@ class DeleteNodeWithMedia extends IslandoraFunctionalTestBase {
$assert_session->pageTextContains('Media2');
$this->submitForm($delete, 'Delete');
$assert_session->pageTextContains('Media1');
$assert_session->pageTextContains('Media2');
$assert_session->pageTextContains($media1->id());
$assert_session->pageTextContains($media2->id());
$this->drupalGet("media/1/delete");
$assert_session->pageTextContains('Page not found');
$this->drupalGet("media/2/delete");
$assert_session->pageTextContains('Page not found');
$this->drupalGet("/admin/content/files");
$assert_session->pageTextNotContains('test.jpeg');
}
}
Loading…
Cancel
Save