Révision 1e39edcb
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/media/modules/media_wysiwyg/media_wysiwyg.test | ||
---|---|---|
99 | 99 |
} |
100 | 100 |
|
101 | 101 |
} |
102 |
|
|
103 |
/** |
|
104 |
* Defines base class for media_wysiwyg_view_mode test cases. |
|
105 |
*/ |
|
106 |
class MediaWYSIWYGViewModeTestHelper extends MediaWYSIWYGTestHelper { |
|
107 |
function setUp() { |
|
108 |
parent::setUp(); |
|
109 |
|
|
110 |
$web_user = $this->drupalCreateUser(array('access administration pages', 'administer file types', 'view files', 'use media wysiwyg')); |
|
111 |
$this->drupalLogin($web_user); |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Test configuring view modes available on the format form. |
|
117 |
*/ |
|
118 |
class FormatFormViewModesTest extends MediaWYSIWYGViewModeTestHelper { |
|
119 |
public static function getInfo() { |
|
120 |
return array( |
|
121 |
'name' => 'Format Form WYSIWYG View Modes', |
|
122 |
'description' => 'Test configuring view modes available on the format form.', |
|
123 |
'group' => 'Media WYSIWYG', |
|
124 |
); |
|
125 |
} |
|
126 |
|
|
127 |
function setUp() { |
|
128 |
parent::setUp(); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Configure format form view mode restrictions and ensure that they are followed. |
|
133 |
*/ |
|
134 |
function testAllowedFormatFormViewModes() { |
|
135 |
// Create an image file to test with. |
|
136 |
$files = $this->drupalGetTestFiles('image'); |
|
137 |
$files[0]->status = FILE_STATUS_PERMANENT; |
|
138 |
$file = file_save($files[0]); |
|
139 |
$fid = $file->fid; |
|
140 |
|
|
141 |
// Teaser view mode should be selectable. |
|
142 |
$this->drupalGet('media/' . $fid . '/format-form'); |
|
143 |
$this->assertResponse(200); |
|
144 |
$this->assertOption('edit-format', 'teaser'); |
|
145 |
|
|
146 |
// Restrict the use of the default view mode. |
|
147 |
$this->drupalGet('admin/structure/file-types/manage/image/file-display/teaser'); |
|
148 |
$this->assertResponse(200); |
|
149 |
$edit = array( |
|
150 |
'restrict_wysiwyg' => 1, |
|
151 |
); |
|
152 |
$this->drupalPost(NULL, $edit, t('Save configuration')); |
|
153 |
$this->assertResponse(200); |
|
154 |
|
|
155 |
// Teaser view mode should be restricted. |
|
156 |
$this->drupalGet('media/' . $fid . '/format-form'); |
|
157 |
$this->assertResponse(200); |
|
158 |
$this->assertNoOption('edit-format', 'teaser'); |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* Assert that a select option in the current page exists. |
|
163 |
* |
|
164 |
* @param $id |
|
165 |
* id of select field to assert. |
|
166 |
* @param $option |
|
167 |
* Option to assert. |
|
168 |
*/ |
|
169 |
function assertOption($id, $option, $message = '', $group = 'Browser') { |
|
170 |
$options = $this->xpath('//select[@id=:id]/option[@value=:option]', array(':id' => $id, ':option' => $option)); |
|
171 |
return $this->assertTrue(isset($options[0]), $message ? $message : t('Option @option for field @id exists.', array('@option' => $option, '@id' => $id))); |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Assert that a select option in the current page does not exist. |
|
176 |
* |
|
177 |
* @param $id |
|
178 |
* id of select field to assert. |
|
179 |
* @param $option |
|
180 |
* Option to assert. |
|
181 |
*/ |
|
182 |
function assertNoOption($id, $option, $message = '', $group = 'Browser') { |
|
183 |
$options = $this->xpath('//select[@id=:id]/option[@value=:option]', array(':id' => $id, ':option' => $option)); |
|
184 |
return $this->assertFalse(isset($options[0]), $message ? $message : t('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id))); |
|
185 |
} |
|
186 |
|
|
187 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules