public function MediaBrowserPlusTest::testSubFolderDeletion in Media Browser Plus 7.3
Test the ability to delete sub-folders.
Introduced due https://drupal.org/node/2176317 @link https://drupal.org/node/2176317
At the moment writing this test hook_taxonomy_term_delete() is invoked after all data are removed from the db. However, there are static caches in effect that still allow to build the necessary paths to clean up the filesystem. Unfortunately this is only true for terms that have children. media_browser_plus_form_taxonomy_term_confirm_delete_submit() fixes that.
See also
media_browser_plus_form_taxonomy_term_confirm_delete_submit()
File
- tests/
media_browser_plus.test, line 259 - Media Browser Plus basic tests.
Class
- MediaBrowserPlusTest
- Basic media browser plus tests.
Code
public function testSubFolderDeletion() {
$this
->drupalLogin($this->adminUser);
// Create test folder structure.
$folders = array(
'source' => $this
->randomName(),
'source_child' => $this
->randomName(),
'source_child_child' => $this
->randomName(),
);
$hierarchy = array(
'root_folder' => array(
$folders['source'] => array(
$folders['source_child'] => array(
$folders['source_child_child'] => array(),
),
),
),
);
$this
->folderCreationHelper($hierarchy, FALSE);
$folders = taxonomy_get_term_by_name($folders['source_child_child']);
$folder = reset($folders);
$folder_path = media_browser_plus_construct_dir_path($folder);
// Delete the folder.
$this
->drupalPost('taxonomy/term/' . $folder->tid . '/edit', array(), t('Delete'));
$this
->drupalPost(NULL, array(), t('Delete'));
foreach (media_get_local_stream_wrappers() as $scheme => $scheme_info) {
$directory = file_stream_wrapper_uri_normalize($scheme . '://' . $folder_path);
$this
->assertFalse(file_exists($directory), 'Folder deleted');
}
// Just to have a verbose output.
$this
->drupalGet('admin/structure/taxonomy/media_folders');
}