1 |
ca0757b9
|
Assos Assos
|
<?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 |
|
|
class MediaWYSIWYGViewModeTestHelper extends MediaWYSIWYGTestHelper {
|
12 |
|
|
function setUp() {
|
13 |
|
|
parent::setUp('media_wysiwyg_view_mode');
|
14 |
|
|
|
15 |
2b3c8cc1
|
Assos Assos
|
$web_user = $this->drupalCreateUser(array('administer media wysiwyg view mode', 'view files', 'use media wysiwyg'));
|
16 |
ca0757b9
|
Assos Assos
|
$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 |
|
|
function setUp() {
|
33 |
|
|
parent::setUp();
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
/**
|
37 |
|
|
* Configure format form view mode restrictions and ensure that they are followed.
|
38 |
|
|
*/
|
39 |
|
|
function testAllowedFormatFormViewModes() {
|
40 |
|
|
// Load the Media WYSIWYG View Mode administration page.
|
41 |
|
|
$this->drupalGet('admin/config/media/wysiwyg-view-mode');
|
42 |
|
|
$this->assertResponse(200, t('The privileged user can access the Media WYSIWYG View Mode administration page.'));
|
43 |
|
|
|
44 |
|
|
// Create an image file to test with.
|
45 |
|
|
$files = $this->drupalGetTestFiles('image');
|
46 |
|
|
$files[0]->status = FILE_STATUS_PERMANENT;
|
47 |
|
|
$file = file_save($files[0]);
|
48 |
|
|
$fid = $file->fid;
|
49 |
|
|
|
50 |
|
|
// The default view mode should be selected by default.
|
51 |
|
|
$this->drupalGet('media/' . $fid . '/format-form');
|
52 |
|
|
$this->assertOptionSelected('edit-format', 'default');
|
53 |
|
|
|
54 |
|
|
// Restrict the use of the default view mode.
|
55 |
|
|
variable_set('media_wysiwyg_view_mode_image_wysiwyg_restricted_view_modes_status', TRUE);
|
56 |
|
|
$restricted_view_modes = array(
|
57 |
|
|
'default' => 'default',
|
58 |
|
|
);
|
59 |
|
|
variable_set('media_wysiwyg_view_mode_image_wysiwyg_restricted_view_modes', $restricted_view_modes);
|
60 |
|
|
|
61 |
|
|
// The teaser view mode should now be selected by default.
|
62 |
|
|
$this->drupalGet('media/' . $fid . '/format-form');
|
63 |
|
|
$this->assertOptionSelected('edit-format', 'teaser');
|
64 |
|
|
}
|
65 |
|
|
} |