update core to 7.36
This commit is contained in:
@@ -155,6 +155,15 @@ class ThemeTestCase extends DrupalWebTestCase {
|
||||
$this->assertNotEqual(theme_get_setting('subtheme_override', 'test_basetheme'), theme_get_setting('subtheme_override', 'test_subtheme'), 'Base theme\'s default settings values can be overridden by subtheme.');
|
||||
$this->assertIdentical(theme_get_setting('basetheme_only', 'test_subtheme'), 'base theme value', 'Base theme\'s default settings values are inherited by subtheme.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the drupal_add_region_content() function.
|
||||
*/
|
||||
function testDrupalAddRegionContent() {
|
||||
$this->drupalGet('theme-test/drupal-add-region-content');
|
||||
$this->assertText('Hello');
|
||||
$this->assertText('World');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,28 +434,100 @@ class ThemeFastTestCase extends DrupalWebTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit tests for theme_html_tag().
|
||||
* Tests the markup of core render element types passed to drupal_render().
|
||||
*/
|
||||
class ThemeHtmlTag extends DrupalUnitTestCase {
|
||||
class RenderElementTypesTestCase extends DrupalWebTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Theme HTML Tag',
|
||||
'description' => 'Tests theme_html_tag() built-in theme functions.',
|
||||
'name' => 'Render element types',
|
||||
'description' => 'Tests the markup of core render element types passed to drupal_render().',
|
||||
'group' => 'Theme',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function theme_html_tag()
|
||||
* Asserts that an array of elements is rendered properly.
|
||||
*
|
||||
* @param array $elements
|
||||
* An array of associative arrays describing render elements and their
|
||||
* expected markup. Each item in $elements must contain the following:
|
||||
* - 'name': This human readable description will be displayed on the test
|
||||
* results page.
|
||||
* - 'value': This is the render element to test.
|
||||
* - 'expected': This is the expected markup for the element in 'value'.
|
||||
*/
|
||||
function testThemeHtmlTag() {
|
||||
// Test auto-closure meta tag generation
|
||||
$tag['element'] = array('#tag' => 'meta', '#attributes' => array('name' => 'description', 'content' => 'Drupal test'));
|
||||
$this->assertEqual('<meta name="description" content="Drupal test" />'."\n", theme_html_tag($tag), 'Test auto-closure meta tag generation.');
|
||||
function assertElements($elements) {
|
||||
foreach($elements as $element) {
|
||||
$this->assertIdentical(drupal_render($element['value']), $element['expected'], '"' . $element['name'] . '" input rendered correctly by drupal_render().');
|
||||
}
|
||||
}
|
||||
|
||||
// Test title tag generation
|
||||
$tag['element'] = array('#tag' => 'title', '#value' => 'title test');
|
||||
$this->assertEqual('<title>title test</title>'."\n", theme_html_tag($tag), 'Test title tag generation.');
|
||||
/**
|
||||
* Tests system #type 'container'.
|
||||
*/
|
||||
function testContainer() {
|
||||
$elements = array(
|
||||
// Basic container with no attributes.
|
||||
array(
|
||||
'name' => "#type 'container' with no HTML attributes",
|
||||
'value' => array(
|
||||
'#type' => 'container',
|
||||
'child' => array(
|
||||
'#markup' => 'foo',
|
||||
),
|
||||
),
|
||||
'expected' => '<div>foo</div>',
|
||||
),
|
||||
// Container with a class.
|
||||
array(
|
||||
'name' => "#type 'container' with a class HTML attribute",
|
||||
'value' => array(
|
||||
'#type' => 'container',
|
||||
'child' => array(
|
||||
'#markup' => 'foo',
|
||||
),
|
||||
'#attributes' => array(
|
||||
'class' => 'bar',
|
||||
),
|
||||
),
|
||||
'expected' => '<div class="bar">foo</div>',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertElements($elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests system #type 'html_tag'.
|
||||
*/
|
||||
function testHtmlTag() {
|
||||
$elements = array(
|
||||
// Test auto-closure meta tag generation.
|
||||
array(
|
||||
'name' => "#type 'html_tag' auto-closure meta tag generation",
|
||||
'value' => array(
|
||||
'#type' => 'html_tag',
|
||||
'#tag' => 'meta',
|
||||
'#attributes' => array(
|
||||
'name' => 'description',
|
||||
'content' => 'Drupal test',
|
||||
),
|
||||
),
|
||||
'expected' => '<meta name="description" content="Drupal test" />' . "\n",
|
||||
),
|
||||
// Test title tag generation.
|
||||
array(
|
||||
'name' => "#type 'html_tag' title tag generation",
|
||||
'value' => array(
|
||||
'#type' => 'html_tag',
|
||||
'#tag' => 'title',
|
||||
'#value' => 'title test',
|
||||
),
|
||||
'expected' => '<title>title test</title>' . "\n",
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertElements($elements);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,3 +581,68 @@ class ThemeRegistryTestCase extends DrupalWebTestCase {
|
||||
$this->assertTrue($registry['theme_test_template_test_2'], 'Offset was returned correctly from the theme registry');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for theme debug markup.
|
||||
*/
|
||||
class ThemeDebugMarkupTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Theme debug markup',
|
||||
'description' => 'Tests theme debug markup output.',
|
||||
'group' => 'Theme',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('theme_test', 'node');
|
||||
theme_enable(array('test_theme'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests debug markup added to template output.
|
||||
*/
|
||||
function testDebugOutput() {
|
||||
variable_set('theme_default', 'test_theme');
|
||||
// Enable the debug output.
|
||||
variable_set('theme_debug', TRUE);
|
||||
|
||||
$registry = theme_get_registry();
|
||||
$extension = '.tpl.php';
|
||||
// Populate array of templates.
|
||||
$templates = drupal_find_theme_templates($registry, $extension, drupal_get_path('theme', 'test_theme'));
|
||||
$templates += drupal_find_theme_templates($registry, $extension, drupal_get_path('module', 'node'));
|
||||
|
||||
// Create a node and test different features of the debug markup.
|
||||
$node = $this->drupalCreateNode();
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertRaw('<!-- THEME DEBUG -->', 'Theme debug markup found in theme output when debug is enabled.');
|
||||
$this->assertRaw("CALL: theme('node')", 'Theme call information found.');
|
||||
$this->assertRaw('x node--1' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' * node' . $extension, 'Suggested template files found in order and node ID specific template shown as current template.');
|
||||
$template_filename = $templates['node__1']['path'] . '/' . $templates['node__1']['template'] . $extension;
|
||||
$this->assertRaw("BEGIN OUTPUT from '$template_filename'", 'Full path to current template file found.');
|
||||
|
||||
// Create another node and make sure the template suggestions shown in the
|
||||
// debug markup are correct.
|
||||
$node2 = $this->drupalCreateNode();
|
||||
$this->drupalGet('node/' . $node2->nid);
|
||||
$this->assertRaw('* node--2' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' x node' . $extension, 'Suggested template files found in order and base template shown as current template.');
|
||||
|
||||
// Create another node and make sure the template suggestions shown in the
|
||||
// debug markup are correct.
|
||||
$node3 = $this->drupalCreateNode();
|
||||
$build = array('#theme' => 'node__foo__bar');
|
||||
$build += node_view($node3);
|
||||
$output = drupal_render($build);
|
||||
$this->assertTrue(strpos($output, "CALL: theme('node__foo__bar')") !== FALSE, 'Theme call information found.');
|
||||
$this->assertTrue(strpos($output, '* node--foo--bar' . $extension . PHP_EOL . ' * node--foo' . $extension . PHP_EOL . ' * node--3' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.');
|
||||
|
||||
// Disable theme debug.
|
||||
variable_set('theme_debug', FALSE);
|
||||
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertNoRaw('<!-- THEME DEBUG -->', 'Theme debug markup not found in theme output when debug is disabled.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user