/**
  * Check the enabled Bartik blocks are correctly copied over.
  */
 function testNewDefaultThemeBlocks()
 {
     $default_theme = \Drupal::config('system.theme')->get('default');
     // Add two instances of the user login block.
     $this->drupalPlaceBlock('user_login_block', array('id' => $default_theme . '_' . strtolower($this->randomMachineName(8))));
     $this->drupalPlaceBlock('user_login_block', array('id' => $default_theme . '_' . strtolower($this->randomMachineName(8))));
     // Add an instance of a different block.
     $this->drupalPlaceBlock('system_powered_by_block', array('id' => $default_theme . '_' . strtolower($this->randomMachineName(8))));
     // Enable a different theme.
     $new_theme = 'bartik';
     $this->assertFalse($new_theme == $default_theme, 'The new theme is different from the previous default theme.');
     theme_enable(array($new_theme));
     \Drupal::config('system.theme')->set('default', $new_theme)->save();
     // Ensure that the new theme has all the blocks as the previous default.
     $default_block_names = $this->container->get('entity.query')->get('block')->condition('theme', $default_theme)->execute();
     $new_blocks = $this->container->get('entity.query')->get('block')->condition('theme', $new_theme)->execute();
     $this->assertTrue(count($default_block_names) == count($new_blocks), 'The new default theme has the same number of blocks as the previous theme.');
     foreach ($default_block_names as $default_block_name) {
         // Remove the matching block from the list of blocks in the new theme.
         // E.g., if the old theme has block.block.stark_admin,
         // unset block.block.bartik_admin.
         unset($new_blocks[str_replace($default_theme . '_', $new_theme . '_', $default_block_name)]);
     }
     $this->assertTrue(empty($new_blocks), 'The new theme has exactly the same blocks as the previous default theme.');
 }
 /**
  * Check the enabled Garland blocks are correctly copied over.
  */
 function testNewDefaultThemeBlocks()
 {
     // Create administrative user.
     $adminuser = $this->drupalCreateUser(array('administer themes'));
     $this->drupalLogin($adminuser);
     // Ensure no other theme's blocks are in the block table yet.
     $count = db_query_range("SELECT 1 FROM {block} WHERE theme NOT IN ('garland', 'seven')", 0, 1)->fetchField();
     $this->assertFalse($count, t('Only Garland and Seven have blocks.'));
     // Populate list of all blocks for matching against new theme.
     $blocks = array();
     $result = db_query("SELECT * FROM {block} WHERE theme = 'garland'");
     foreach ($result as $block) {
         // $block->theme and $block->bid will not match, so remove them.
         unset($block->theme, $block->bid);
         $blocks[$block->module][$block->delta] = $block;
     }
     // Turn on the Stark theme and ensure that it contains all of the blocks
     // that Garland did.
     theme_enable(array('stark'));
     variable_set('theme_default', 'stark');
     $result = db_query("SELECT * FROM {block} WHERE theme='stark'");
     foreach ($result as $block) {
         unset($block->theme, $block->bid);
         $this->assertEqual($blocks[$block->module][$block->delta], $block, t('Block %name matched', array('%name' => $block->module . '-' . $block->delta)));
     }
 }
 /**
  * Test non-default theme admin.
  */
 function testNonDefaultBlockAdmin()
 {
     $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes'));
     $this->drupalLogin($admin_user);
     theme_enable(array('stark'));
     $this->drupalGet('admin/structure/block/list/stark');
 }
Пример #4
0
 /**
  * Test creating custom block, moving it to a specific region and then
  * deleting it.
  */
 function testCustomBlock()
 {
     // Confirm that the add block link appears on block overview pages.
     $this->drupalGet('admin/structure/block');
     $this->assertRaw(l(t('Add block'), 'admin/structure/block/add'), t('Add block link is present on block overview page for default theme.'));
     $this->drupalGet('admin/structure/block/list/seven');
     $this->assertRaw(l(t('Add block'), 'admin/structure/block/list/seven/add'), t('Add block link is present on block overview page for non-default theme.'));
     // Confirm that hidden regions are not shown as options for block placement
     // when adding a new block.
     theme_enable(array('stark'));
     $themes = list_themes();
     $this->drupalGet('admin/structure/block/add');
     foreach ($themes as $key => $theme) {
         if ($theme->status) {
             foreach ($theme->info['regions_hidden'] as $hidden_region) {
                 $elements = $this->xpath('//select[@id=:id]//option[@value=:value]', array(':id' => 'edit-regions-' . $key, ':value' => $hidden_region));
                 $this->assertFalse(isset($elements[0]), t('The hidden region @region is not available for @theme.', array('@region' => $hidden_region, '@theme' => $key)));
             }
         }
     }
     // Add a new custom block by filling out the input form on the
     // admin/structure/block/add page.
     $custom_block = array();
     $custom_block['info'] = $this->randomName(8);
     $custom_block['title'] = $this->randomName(8);
     $custom_block['body[value]'] = $this->randomName(32);
     $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
     // Confirm that the custom block has been created, and then query the
     // created bid.
     $this->assertText(t('The block has been created.'), t('Custom block successfully created.'));
     $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
     // Check to see if the custom block was created by checking that it's in
     // the database..
     $this->assertNotNull($bid, t('Custom block found in database'));
     // Check if the block can be moved to all available regions.
     $custom_block['module'] = 'block';
     $custom_block['delta'] = $bid;
     foreach ($this->regions as $region) {
         $this->moveBlockToRegion($custom_block, $region);
     }
     // Verify presence of configure and delete links for custom block.
     $this->drupalGet('admin/structure/block');
     $this->assertRaw(l(t('configure'), 'admin/structure/block/manage/block/' . $bid . '/configure'), t('Custom block configure link found.'));
     $this->assertRaw(l(t('delete'), 'admin/structure/block/manage/block/' . $bid . '/delete'), t('Custom block delete link found.'));
     // Set visibility only for authenticated users, to verify delete
     // functionality.
     $edit = array();
     $edit['roles[2]'] = TRUE;
     $this->drupalPost('admin/structure/block/manage/block/' . $bid . '/configure', $edit, t('Save block'));
     // Delete the created custom block & verify that it's been deleted and no
     // longer appearing on the page.
     $this->clickLink(t('delete'));
     $this->drupalPost('admin/structure/block/manage/block/' . $bid . '/delete', array(), t('Delete'));
     $this->assertRaw(t('The block %title has been removed.', array('%title' => $custom_block['info'])), t('Custom block successfully deleted.'));
     $this->assertNoText(t($custom_block['title']), t('Custom block no longer appears on page.'));
     $count = db_query("SELECT 1 FROM {block_role} WHERE module = :module AND delta = :delta", array(':module' => $custom_block['module'], ':delta' => $custom_block['delta']))->fetchField();
     $this->assertFalse($count, t('Table block_role being cleaned.'));
 }
 /**
  * Test non-default theme admin.
  */
 function testNonDefaultBlockAdmin()
 {
     $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes'));
     $this->drupalLogin($admin_user);
     $new_theme = 'bartik';
     theme_enable(array($new_theme));
     $this->drupalGet('admin/structure/block/list/' . $new_theme);
     $this->assertText('Bartik(' . t('active tab') . ')', 'Tab for non-default theme found.');
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 function setUp()
 {
     parent::setUp();
     // Create user.
     $this->big_user = $this->drupalCreateUser(array('administer themes'));
     // This tests the color module in Bartik.
     $this->themes = array('bartik' => array('palette_input' => 'palette[bg]', 'scheme' => 'slate', 'scheme_color' => '#3b3b3b'), 'color_test_theme' => array('palette_input' => 'palette[bg]', 'scheme' => '', 'scheme_color' => '#3b3b3b'));
     theme_enable(array_keys($this->themes));
     // Array filled with valid and not valid color values.
     $this->colorTests = array('#000' => TRUE, '#123456' => TRUE, '#abcdef' => TRUE, '#0' => FALSE, '#00' => FALSE, '#0000' => FALSE, '#00000' => FALSE, '123456' => FALSE, '#00000g' => FALSE);
 }
Пример #7
0
 /**
  * Set admin theme given its machine name.
  *
  * @param string $name
  *    Theme machine name.
  *
  * @return bool
  *    TRUE if theme is found and enabled, FALSE otherwise.
  */
 public function setAdminTheme($name)
 {
     $themes = list_themes(TRUE);
     if (isset($themes[$name])) {
         theme_enable(array($name));
         variable_set('admin_theme', $name);
         return TRUE;
     } else {
         return FALSE;
     }
 }
Пример #8
0
 function setUp()
 {
     parent::setUp();
     // Make sure we are using distinct default and administrative themes for
     // the duration of these tests.
     theme_enable(array('bartik', 'seven'));
     \Drupal::config('system.theme')->set('default', 'bartik')->set('admin', 'seven')->save();
     // Create and log in as a user who has permission to add and edit taxonomy
     // terms and view the administrative theme.
     $admin_user = $this->drupalCreateUser(array('administer taxonomy', 'view the administration theme'));
     $this->drupalLogin($admin_user);
 }
Пример #9
0
 /**
  * Check for the accessibility of the admin theme on the  block admin page.
  */
 function testAdminTheme()
 {
     // Create administrative user.
     $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes'));
     $this->drupalLogin($admin_user);
     // Ensure that access to block admin page is denied when theme is disabled.
     $this->drupalGet('admin/structure/block/list/bartik');
     $this->assertResponse(403);
     // Enable admin theme and confirm that tab is accessible.
     theme_enable(array('bartik'));
     $edit['admin_theme'] = 'bartik';
     $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
     $this->drupalGet('admin/structure/block/list/bartik');
     $this->assertResponse(200);
 }
Пример #10
0
 /**
  * Tests comment links.
  *
  * The output of comment links depends on various environment conditions:
  * - Various Comment module configuration settings, user registration
  *   settings, and user access permissions.
  * - Whether the user is authenticated or not, and whether any comments exist.
  *
  * To account for all possible cases, this test creates permutations of all
  * possible conditions and tests the expected appearance of comment links in
  * each environment.
  */
 function testCommentLinks()
 {
     // Bartik theme alters comment links, so use a different theme.
     theme_enable(array('stark'));
     \Drupal::config('system.theme')->set('default', 'stark')->save();
     // Remove additional user permissions from $this->web_user added by setUp(),
     // since this test is limited to anonymous and authenticated roles only.
     $roles = $this->web_user->getRoles();
     entity_delete_multiple('user_role', array(reset($roles)));
     // Matrix of possible environmental conditions and configuration settings.
     // See setEnvironment() for details.
     $conditions = array('authenticated' => array(FALSE, TRUE), 'comment count' => array(FALSE, TRUE), 'access comments' => array(0, 1), 'post comments' => array(0, 1), 'form' => array(COMMENT_FORM_BELOW, COMMENT_FORM_SEPARATE_PAGE), 'user_register' => array(USER_REGISTER_VISITORS, USER_REGISTER_ADMINISTRATORS_ONLY));
     $environments = $this->generatePermutations($conditions);
     foreach ($environments as $info) {
         $this->assertCommentLinks($info);
     }
 }
Пример #11
0
 /**
  * Tests debug markup added to Twig template output.
  */
 function testTwigDebugMarkup()
 {
     $extension = twig_extension();
     theme_enable(array('test_theme'));
     \Drupal::config('system.theme')->set('default', 'test_theme')->save();
     // Enable debug, rebuild the service container, and clear all caches.
     $this->settingsSet('twig_debug', TRUE);
     $this->rebuildContainer();
     $this->resetAll();
     $cache = $this->container->get('theme.registry')->get();
     // Create array of Twig templates.
     $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme'));
     $templates += drupal_find_theme_templates($cache, $extension, drupal_get_path('module', 'node'));
     // Create a node and test different features of the debug markup.
     $node = $this->drupalCreateNode();
     $build = node_view($node);
     $output = drupal_render($build);
     $this->assertTrue(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup found in theme output when debug is enabled.');
     $this->assertTrue(strpos($output, "CALL: _theme('node')") !== FALSE, 'Theme call information found.');
     $this->assertTrue(strpos($output, '* node--1--full' . $extension . PHP_EOL . '   x node--1' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   * node' . $extension) !== FALSE, '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->assertTrue(strpos($output, "BEGIN OUTPUT from '{$template_filename}'") !== FALSE, '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();
     $build = node_view($node2);
     $output = drupal_render($build);
     $this->assertTrue(strpos($output, '* node--2--full' . $extension . PHP_EOL . '   * node--2' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   x node' . $extension) !== FALSE, '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--full' . $extension . PHP_EOL . '   * node--3' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.');
     // Disable debug, rebuild the service container, and clear all caches.
     $this->settingsSet('twig_debug', FALSE);
     $this->rebuildContainer();
     $this->resetAll();
     $build = node_view($node);
     $output = drupal_render($build);
     $this->assertFalse(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup not found in theme output when debug is disabled.');
 }
Пример #12
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Setup test_theme.
     theme_enable(array('test_theme'));
     \Drupal::config('system.theme')->set('default', 'test_theme')->save();
     // Create and log in as admin.
     $this->admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer site configuration', 'translate interface'));
     $this->drupalLogin($this->admin_user);
     // Install languages.
     $this->installLanguages();
     // Assign Lolspeak (xx) to be the default language.
     $language = \Drupal::languageManager()->getLanguage('xx');
     $language->default = TRUE;
     language_save($language);
     $this->rebuildContainer();
     // Check that lolspeak is the default language for the site.
     $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, 'xx', 'Lolspeak is the default language');
 }
Пример #13
0
 /**
  * Tests that hidden regions do not inherit blocks when a theme is enabled.
  */
 public function testBlockNotInHiddenRegion()
 {
     // Ensure that the search form block is displayed.
     $this->drupalGet('');
     $this->assertText('Search', 'Block was displayed on the front page.');
     // Enable "block_test_theme" and set it as the default theme.
     $theme = 'block_test_theme';
     theme_enable(array($theme));
     \Drupal::config('system.theme')->set('default', $theme)->save();
     // Enabling a theme will cause the kernel terminate event to rebuild the
     // router. Simulate that here.
     \Drupal::service('router.builder')->rebuildIfNeeded();
     // Ensure that "block_test_theme" is set as the default theme.
     $this->drupalGet('admin/structure/block');
     $this->assertText('Block test theme(' . t('active tab') . ')', 'Default local task on blocks admin page is the block test theme.');
     // Ensure that the search form block is displayed.
     $this->drupalGet('');
     $this->assertText('Search', 'Block was displayed on the front page.');
 }
Пример #14
0
 /**
  * Tests stylesheets-override and stylesheets-remove.
  */
 function testStylesheets()
 {
     theme_enable(array('test_basetheme', 'test_subtheme'));
     \Drupal::config('system.theme')->set('default', 'test_subtheme')->save();
     $base = drupal_get_path('theme', 'test_basetheme');
     // Unlike test_basetheme (and the original module CSS), the subtheme decides
     // to put all of its CSS into a ./css subdirectory. All overrides and
     // removals are expected to be based on a file's basename and should work
     // nevertheless.
     $sub = drupal_get_path('theme', 'test_subtheme') . '/css';
     $this->drupalGet('theme-test/info/stylesheets');
     $this->assertIdentical(1, count($this->xpath("//link[contains(@href, '{$base}/base-add.css')]")), "{$base}/base-add.css found");
     $this->assertIdentical(1, count($this->xpath("//link[contains(@href, '{$base}/base-override.css')]")), "{$base}/base-override.css found");
     $this->assertIdentical(0, count($this->xpath("//link[contains(@href, 'base-remove.css')]")), "base-remove.css not found");
     $this->assertIdentical(1, count($this->xpath("//link[contains(@href, '{$sub}/sub-add.css')]")), "{$sub}/sub-add.css found");
     $this->assertIdentical(1, count($this->xpath("//link[contains(@href, '{$sub}/sub-override.css')]")), "{$sub}/sub-override.css found");
     $this->assertIdentical(1, count($this->xpath("//link[contains(@href, '{$sub}/base-add.sub-override.css')]")), "{$sub}/base-add.sub-override.css found");
     $this->assertIdentical(1, count($this->xpath("//link[contains(@href, '{$sub}/base-remove.sub-override.css')]")), "{$sub}/base-remove.sub-override.css found");
     $this->assertIdentical(0, count($this->xpath("//link[contains(@href, 'sub-remove.css')]")), "sub-remove.css not found");
     $this->assertIdentical(0, count($this->xpath("//link[contains(@href, 'base-add.sub-remove.css')]")), "base-add.sub-remove.css not found");
     $this->assertIdentical(0, count($this->xpath("//link[contains(@href, 'base-override.sub-remove.css')]")), "base-override.sub-remove.css not found");
 }
Пример #15
0
 function setUp()
 {
     parent::setUp();
     // Enable all available non-testing themes.
     $listing = new ExtensionDiscovery();
     $this->themes = $listing->scan('theme', FALSE);
     theme_enable(array_keys($this->themes));
     // Create a test user.
     $this->user = $this->drupalCreateUser(array('access content', 'access user profiles'));
     $this->user->name = $this->xss_label;
     $this->user->save();
     $this->drupalLogin($this->user);
     // Create a test term.
     $this->term = entity_create('taxonomy_term', array('name' => $this->xss_label, 'vid' => 1));
     $this->term->save();
     // Add a comment field.
     $this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment', CommentItemInterface::OPEN);
     // Create a test node tagged with the test term.
     $this->node = $this->drupalCreateNode(array('title' => $this->xss_label, 'type' => 'article', 'promote' => NODE_PROMOTED, 'field_tags' => array(array('target_id' => $this->term->id()))));
     // Create a test comment on the test node.
     $this->comment = entity_create('comment', array('entity_id' => $this->node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'status' => CommentInterface::PUBLISHED, 'subject' => $this->xss_label, 'comment_body' => array($this->randomName())));
     $this->comment->save();
 }
 function setUp()
 {
     parent::setUp();
     theme_enable(array('test_theme'));
 }
Пример #17
0
 public function setUp()
 {
     parent::setUp();
     theme_enable(array('breakpoint_test_theme'));
 }
Пример #18
0
 /**
  * Tests that overridden CSS files are not added during lazy load.
  */
 public function testLazyLoadOverriddenCSS()
 {
     // The test theme overrides system.module.css without an implementation,
     // thereby removing it.
     theme_enable(array('test_theme'));
     \Drupal::config('system.theme')->set('default', 'test_theme')->save();
     // This gets the form, and emulates an Ajax submission on it, including
     // adding markup to the HEAD and BODY for any lazy loaded JS/CSS files.
     $this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', array('add_files' => TRUE), array('op' => t('Submit')));
     // Verify that the resulting HTML does not load the overridden CSS file.
     // We add a "?" to the assertion, because drupalSettings may include
     // information about the file; we only really care about whether it appears
     // in a LINK or STYLE tag, for which Drupal always adds a query string for
     // cache control.
     $this->assertNoText('system.module.css?', 'Ajax lazy loading does not add overridden CSS files.');
 }
Пример #19
0
 /**
  * Test block display of theme titles.
  */
 function testThemeName()
 {
     // Enable the help block.
     $this->drupalPlaceBlock('system_help_block', array('region' => 'help'));
     // Explicitly set the default and admin themes.
     $theme = 'block_test_specialchars_theme';
     theme_enable(array($theme));
     \Drupal::service('router.builder')->rebuild();
     $this->drupalGet('admin/structure/block');
     $this->assertRaw(String::checkPlain('<"Cat" & \'Mouse\'>'));
     $this->drupalGet('admin/structure/block/list/block_test_specialchars_theme');
     $this->assertRaw(String::checkPlain('Demonstrate block regions (<"Cat" & \'Mouse\'>)'));
 }
Пример #20
0
 /**
  * Tests updates with a hidden base theme.
  */
 function testUpdateHiddenBaseTheme()
 {
     module_load_include('compare.inc', 'update');
     // Enable the subtheme.
     theme_enable(array('update_test_subtheme'));
     // Add a project and initial state for base theme and subtheme.
     $system_info = array('update_test_basetheme' => array('project' => 'update_test_basetheme', 'hidden' => TRUE), 'update_test_subtheme' => array('project' => 'update_test_subtheme', 'hidden' => FALSE));
     \Drupal::config('update_test.settings')->set('system_info', $system_info)->save();
     $projects = update_get_projects();
     $theme_data = system_rebuild_theme_data();
     $project_info = new ProjectInfo();
     $project_info->processInfoList($projects, $theme_data, 'theme', TRUE);
     $this->assertTrue(!empty($projects['update_test_basetheme']), 'Valid base theme (update_test_basetheme) was found.');
 }
Пример #21
0
<?php

$enable = array('theme_default' => 'bartik', 'admin_theme' => 'seven');
theme_enable($enable);
foreach ($enable as $var => $theme) {
    if (!is_numeric($var)) {
        variable_set($var, $theme);
        if ($theme == 'omega') {
            $settings = variable_get('theme_' . $theme . '_settings');
            // Configure settings for conceptual theme.
            variable_set('theme_' . $theme . '_settings', $settings);
            // Disable default blocks.
            db_update('block')->fields(array('status' => 0))->condition('theme', $theme)->condition('delta', 'main', '!=')->execute();
        }
    }
}
// Disable the default Bartik.
// theme_disable(array('bartik'));
Пример #22
0
 /**
  * Tests that the add shortcut link is not displayed for 404/403 errors.
  *
  * Tests that the "Add to shortcuts" link is not displayed on a page not
  * found or a page the user does not have access to.
  */
 public function testNoShortcutLink()
 {
     // Change to a theme that displays shortcuts.
     theme_enable(array('seven'));
     \Drupal::config('system.theme')->set('default', 'seven')->save();
     $this->drupalGet('page-that-does-not-exist');
     $result = $this->xpath('//div[contains(@class, "add-shortcut")]');
     $this->assertTrue(empty($result), 'Add to shortcuts link was not shown on a page not found.');
     // The user does not have access to this path.
     $this->drupalGet('admin/modules');
     $result = $this->xpath('//div[contains(@class, "add-shortcut")]');
     $this->assertTrue(empty($result), 'Add to shortcuts link was not shown on a page the user does not have access to.');
     // Verify that the testing mechanism works by verifying the shortcut
     // link appears on admin/people.
     $this->drupalGet('admin/people');
     $result = $this->xpath('//div[contains(@class, "remove-shortcut")]');
     $this->assertTrue(!empty($result), 'Remove from shortcuts link was shown on a page the user does have access to.');
     // Verify that the shortcut link appears on routing only pages.
     $this->drupalGet('router_test/test2');
     $result = $this->xpath('//div[contains(@class, "add-shortcut")]');
     $this->assertTrue(!empty($result), 'Add to shortcuts link was shown on a page the user does have access to.');
 }
Пример #23
0
 /**
  * Test switching the default theme.
  */
 function testSwitchDefaultTheme()
 {
     // Enable Bartik and set it as the default theme.
     theme_enable(array('bartik'));
     $this->drupalGet('admin/appearance');
     $this->clickLink(t('Set as default'));
     $this->assertEqual(\Drupal::config('system.theme')->get('default'), 'bartik');
     drupal_flush_all_caches();
     // Test the default theme on the secondary links (blocks admin page).
     $this->drupalGet('admin/structure/block');
     $this->assertText('Bartik(' . t('active tab') . ')', 'Default local task on blocks admin page is the default theme.');
     // Switch back to Stark and test again to test that the menu cache is cleared.
     $this->drupalGet('admin/appearance');
     $this->clickLink(t('Set as default'), 0);
     $this->drupalGet('admin/structure/block');
     $this->assertText('Stark(' . t('active tab') . ')', 'Default local task on blocks admin page has changed.');
 }
Пример #24
0
 /**
  * Tests that redirects work as expected when multiple block types exist.
  */
 public function testsBlockContentAddTypes()
 {
     $this->drupalLogin($this->adminUser);
     // Create two block types programmatically.
     $type = $this->createBlockContentType('foo');
     $type = $this->createBlockContentType('bar');
     // Get the custom block storage.
     $storage = $this->container->get('entity.manager')->getStorage('block_content');
     // Enable all themes.
     theme_enable(array('bartik', 'seven'));
     $themes = array('bartik', 'seven', 'stark');
     $theme_settings = $this->container->get('config.factory')->get('system.theme');
     foreach ($themes as $default_theme) {
         // Change the default theme.
         $theme_settings->set('default', $default_theme)->save();
         \Drupal::service('router.builder')->rebuild();
         // For each enabled theme, go to its block page and test the redirects.
         $themes = array('bartik', 'stark', 'seven');
         foreach ($themes as $theme) {
             // Test that adding a block from the 'place blocks' form sends you to the
             // block configure form.
             $path = $theme == $default_theme ? 'admin/structure/block' : "admin/structure/block/list/{$theme}";
             $this->drupalGet($path);
             $this->clickLink(t('Add custom block'));
             // The seven theme has markup inside the link, we cannot use clickLink().
             if ($default_theme == 'seven') {
                 $options = $theme != $default_theme ? array('query' => array('theme' => $theme)) : array();
                 $this->assertLinkByHref(url('block/add/foo', $options));
                 $this->drupalGet('block/add/foo', $options);
             } else {
                 $this->clickLink('foo');
             }
             // Create a new block.
             $edit = array('info[0][value]' => $this->randomMachineName(8));
             $this->drupalPostForm(NULL, $edit, t('Save'));
             $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]']));
             if (!empty($blocks)) {
                 $block = reset($blocks);
                 $destination = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $theme;
                 $this->assertUrl(url($destination, array('absolute' => TRUE)));
                 $this->drupalPostForm(NULL, array(), t('Save block'));
                 $this->assertUrl(url("admin/structure/block/list/{$theme}", array('absolute' => TRUE, 'query' => array('block-placement' => drupal_html_class($edit['info[0][value]'])))));
             } else {
                 $this->fail('Could not load created block.');
             }
         }
     }
     // Test that adding a block from the 'custom blocks list' doesn't send you
     // to the block configure form.
     $this->drupalGet('admin/structure/block/block-content');
     $this->clickLink(t('Add custom block'));
     $this->clickLink('foo');
     $edit = array('info[0][value]' => $this->randomMachineName(8));
     $this->drupalPostForm(NULL, $edit, t('Save'));
     $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]']));
     if (!empty($blocks)) {
         $destination = 'admin/structure/block/block-content';
         $this->assertUrl(url($destination, array('absolute' => TRUE)));
     } else {
         $this->fail('Could not load created block.');
     }
 }