function MediaAdminTestCase::testFilesAdminSort in D7 Media 7.3
Same name and namespace in other branches
- 7.4 tests/media.test \MediaAdminTestCase::testFilesAdminSort()
- 7.2 tests/media.test \MediaAdminTestCase::testFilesAdminSort()
Tests that the table sorting works on the files admin pages.
File
- tests/
media.test, line 354 - Tests for media.module.
Class
- MediaAdminTestCase
- Test media file administration page functionality.
Code
function testFilesAdminSort() {
$i = 0;
foreach (array(
'dd',
'aa',
'DD',
'bb',
'cc',
'CC',
'AA',
'BB',
) as $prefix) {
$this
->createFileEntity(array(
'filepath' => $prefix . $this
->randomName(6),
'timestamp' => $i,
));
$i++;
}
// Test that the default sort by file_managed.timestamp DESC actually fires properly.
$files_query = db_select('file_managed', 'fm')
->fields('fm', array(
'fid',
))
->orderBy('timestamp', 'DESC')
->execute()
->fetchCol();
$files_form = array();
$this
->drupalGet('admin/content/file/thumbnails');
foreach ($this
->xpath('//ul[@class="media-list-thumbnails"]/li/div[@data-fid]/@data-fid') as $input) {
$files_form[] = $input;
}
$this
->assertEqual($files_query, $files_form, 'Files are sorted in the form according to the default query.');
// Compare the rendered HTML node list to a query for the files ordered by
// filename to account for possible database-dependent sort order.
$files_query = db_select('file_managed', 'fm')
->fields('fm', array(
'fid',
))
->orderBy('filename')
->execute()
->fetchCol();
$files_form = array();
$this
->drupalGet('admin/content/file/thumbnails', array(
'query' => array(
'sort' => 'asc',
'order' => 'Title',
),
));
foreach ($this
->xpath('//ul[@class="media-list-thumbnails"]/li/div[@data-fid]/@data-fid') as $input) {
$files_form[] = $input;
}
$this
->assertEqual($files_query, $files_form, 'Files are sorted in the form the same as they are in the query.');
}