diff --git a/tests/media.test b/tests/media.test index b72035e..893c949 100644 --- a/tests/media.test +++ b/tests/media.test @@ -610,6 +610,56 @@ class MediaBrowserLibraryTestCase extends MediaFileFieldTestCase { } /** + * Tests the media browser settings. + */ +class MediaBrowserSettingsTestCase extends MediaFileFieldTestCase { + public static function getInfo() { + return array( + 'name' => 'Media browser settings test', + 'description' => 'Tests the media browser settings.', + 'group' => 'Media', + ); + } + + /** + * Tests the media browser settings. + */ + function testBrowserSettings() { + // Perform the tests with all permutations of $scheme, $type and $extension. + foreach (array('public', 'private') as $scheme) { + foreach (array('image', 'document') as $type) { + foreach (array('jpg', 'txt') as $extension) { + $file = $this->createFileEntity(array('scheme' => $scheme, 'uid' => $this->admin_user->uid, 'type' => $type, 'filemime' => media_get_extension_mimetype($extension))); + + $options = array( + 'query' => array( + 'enabledPlugins' => array( + 'media_default--media_browser_1' => 'media_default--media_browser_1', + ), + 'schemes' => array($scheme), + 'types' => array($type), + 'file_extensions' => $extension, + ), + ); + + // Verify that the file is displayed. + $this->drupalGet('media/browser', $options); + $this->assertResponse(200); + $xpath = $this->buildXPathQuery('//ul[@class="media-list-thumbnails"]/li/div[@data-fid=:fid]/@data-fid', array( + ':fid' => $file->fid, + )); + $this->assertFieldByXPath($xpath, TRUE, format_string('File with file ID %fid found.', array('%fid' => $file->fid))); + + // Verify that no other files are also displayed. + $files = $this->xpath('//ul[@class="media-list-thumbnails"]/li/div[@data-fid]'); + $this->assertEqual(count($files), 1, 'There is only one file that matches the current browser configuration.'); + } + } + } + } +} + +/** * Tests the media browser 'My files' tab. */ class MediaBrowserMyFilesTestCase extends MediaFileFieldTestCase {