1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Tests for media_wysiwyg_view_mode.module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Defines base class for media_wysiwyg_view_mode test cases.
|
10
|
*/
|
11
|
abstract class MediaWYSIWYGViewModeTestHelper extends MediaWYSIWYGTestHelper {
|
12
|
function setUp() {
|
13
|
parent::setUp(array('media_wysiwyg_view_mode'));
|
14
|
|
15
|
$web_user = $this->drupalCreateUser(array('view files', 'use media wysiwyg', 'administer file types'));
|
16
|
$this->drupalLogin($web_user);
|
17
|
}
|
18
|
}
|
19
|
|
20
|
/**
|
21
|
* Test configuring view modes available on the format form.
|
22
|
*/
|
23
|
class FormatFormViewModesTest extends MediaWYSIWYGViewModeTestHelper {
|
24
|
public static function getInfo() {
|
25
|
return array(
|
26
|
'name' => 'Format Form WYSIWYG View Modes',
|
27
|
'description' => 'Test configuring view modes available on the format form.',
|
28
|
'group' => 'Media WYSIWYG View Mode',
|
29
|
);
|
30
|
}
|
31
|
|
32
|
/**
|
33
|
* Configure format form view mode restrictions and ensure that they are followed.
|
34
|
*/
|
35
|
function testAllowedFormatFormViewModes() {
|
36
|
// Create an image file to test with.
|
37
|
$files = $this->drupalGetTestFiles('image');
|
38
|
$files[0]->status = FILE_STATUS_PERMANENT;
|
39
|
$file = file_save($files[0]);
|
40
|
$fid = $file->fid;
|
41
|
|
42
|
// The default view mode should be selected by default.
|
43
|
$this->drupalGet('media/' . $fid . '/format-form');
|
44
|
$this->assertOptionSelected('edit-format', 'default');
|
45
|
|
46
|
$edit = array(
|
47
|
'media_wysiwyg_view_mode[media_wysiwyg_view_mode_image_wysiwyg_restricted_view_modes_status]' => TRUE,
|
48
|
'media_wysiwyg_view_mode[media_wysiwyg_view_mode_image_wysiwyg_restricted_view_modes][default]' => TRUE,
|
49
|
);
|
50
|
$this->drupalPost('admin/structure/file-types/manage/image/edit', $edit, 'Save');
|
51
|
|
52
|
// The teaser view mode should now be selected by default.
|
53
|
$this->drupalGet('media/' . $fid . '/format-form');
|
54
|
$this->assertOptionSelected('edit-format', 'teaser');
|
55
|
}
|
56
|
}
|