1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Tests for ensuring media macros render properly.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Defines media macro test cases.
|
10
|
*/
|
11
|
class MediaWYSIWYGWYSIWYGOverridesTest extends MediaWYSIWYGTestHelper {
|
12
|
|
13
|
/**
|
14
|
* Provide test information.
|
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
|
public function setUp() {
|
26
|
parent::setUp('token');
|
27
|
|
28
|
// 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);
|
31
|
|
32
|
// Enable the media filter for full html.
|
33
|
$edit = array(
|
34
|
'filters[media_filter][status]' => TRUE,
|
35
|
'filters[filter_html][status]' => FALSE,
|
36
|
);
|
37
|
$this->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration'));
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* Test image media overrides.
|
42
|
*/
|
43
|
public function testAttributeOverrides() {
|
44
|
$files = $this->drupalGetTestFiles('image');
|
45
|
$file = file_save($files[0]);
|
46
|
|
47
|
// Create a node to test with.
|
48
|
$nid = $this->createNode($file->fid);
|
49
|
|
50
|
$this->drupalGet('node/' . $nid);
|
51
|
$this->assertRaw('width="100"', t('Image displays with default width attribute.'));
|
52
|
$this->assertRaw('height="100"', t('Image displays with default height attribute.'));
|
53
|
|
54
|
// Create a node with a style attribute.
|
55
|
$attributes = array(
|
56
|
'style' => 'float: left; width: 50px;',
|
57
|
);
|
58
|
$nid = $this->createNode($file->fid, $attributes);
|
59
|
$this->drupalGet('node/' . $nid);
|
60
|
$this->assertRaw(drupal_attributes($attributes), t('Image displays with overriden attributes.'));
|
61
|
|
62
|
// Create a node with overriden alt/title attributes.
|
63
|
$attributes = array(
|
64
|
'alt' => $this->randomName(),
|
65
|
'title' => $this->randomName(),
|
66
|
);
|
67
|
$nid = $this->createNode($file->fid, $attributes);
|
68
|
$this->drupalGet('node/' . $nid);
|
69
|
$this->assertRaw(drupal_attributes($attributes), t('Image displays with alt/title set as attributes.'));
|
70
|
|
71
|
// Create a node with overriden alt/title fields.
|
72
|
$fields = $attributes = array();
|
73
|
$attributes['alt'] = $fields['field_file_image_alt_text[und][0][value]'] = $this->randomName();
|
74
|
$attributes['title'] = $fields['field_file_image_title_text[und][0][value]'] = $this->randomName();
|
75
|
|
76
|
$nid = $this->createNode($file->fid, array(), $fields);
|
77
|
$this->drupalGet('node/' . $nid);
|
78
|
// Ensure that the alt/title from attributes display.
|
79
|
$this->assertRaw(drupal_attributes($attributes), t('Image displays with alt/title set as fields.'));
|
80
|
|
81
|
// Create a node with overriden alt/title fields as well as attributes.
|
82
|
$attributes = array(
|
83
|
'alt' => $this->randomName(),
|
84
|
'title' => $this->randomName(),
|
85
|
);
|
86
|
$fields = array(
|
87
|
'field_file_image_alt_text[und][0][value]' => $this->randomName(),
|
88
|
'field_file_image_title_text[und][0][value]' => $this->randomName(),
|
89
|
);
|
90
|
$nid = $this->createNode($file->fid, $attributes, $fields);
|
91
|
$this->drupalGet('node/' . $nid);
|
92
|
// Ensure that the alt/title from attributes display rather the field ones.
|
93
|
$this->assertRaw(drupal_attributes($attributes), t('Image displays with alt/title set as attributes overriding field values.'));
|
94
|
}
|
95
|
}
|