Issue #1843954 by ACF: Added Change menu test variables to the state system.
parent
723c3251da
commit
199fcdfe76
|
@ -225,7 +225,7 @@ class RouterTest extends WebTestBase {
|
||||||
function testHookCustomTheme() {
|
function testHookCustomTheme() {
|
||||||
// Trigger hook_custom_theme() to dynamically request the Stark theme for
|
// Trigger hook_custom_theme() to dynamically request the Stark theme for
|
||||||
// the requested page.
|
// the requested page.
|
||||||
variable_set('menu_test_hook_custom_theme_name', 'stark');
|
state()->set('menu_test.hook_custom_theme_name', 'stark');
|
||||||
theme_enable(array('stark', 'seven'));
|
theme_enable(array('stark', 'seven'));
|
||||||
|
|
||||||
// Visit a page that does not implement a theme callback. The above request
|
// Visit a page that does not implement a theme callback. The above request
|
||||||
|
@ -241,7 +241,7 @@ class RouterTest extends WebTestBase {
|
||||||
function testThemeCallbackHookCustomTheme() {
|
function testThemeCallbackHookCustomTheme() {
|
||||||
// Trigger hook_custom_theme() to dynamically request the Stark theme for
|
// Trigger hook_custom_theme() to dynamically request the Stark theme for
|
||||||
// the requested page.
|
// the requested page.
|
||||||
variable_set('menu_test_hook_custom_theme_name', 'stark');
|
state()->set('menu_test.hook_custom_theme_name', 'stark');
|
||||||
theme_enable(array('stark', 'seven'));
|
theme_enable(array('stark', 'seven'));
|
||||||
|
|
||||||
// The menu "theme callback" should take precedence over a value set in
|
// The menu "theme callback" should take precedence over a value set in
|
||||||
|
|
|
@ -88,12 +88,12 @@ class TrailTest extends MenuTestBase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test the tree generation for the Tools menu.
|
// Test the tree generation for the Tools menu.
|
||||||
variable_del('menu_test_menu_tree_set_path');
|
state()->delete('menu_test.menu_tree_set_path');
|
||||||
$this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree);
|
$this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree);
|
||||||
|
|
||||||
// Override the active trail for the Administration tree; it should not
|
// Override the active trail for the Administration tree; it should not
|
||||||
// affect the Tools tree.
|
// affect the Tools tree.
|
||||||
variable_set('menu_test_menu_tree_set_path', $test_menu_path);
|
state()->set('menu_test.menu_tree_set_path', $test_menu_path);
|
||||||
$this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree);
|
$this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree);
|
||||||
|
|
||||||
$breadcrumb = $config + array(
|
$breadcrumb = $config + array(
|
||||||
|
@ -114,12 +114,12 @@ class TrailTest extends MenuTestBase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test the tree generation for the Administration menu.
|
// Test the tree generation for the Administration menu.
|
||||||
variable_del('menu_test_menu_tree_set_path');
|
state()->delete('menu_test.menu_tree_set_path');
|
||||||
$this->assertBreadcrumb('admin/config/development/menu-trail', $breadcrumb, t('Menu trail - Case 2'), $tree);
|
$this->assertBreadcrumb('admin/config/development/menu-trail', $breadcrumb, t('Menu trail - Case 2'), $tree);
|
||||||
|
|
||||||
// Override the active trail for the Administration tree; it should affect
|
// Override the active trail for the Administration tree; it should affect
|
||||||
// the breadcrumbs and Administration tree.
|
// the breadcrumbs and Administration tree.
|
||||||
variable_set('menu_test_menu_tree_set_path', $test_menu_path);
|
state()->set('menu_test.menu_tree_set_path', $test_menu_path);
|
||||||
$this->assertBreadcrumb('admin/config/development/menu-trail', $override_breadcrumb, t('Menu trail - Case 2'), $override_tree);
|
$this->assertBreadcrumb('admin/config/development/menu-trail', $override_breadcrumb, t('Menu trail - Case 2'), $override_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,13 +171,13 @@ class TrailTest extends MenuTestBase {
|
||||||
foreach (array(403, 404) as $status_code) {
|
foreach (array(403, 404) as $status_code) {
|
||||||
// Before visiting the page, trigger the code in the menu_test module
|
// Before visiting the page, trigger the code in the menu_test module
|
||||||
// that will record the active trail (so we can check it in this test).
|
// that will record the active trail (so we can check it in this test).
|
||||||
variable_set('menu_test_record_active_trail', TRUE);
|
state()->set('menu_test.record_active_trail', TRUE);
|
||||||
$this->drupalGet($paths[$status_code]);
|
$this->drupalGet($paths[$status_code]);
|
||||||
$this->assertResponse($status_code);
|
$this->assertResponse($status_code);
|
||||||
|
|
||||||
// Check that the initial trail (during the Drupal bootstrap) matches
|
// Check that the initial trail (during the Drupal bootstrap) matches
|
||||||
// what we expect.
|
// what we expect.
|
||||||
$initial_trail = variable_get('menu_test_active_trail_initial', array());
|
$initial_trail = state()->get('menu_test.active_trail_initial') ?: array();
|
||||||
$this->assertEqual(count($initial_trail), count($expected_trail[$status_code]['initial']), format_string('The initial active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array(
|
$this->assertEqual(count($initial_trail), count($expected_trail[$status_code]['initial']), format_string('The initial active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array(
|
||||||
'@status_code' => $status_code,
|
'@status_code' => $status_code,
|
||||||
'@expected' => count($expected_trail[$status_code]['initial']),
|
'@expected' => count($expected_trail[$status_code]['initial']),
|
||||||
|
@ -194,7 +194,7 @@ class TrailTest extends MenuTestBase {
|
||||||
|
|
||||||
// Check that the final trail (after the user has been redirected to the
|
// Check that the final trail (after the user has been redirected to the
|
||||||
// custom 403/404 page) matches what we expect.
|
// custom 403/404 page) matches what we expect.
|
||||||
$final_trail = variable_get('menu_test_active_trail_final', array());
|
$final_trail = state()->get('menu_test.active_trail_final') ?: array();
|
||||||
$this->assertEqual(count($final_trail), count($expected_trail[$status_code]['final']), format_string('The final active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array(
|
$this->assertEqual(count($final_trail), count($expected_trail[$status_code]['final']), format_string('The final active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array(
|
||||||
'@status_code' => $status_code,
|
'@status_code' => $status_code,
|
||||||
'@expected' => count($expected_trail[$status_code]['final']),
|
'@expected' => count($expected_trail[$status_code]['final']),
|
||||||
|
|
|
@ -394,7 +394,7 @@ function menu_test_callback() {
|
||||||
* Callback that test menu_test_menu_tree_set_path().
|
* Callback that test menu_test_menu_tree_set_path().
|
||||||
*/
|
*/
|
||||||
function menu_test_menu_trail_callback() {
|
function menu_test_menu_trail_callback() {
|
||||||
$menu_path = variable_get('menu_test_menu_tree_set_path', array());
|
$menu_path = state()->get('menu_test.menu_tree_set_path') ?: array();
|
||||||
if (!empty($menu_path)) {
|
if (!empty($menu_path)) {
|
||||||
menu_tree_set_path($menu_path['menu_name'], $menu_path['path']);
|
menu_tree_set_path($menu_path['menu_name'], $menu_path['path']);
|
||||||
}
|
}
|
||||||
|
@ -408,8 +408,8 @@ function menu_test_init() {
|
||||||
// When requested by one of the MenuTrailTestCase tests, record the initial
|
// When requested by one of the MenuTrailTestCase tests, record the initial
|
||||||
// active trail during Drupal's bootstrap (before the user is redirected to a
|
// active trail during Drupal's bootstrap (before the user is redirected to a
|
||||||
// custom 403 or 404 page). See menu_test_custom_403_404_callback().
|
// custom 403 or 404 page). See menu_test_custom_403_404_callback().
|
||||||
if (variable_get('menu_test_record_active_trail', FALSE)) {
|
if (state()->get('menu_test.record_active_trail') ?: FALSE) {
|
||||||
variable_set('menu_test_active_trail_initial', menu_get_active_trail());
|
state()->set('menu_test.active_trail_initial', menu_get_active_trail());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,8 +420,8 @@ function menu_test_custom_403_404_callback() {
|
||||||
// When requested by one of the MenuTrailTestCase tests, record the final
|
// When requested by one of the MenuTrailTestCase tests, record the final
|
||||||
// active trail now that the user has been redirected to the custom 403 or
|
// active trail now that the user has been redirected to the custom 403 or
|
||||||
// 404 page. See menu_test_init().
|
// 404 page. See menu_test_init().
|
||||||
if (variable_get('menu_test_record_active_trail', FALSE)) {
|
if (state()->get('menu_test.record_active_trail') ?: FALSE) {
|
||||||
variable_set('menu_test_active_trail_final', menu_get_active_trail());
|
state()->set('menu_test.active_trail_final', menu_get_active_trail());
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'This is menu_test_custom_403_404_callback().';
|
return 'This is menu_test_custom_403_404_callback().';
|
||||||
|
@ -487,7 +487,7 @@ function menu_test_custom_theme() {
|
||||||
// If an appropriate variable has been set in the database, request the theme
|
// If an appropriate variable has been set in the database, request the theme
|
||||||
// that is stored there. Otherwise, do not attempt to dynamically set the
|
// that is stored there. Otherwise, do not attempt to dynamically set the
|
||||||
// theme.
|
// theme.
|
||||||
if ($theme = variable_get('menu_test_hook_custom_theme_name', FALSE)) {
|
if ($theme = state()->get('menu_test.hook_custom_theme_name') ?: FALSE) {
|
||||||
return $theme;
|
return $theme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue