Révision ba3b3627
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/media/modules/media_wysiwyg/tests/media_wysiwyg.macro.test | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 |
* Defines media macro test cases.
|
|
9 |
* Base class for testing rendered wysiwyg macros.
|
|
10 | 10 |
*/ |
11 |
class MediaWYSIWYGWYSIWYGOverridesTest extends MediaWYSIWYGTestHelper {
|
|
11 |
abstract class MediaWYSIWYGMacroTestHelper extends MediaWYSIWYGTestHelper {
|
|
12 | 12 |
|
13 | 13 |
/** |
14 |
* Provide test information.
|
|
14 |
* Common setup routines for rendered media macros.
|
|
15 | 15 |
*/ |
16 |
public static function getInfo() { |
|
17 |
return array( |
|
18 |
'name' => t('Media WYSIWYG WYSIWYG overrides'), |
|
19 |
'description' => t('Tests that overridden attributes display correct.'), |
|
20 |
'group' => t('Media WYSIWYG'), |
|
21 |
'dependencies' => array('token'), |
|
22 |
); |
|
23 |
} |
|
24 |
|
|
25 | 16 |
public function setUp() { |
26 |
parent::setUp('token');
|
|
17 |
parent::setUp(array('field_ui', 'token'));
|
|
27 | 18 |
|
28 | 19 |
// Create and log in a user. |
29 |
$account = $this->drupalCreateUser(array('create article content', 'administer filters', 'use text format filtered_html')); |
|
30 |
$this->drupalLogin($account); |
|
20 |
$this->admin_user = $this->drupalCreateUser(array( |
|
21 |
'administer file types', |
|
22 |
'administer fields', |
|
23 |
'administer filters', |
|
24 |
'create article content', |
|
25 |
'use text format filtered_html', |
|
26 |
)); |
|
27 |
$this->drupalLogin($this->admin_user); |
|
31 | 28 |
|
32 | 29 |
// Enable the media filter for full html. |
33 | 30 |
$edit = array( |
... | ... | |
37 | 34 |
$this->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration')); |
38 | 35 |
} |
39 | 36 |
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* Defines rendered media macros test cases. |
|
41 |
*/ |
|
42 |
class MediaWYSIWYGRenderMacrosTest extends MediaWYSIWYGMacroTestHelper { |
|
43 |
|
|
44 |
/** |
|
45 |
* Test information. |
|
46 |
*/ |
|
47 |
public static function getInfo() { |
|
48 |
return array( |
|
49 |
'name' => t('Media WYSIWYG Rendered Macros test'), |
|
50 |
'description' => t('Test that rendered macros are displayed correctly.'), |
|
51 |
'group' => t('Media WYSIWYG'), |
|
52 |
'dependencies' => array('token'), |
|
53 |
); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* Test that displayed fields on file entity are rendered correctly. |
|
58 |
*/ |
|
59 |
public function testEmptyField() { |
|
60 |
// Add a field as part of the rendered macro. |
|
61 |
$edit = array( |
|
62 |
'fields[field_file_image_title_text][type]' => 'text_default', |
|
63 |
); |
|
64 |
$this->drupalPost('admin/structure/file-types/manage/image/display/preview', $edit, t('Save')); |
|
65 |
|
|
66 |
// Assert that fields that are enabled in display settings for macro are NOT |
|
67 |
// rendered if empty. |
|
68 |
$files = $this->drupalGetTestFiles('image'); |
|
69 |
$attributes = array( |
|
70 |
'alt' => $this->randomName(), |
|
71 |
'title' => '', |
|
72 |
); |
|
73 |
$fields = array( |
|
74 |
'field_file_image_alt_text[und][0][value]' => $attributes['alt'], |
|
75 |
'field_file_image_title_text[und][0][value]' => $attributes['title'], |
|
76 |
); |
|
77 |
$files[0]->field_file_image_alt_text[LANGUAGE_NONE][0]['value'] = $attributes['alt']; |
|
78 |
$files[0]->field_file_image_title_text[LANGUAGE_NONE][0]['value'] = $attributes['title']; |
|
79 |
$file = file_save($files[0]); |
|
80 |
$nid = $this->createNode($file->fid, $attributes, $fields); |
|
81 |
$this->drupalGet('node/' . $nid); |
|
82 |
// Assert that the empty field isn't rendered. |
|
83 |
$this->assertNoPattern('|<div class="[^">]*field-name-field-file-image-title-text|', t('Displayed text field with empty value not rendered.')); |
|
84 |
} |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Defines media macro override test cases. |
|
90 |
*/ |
|
91 |
class MediaWYSIWYGWYSIWYGOverridesTest extends MediaWYSIWYGMacroTestHelper { |
|
92 |
|
|
93 |
/** |
|
94 |
* Provide test information. |
|
95 |
*/ |
|
96 |
public static function getInfo() { |
|
97 |
return array( |
|
98 |
'name' => t('Media WYSIWYG WYSIWYG overrides'), |
|
99 |
'description' => t('Tests that overridden attributes display correct.'), |
|
100 |
'group' => t('Media WYSIWYG'), |
|
101 |
'dependencies' => array('token'), |
|
102 |
); |
|
103 |
} |
|
104 |
|
|
40 | 105 |
/** |
41 | 106 |
* Test image media overrides. |
42 | 107 |
*/ |
Formats disponibles : Unified diff
Weekly update of contrib modules