Issue #1872540 by xjm: Provide a test helper method for creating block instances.
parent
1691c94d06
commit
b11bacd8f1
|
@ -38,6 +38,10 @@ class AggregatorRenderingTest extends AggregatorTestBase {
|
||||||
$feed = $this->createFeed();
|
$feed = $this->createFeed();
|
||||||
$this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
|
$this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
|
||||||
|
|
||||||
|
// Clear the block cache to load the new block definitions.
|
||||||
|
$manager = $this->container->get('plugin.manager.block');
|
||||||
|
$manager->clearCachedDefinitions();
|
||||||
|
|
||||||
// Need admin user to be able to access block admin.
|
// Need admin user to be able to access block admin.
|
||||||
$admin_user = $this->drupalCreateUser(array(
|
$admin_user = $this->drupalCreateUser(array(
|
||||||
'administer blocks',
|
'administer blocks',
|
||||||
|
@ -47,16 +51,11 @@ class AggregatorRenderingTest extends AggregatorTestBase {
|
||||||
));
|
));
|
||||||
$this->drupalLogin($admin_user);
|
$this->drupalLogin($admin_user);
|
||||||
|
|
||||||
$current_theme = variable_get('theme_default', 'stark');
|
|
||||||
$machine_name = 'test_aggregator_feed_block';
|
|
||||||
$block = array(
|
$block = array(
|
||||||
'machine_name' => $machine_name,
|
|
||||||
'region' => 'footer',
|
|
||||||
'title' => 'feed-' . $feed->title,
|
'title' => 'feed-' . $feed->title,
|
||||||
'block_count' => 2,
|
'block_count' => 2,
|
||||||
);
|
);
|
||||||
$this->drupalPost("admin/structure/block/manage/aggregator_feed_block:{$feed->fid}/$current_theme", $block, t('Save block'));
|
$this->drupalPlaceBlock("aggregator_feed_block:{$feed->fid}", $block);
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Block was saved.');
|
|
||||||
|
|
||||||
// Confirm that the block is now being displayed on pages.
|
// Confirm that the block is now being displayed on pages.
|
||||||
$this->drupalGet('node');
|
$this->drupalGet('node');
|
||||||
|
|
|
@ -49,15 +49,7 @@ class ImportOpmlTest extends AggregatorTestBase {
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
// Enable the help block.
|
// Enable the help block.
|
||||||
$block_id = 'system_help_block';
|
$this->drupalPlaceBlock('system_help_block', array('region' => 'help'));
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'help',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), '"Help" block enabled');
|
|
||||||
|
|
||||||
$this->drupalGet('admin/config/services/aggregator/add/opml');
|
$this->drupalGet('admin/config/services/aggregator/add/opml');
|
||||||
$this->assertText('A single OPML document may contain a collection of many feeds.', 'Found OPML help text.');
|
$this->assertText('A single OPML document may contain a collection of many feeds.', 'Found OPML help text.');
|
||||||
|
|
|
@ -49,12 +49,8 @@ class BlockCacheTest extends WebTestBase {
|
||||||
$this->normal_user_alt->save();
|
$this->normal_user_alt->save();
|
||||||
|
|
||||||
// Enable our test block.
|
// Enable our test block.
|
||||||
$this->theme = variable_get('theme_default', 'stark');
|
$block = $this->drupalPlaceBlock('test_cache');
|
||||||
$block = array();
|
$this->block_config_id = $block['config_id'];
|
||||||
$block['machine_name'] = $this->randomName(8);
|
|
||||||
$block['region'] = 'sidebar_first';
|
|
||||||
$this->block = $block;
|
|
||||||
$this->drupalPost('admin/structure/block/manage/test_cache/' . $this->theme, $block, t('Save block'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,13 +192,11 @@ class BlockCacheTest extends WebTestBase {
|
||||||
* Private helper method to set the test block's cache mode.
|
* Private helper method to set the test block's cache mode.
|
||||||
*/
|
*/
|
||||||
private function setCacheMode($cache_mode) {
|
private function setCacheMode($cache_mode) {
|
||||||
$block = $this->block;
|
$block_config = config($this->block_config_id);
|
||||||
$block['config_id'] = 'plugin.core.block.' . $this->theme . '.' . $block['machine_name'];
|
|
||||||
$block_config = config($block['config_id']);
|
|
||||||
$block_config->set('cache', $cache_mode);
|
$block_config->set('cache', $cache_mode);
|
||||||
$block_config->save();
|
$block_config->save();
|
||||||
|
|
||||||
$instance = block_load($block['config_id']);
|
$instance = block_load($this->block_config_id);
|
||||||
$config = $instance->getConfig();
|
$config = $instance->getConfig();
|
||||||
if ($config['cache'] != $cache_mode) {
|
if ($config['cache'] != $cache_mode) {
|
||||||
$this->fail(t('Unable to set cache mode to %mode. Current mode: %current_mode', array('%mode' => $cache_mode, '%current_mode' => $config['cache'])));
|
$this->fail(t('Unable to set cache mode to %mode. Current mode: %current_mode', array('%mode' => $cache_mode, '%current_mode' => $config['cache'])));
|
||||||
|
|
|
@ -46,14 +46,7 @@ class BlockHiddenRegionTest extends WebTestBase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->drupalLogin($this->adminUser);
|
$this->drupalLogin($this->adminUser);
|
||||||
|
$this->drupalPlaceBlock('search_form_block');
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
|
|
||||||
$block['machine_name'] = $this->randomName();
|
|
||||||
$block['region'] = 'sidebar_first';
|
|
||||||
$block['title'] = $this->randomName();
|
|
||||||
$this->drupalPost('admin/structure/block/manage/search_form_block/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText('The block configuration has been saved.', 'Block was saved');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,8 +54,6 @@ class BlockHiddenRegionTest extends WebTestBase {
|
||||||
*/
|
*/
|
||||||
public function testBlockNotInHiddenRegion() {
|
public function testBlockNotInHiddenRegion() {
|
||||||
|
|
||||||
$this->drupalLogin($this->adminUser);
|
|
||||||
|
|
||||||
// Ensure that the search form block is displayed.
|
// Ensure that the search form block is displayed.
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertText('Search', 'Block was displayed on the front page.');
|
$this->assertText('Search', 'Block was displayed on the front page.');
|
||||||
|
@ -81,4 +72,5 @@ class BlockHiddenRegionTest extends WebTestBase {
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertText('Search', 'Block was displayed on the front page.');
|
$this->assertText('Search', 'Block was displayed on the front page.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\block\Tests;
|
||||||
use Drupal\simpletest\WebTestBase;
|
use Drupal\simpletest\WebTestBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test block HTML id validity.
|
* Tests block HTML ID validity.
|
||||||
*/
|
*/
|
||||||
class BlockHtmlIdTest extends WebTestBase {
|
class BlockHtmlIdTest extends WebTestBase {
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ class BlockHtmlIdTest extends WebTestBase {
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
'name' => 'Block HTML id',
|
'name' => 'Block HTML ID',
|
||||||
'description' => 'Test block HTML id validity.',
|
'description' => 'Tests block HTML ID validity.',
|
||||||
'group' => 'Block',
|
'group' => 'Block',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,7 @@ class BlockHtmlIdTest extends WebTestBase {
|
||||||
state()->set('block_test.content', $current_content);
|
state()->set('block_test.content', $current_content);
|
||||||
|
|
||||||
// Enable our test block.
|
// Enable our test block.
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$this->drupalPlaceBlock('test_html_id', array('machine_name' => 'test_id_block'));
|
||||||
$block = array();
|
|
||||||
$block['machine_name'] = 'test_id_block';
|
|
||||||
$block['region'] = 'sidebar_first';
|
|
||||||
$this->drupalPost('admin/structure/block/manage/test_html_id' . '/' . $default_theme, array('machine_name' => $block['machine_name'], 'region' => $block['region']), t('Save block'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,4 +56,5 @@ class BlockHtmlIdTest extends WebTestBase {
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertRaw('id="block-test-id-block"', 'HTML ID for test block is valid.');
|
$this->assertRaw('id="block-test-id-block"', 'HTML ID for test block is valid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,18 +44,9 @@ class BlockInvalidRegionTest extends WebTestBase {
|
||||||
* Tests that blocks assigned to invalid regions work correctly.
|
* Tests that blocks assigned to invalid regions work correctly.
|
||||||
*/
|
*/
|
||||||
function testBlockInInvalidRegion() {
|
function testBlockInInvalidRegion() {
|
||||||
// Enable a test block in the default theme and place it in an invalid region.
|
// Enable a test block and place it in an invalid region.
|
||||||
$current_theme = variable_get('default_theme', 'stark');
|
$block = $this->drupalPlaceBlock('test_html_id');
|
||||||
$machine_name = 'test_html_id';
|
$config = config($block['config_id']);
|
||||||
$block = array(
|
|
||||||
'machine_name' => $machine_name,
|
|
||||||
'region' => 'footer',
|
|
||||||
);
|
|
||||||
$this->drupalPost("admin/structure/block/manage/test_html_id/$current_theme", $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Block was saved.');
|
|
||||||
|
|
||||||
$machine_name = 'plugin.core.block.' . $current_theme . '.' . $machine_name;
|
|
||||||
$config = config($machine_name);
|
|
||||||
$config->set('region', 'invalid_region');
|
$config->set('region', 'invalid_region');
|
||||||
$config->save();
|
$config->save();
|
||||||
|
|
||||||
|
@ -70,7 +61,6 @@ class BlockInvalidRegionTest extends WebTestBase {
|
||||||
$this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
|
$this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
|
||||||
|
|
||||||
// Place disabled test block in the invalid region of the default theme.
|
// Place disabled test block in the invalid region of the default theme.
|
||||||
$config = config($machine_name);
|
|
||||||
$config->set('region', 'invalid_region');
|
$config->set('region', 'invalid_region');
|
||||||
$config->save();
|
$config->save();
|
||||||
|
|
||||||
|
|
|
@ -33,38 +33,18 @@ class NewDefaultThemeBlocksTest extends WebTestBase {
|
||||||
* Check the enabled Bartik blocks are correctly copied over.
|
* Check the enabled Bartik blocks are correctly copied over.
|
||||||
*/
|
*/
|
||||||
function testNewDefaultThemeBlocks() {
|
function testNewDefaultThemeBlocks() {
|
||||||
|
$default_theme = variable_get('theme_default', 'stark');
|
||||||
|
|
||||||
// Add several block instances.
|
// Add several block instances.
|
||||||
// @todo Do this programmatically and with test blocks instead of other
|
|
||||||
// modules' blocks once block instances are config entities.
|
|
||||||
$this->adminUser = $this->drupalCreateUser(array('administer blocks'));
|
$this->adminUser = $this->drupalCreateUser(array('administer blocks'));
|
||||||
$this->drupalLogin($this->adminUser);
|
$this->drupalLogin($this->adminUser);
|
||||||
|
|
||||||
// Add one instance of the user login block.
|
// Add two instances of the user login block.
|
||||||
$block_id = 'user_login_block';
|
$this->drupalPlaceBlock('user_login_block');
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$this->drupalPlaceBlock('user_login_block');
|
||||||
$edit = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $edit, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'User login block enabled');
|
|
||||||
|
|
||||||
// Add another instance of the same block.
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $edit, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'User login block enabled');
|
|
||||||
|
|
||||||
// Add an instance of a different block.
|
// Add an instance of a different block.
|
||||||
$block_id = 'system_powered_by_block';
|
$this->drupalPlaceBlock('system_powered_by_block');
|
||||||
$edit = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $edit, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'User login block enabled');
|
|
||||||
|
|
||||||
$this->drupalLogout($this->adminUser);
|
$this->drupalLogout($this->adminUser);
|
||||||
|
|
||||||
// Enable a different theme.
|
// Enable a different theme.
|
||||||
|
|
|
@ -309,16 +309,8 @@ class BookTest extends WebTestBase {
|
||||||
function testBookNavigationBlock() {
|
function testBookNavigationBlock() {
|
||||||
$this->drupalLogin($this->admin_user);
|
$this->drupalLogin($this->admin_user);
|
||||||
|
|
||||||
$block_id = 'book_navigation';
|
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'footer',
|
|
||||||
);
|
|
||||||
// Enable the block.
|
// Enable the block.
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
$block = $this->drupalPlaceBlock('book_navigation');
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Block enabled');
|
|
||||||
|
|
||||||
// Give anonymous users the permission 'node test view'.
|
// Give anonymous users the permission 'node test view'.
|
||||||
$edit = array();
|
$edit = array();
|
||||||
|
@ -329,7 +321,7 @@ class BookTest extends WebTestBase {
|
||||||
// Test correct display of the block.
|
// Test correct display of the block.
|
||||||
$nodes = $this->createBook();
|
$nodes = $this->createBook();
|
||||||
$this->drupalGet('<front>');
|
$this->drupalGet('<front>');
|
||||||
$this->assertText($block['title'], 'Book navigation block is displayed.');
|
$this->assertText($block['subject'], 'Book navigation block is displayed.');
|
||||||
$this->assertText($this->book->label(), format_string('Link to book root (@title) is displayed.', array('@title' => $nodes[0]->label())));
|
$this->assertText($this->book->label(), format_string('Link to book root (@title) is displayed.', array('@title' => $nodes[0]->label())));
|
||||||
$this->assertNoText($nodes[0]->label(), 'No links to individual book pages are displayed.');
|
$this->assertNoText($nodes[0]->label(), 'No links to individual book pages are displayed.');
|
||||||
}
|
}
|
||||||
|
@ -339,17 +331,7 @@ class BookTest extends WebTestBase {
|
||||||
*/
|
*/
|
||||||
function testNavigationBlockOnAccessModuleEnabled() {
|
function testNavigationBlockOnAccessModuleEnabled() {
|
||||||
$this->drupalLogin($this->admin_user);
|
$this->drupalLogin($this->admin_user);
|
||||||
$block_id = 'book_navigation';
|
$block = $this->drupalPlaceBlock('book_navigation', array('book_block_mode' => 'book pages'));
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'footer',
|
|
||||||
'book_block_mode' => 'book pages',
|
|
||||||
);
|
|
||||||
// Enable the block.
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Block enabled');
|
|
||||||
|
|
||||||
// Give anonymous users the permission 'node test view'.
|
// Give anonymous users the permission 'node test view'.
|
||||||
$edit = array();
|
$edit = array();
|
||||||
|
@ -363,12 +345,12 @@ class BookTest extends WebTestBase {
|
||||||
// Test correct display of the block to registered users.
|
// Test correct display of the block to registered users.
|
||||||
$this->drupalLogin($this->web_user);
|
$this->drupalLogin($this->web_user);
|
||||||
$this->drupalGet('node/' . $this->book->nid);
|
$this->drupalGet('node/' . $this->book->nid);
|
||||||
$this->assertText($block['title'], 'Book navigation block is displayed to registered users.');
|
$this->assertText($block['subject'], 'Book navigation block is displayed to registered users.');
|
||||||
$this->drupalLogout();
|
$this->drupalLogout();
|
||||||
|
|
||||||
// Test correct display of the block to anonymous users.
|
// Test correct display of the block to anonymous users.
|
||||||
$this->drupalGet('node/' . $this->book->nid);
|
$this->drupalGet('node/' . $this->book->nid);
|
||||||
$this->assertText($block['title'], 'Book navigation block is displayed to anonymous users.');
|
$this->assertText($block['subject'], 'Book navigation block is displayed to anonymous users.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,16 +46,7 @@ class CommentBlockTest extends CommentTestBase {
|
||||||
*/
|
*/
|
||||||
function testRecentCommentBlock() {
|
function testRecentCommentBlock() {
|
||||||
$this->drupalLogin($this->admin_user);
|
$this->drupalLogin($this->admin_user);
|
||||||
$current_theme = variable_get('default_theme', 'stark');
|
$block = $this->drupalPlaceBlock('recent_comments', array('block_count' => 2));
|
||||||
$machine_name = 'test_recent_comments';
|
|
||||||
$edit = array(
|
|
||||||
'machine_name' => $machine_name,
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
'title' => $this->randomName(),
|
|
||||||
'block_count' => 2,
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/recent_comments/' . $current_theme, $edit, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Block was saved.');
|
|
||||||
|
|
||||||
// Add some test comments, one without a subject.
|
// Add some test comments, one without a subject.
|
||||||
$comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
|
$comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
|
||||||
|
@ -70,14 +61,14 @@ class CommentBlockTest extends CommentTestBase {
|
||||||
// posting a node from a node form.
|
// posting a node from a node form.
|
||||||
cache_invalidate_tags(array('content' => TRUE));
|
cache_invalidate_tags(array('content' => TRUE));
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertNoText($edit['title'], 'Block was not found.');
|
$this->assertNoText($block['subject'], 'Block was not found.');
|
||||||
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments'));
|
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments'));
|
||||||
|
|
||||||
// Test that a user with the 'access comments' permission can see the
|
// Test that a user with the 'access comments' permission can see the
|
||||||
// block.
|
// block.
|
||||||
$this->drupalLogin($this->web_user);
|
$this->drupalLogin($this->web_user);
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertText($edit['title'], 'Block was found.');
|
$this->assertText($block['subject'], 'Block was found.');
|
||||||
|
|
||||||
// Test the only the 2 latest comments are shown and in the proper order.
|
// Test the only the 2 latest comments are shown and in the proper order.
|
||||||
$this->assertNoText($comment1->subject, 'Comment not found in block.');
|
$this->assertNoText($comment1->subject, 'Comment not found in block.');
|
||||||
|
@ -88,11 +79,12 @@ class CommentBlockTest extends CommentTestBase {
|
||||||
// Set the number of recent comments to show to 10.
|
// Set the number of recent comments to show to 10.
|
||||||
$this->drupalLogout();
|
$this->drupalLogout();
|
||||||
$this->drupalLogin($this->admin_user);
|
$this->drupalLogin($this->admin_user);
|
||||||
$block = array(
|
$edit = array(
|
||||||
'block_count' => 10,
|
'block_count' => 10,
|
||||||
);
|
);
|
||||||
|
$current_theme = variable_get('theme_default', 'stark');
|
||||||
|
|
||||||
$this->drupalPost("admin/structure/block/manage/plugin.core.block.$current_theme.$machine_name/$current_theme/configure", $block, t('Save block'));
|
$this->drupalPost('admin/structure/block/manage/' . $block['config_id'] . '/' . variable_get('theme_default', 'stark') . '/configure', $edit, t('Save block'));
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Block saved.');
|
$this->assertText(t('The block configuration has been saved.'), 'Block saved.');
|
||||||
|
|
||||||
// Post an additional comment.
|
// Post an additional comment.
|
||||||
|
@ -118,4 +110,5 @@ class CommentBlockTest extends CommentTestBase {
|
||||||
// rel="canonical" is added to the head of the document.
|
// rel="canonical" is added to the head of the document.
|
||||||
$this->assertRaw('<link rel="canonical"', 'Canonical URL was found in the HTML head');
|
$this->assertRaw('<link rel="canonical"', 'Canonical URL was found in the HTML head');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,17 +57,8 @@ class ForumBlockTest extends WebTestBase {
|
||||||
// Create 5 forum topics.
|
// Create 5 forum topics.
|
||||||
$topics = $this->createForumTopics();
|
$topics = $this->createForumTopics();
|
||||||
|
|
||||||
$block_id = 'forum_new_block';
|
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_second',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Enable the new forum topics block.
|
// Enable the new forum topics block.
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
$block = $this->drupalPlaceBlock('forum_new_block');
|
||||||
$this->assertText(t('The block configuration has been saved.'), '"New forum topics" block was enabled');
|
$this->assertText(t('The block configuration has been saved.'), '"New forum topics" block was enabled');
|
||||||
|
|
||||||
$this->assertLink(t('More'), 0, 'New forum topics block has a "more"-link.');
|
$this->assertLink(t('More'), 0, 'New forum topics block has a "more"-link.');
|
||||||
|
@ -79,7 +70,6 @@ class ForumBlockTest extends WebTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the new forum topics block to only show 2 topics.
|
// Configure the new forum topics block to only show 2 topics.
|
||||||
$block['config_id'] = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name'];
|
|
||||||
$config = config($block['config_id']);
|
$config = config($block['config_id']);
|
||||||
$config->set('block_count', 2);
|
$config->set('block_count', 2);
|
||||||
$config->save();
|
$config->save();
|
||||||
|
@ -122,19 +112,7 @@ class ForumBlockTest extends WebTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable the block.
|
// Enable the block.
|
||||||
$block_id = 'forum_active_block';
|
$block = $this->drupalPlaceBlock('forum_active_block');
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_second',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Enable the active forum block.
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Active forum topics forum block was enabled');
|
|
||||||
|
|
||||||
$this->assertLink(t('More'), 0, 'Active forum topics block has a "more"-link.');
|
$this->assertLink(t('More'), 0, 'Active forum topics block has a "more"-link.');
|
||||||
$this->assertLinkByHref('forum', 0, 'Active forum topics block has a "more"-link.');
|
$this->assertLinkByHref('forum', 0, 'Active forum topics block has a "more"-link.');
|
||||||
|
|
||||||
|
@ -151,7 +129,6 @@ class ForumBlockTest extends WebTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the active forum block to only show 2 topics.
|
// Configure the active forum block to only show 2 topics.
|
||||||
$block['config_id'] = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name'];
|
|
||||||
$config = config($block['config_id']);
|
$config = config($block['config_id']);
|
||||||
$config->set('block_count', 2);
|
$config->set('block_count', 2);
|
||||||
$config->save();
|
$config->save();
|
||||||
|
|
|
@ -75,26 +75,10 @@ class ForumNodeAccessTest extends WebTestBase {
|
||||||
$public_node = $this->drupalGetNodeByTitle($public_node_title);
|
$public_node = $this->drupalGetNodeByTitle($public_node_title);
|
||||||
$this->assertTrue(!empty($public_node), 'New public forum node found in database.');
|
$this->assertTrue(!empty($public_node), 'New public forum node found in database.');
|
||||||
|
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
// Enable the active forum block.
|
|
||||||
$block_id = 'forum_active_block';
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_second',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Active forum topics block enabled');
|
|
||||||
|
|
||||||
// Enable the new forum block.
|
// Enable the new and active forum blocks.
|
||||||
$block_id = 'forum_new_block';
|
$this->drupalPlaceBlock('forum_active_block');
|
||||||
$block = array(
|
$this->drupalPlaceBlock('forum_new_block');
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_second',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'New forum topics block enabled');
|
|
||||||
|
|
||||||
// Test for $access_user.
|
// Test for $access_user.
|
||||||
$this->drupalLogin($access_user);
|
$this->drupalLogin($access_user);
|
||||||
|
@ -112,4 +96,5 @@ class ForumNodeAccessTest extends WebTestBase {
|
||||||
$this->assertNoText($private_node->title, 'Private node not found in block by $no_access_user');
|
$this->assertNoText($private_node->title, 'Private node not found in block by $no_access_user');
|
||||||
$this->assertText($public_node->title, 'Public node found in block by $no_access_user');
|
$this->assertText($public_node->title, 'Public node found in block by $no_access_user');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,16 +42,7 @@ class LanguageSwitchingTest extends WebTestBase {
|
||||||
*/
|
*/
|
||||||
function testLanguageBlock() {
|
function testLanguageBlock() {
|
||||||
// Enable the language switching block.
|
// Enable the language switching block.
|
||||||
$language_type = LANGUAGE_TYPE_INTERFACE;
|
$block = $this->drupalPlaceBlock('language_block:' . LANGUAGE_TYPE_INTERFACE, array('machine_name' => 'test_language_block'));
|
||||||
$block_id = 'language_block:' . $language_type;
|
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Block enabled');
|
|
||||||
|
|
||||||
// Add language.
|
// Add language.
|
||||||
$edit = array(
|
$edit = array(
|
||||||
|
@ -65,10 +56,10 @@ class LanguageSwitchingTest extends WebTestBase {
|
||||||
|
|
||||||
// Assert that the language switching block is displayed on the frontpage.
|
// Assert that the language switching block is displayed on the frontpage.
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertText($block['title'], 'Language switcher block found.');
|
$this->assertText($block['subject'], 'Language switcher block found.');
|
||||||
|
|
||||||
// Assert that only the current language is marked as active.
|
// Assert that only the current language is marked as active.
|
||||||
list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-' . strtolower($block['machine_name'])));
|
list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-test-language-block'));
|
||||||
$links = array(
|
$links = array(
|
||||||
'active' => array(),
|
'active' => array(),
|
||||||
'inactive' => array(),
|
'inactive' => array(),
|
||||||
|
@ -97,4 +88,5 @@ class LanguageSwitchingTest extends WebTestBase {
|
||||||
$this->assertIdentical($links, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language list item is marked as active on the language switcher block.');
|
$this->assertIdentical($links, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language list item is marked as active on the language switcher block.');
|
||||||
$this->assertIdentical($anchors, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language anchor is marked as active on the language switcher block.');
|
$this->assertIdentical($anchors, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language anchor is marked as active on the language switcher block.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,15 +402,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
|
||||||
$this->drupalGet('admin/config/regional/language/detection');
|
$this->drupalGet('admin/config/regional/language/detection');
|
||||||
|
|
||||||
// Enable the language switcher block.
|
// Enable the language switcher block.
|
||||||
$block_id = 'language_block:' . LANGUAGE_TYPE_INTERFACE;
|
$this->drupalPlaceBlock('language_block:' . LANGUAGE_TYPE_INTERFACE, array('machine_name' => 'test_language_block'));
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Block enabled');
|
|
||||||
|
|
||||||
// Access the front page without specifying any valid URL language prefix
|
// Access the front page without specifying any valid URL language prefix
|
||||||
// and having as browser language preference a non-default language.
|
// and having as browser language preference a non-default language.
|
||||||
|
@ -420,7 +412,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
|
||||||
|
|
||||||
// Check that the language switcher active link matches the given browser
|
// Check that the language switcher active link matches the given browser
|
||||||
// language.
|
// language.
|
||||||
$args = array(':id' => 'block-' . strtolower($block['machine_name']), ':url' => base_path() . $GLOBALS['script_path'] . $langcode_browser_fallback);
|
$args = array(':id' => 'block-test-language-block', ':url' => base_path() . $GLOBALS['script_path'] . $langcode_browser_fallback);
|
||||||
$fields = $this->xpath('//div[@id=:id]//a[@class="language-link active" and starts-with(@href, :url)]', $args);
|
$fields = $this->xpath('//div[@id=:id]//a[@class="language-link active" and starts-with(@href, :url)]', $args);
|
||||||
$this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, 'The browser language is the URL active language');
|
$this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, 'The browser language is the URL active language');
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class MenuTest extends WebTestBase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $modules = array('menu');
|
public static $modules = array('menu', 'block');
|
||||||
|
|
||||||
protected $profile = 'standard';
|
protected $profile = 'standard';
|
||||||
|
|
||||||
|
@ -138,7 +138,6 @@ class MenuTest extends WebTestBase {
|
||||||
* Add custom menu.
|
* Add custom menu.
|
||||||
*/
|
*/
|
||||||
function addCustomMenu() {
|
function addCustomMenu() {
|
||||||
// Add custom menu.
|
|
||||||
|
|
||||||
// Try adding a menu using a menu_name that is too long.
|
// Try adding a menu using a menu_name that is too long.
|
||||||
$this->drupalGet('admin/structure/menu/add');
|
$this->drupalGet('admin/structure/menu/add');
|
||||||
|
@ -176,16 +175,12 @@ class MenuTest extends WebTestBase {
|
||||||
|
|
||||||
// Enable the custom menu block.
|
// Enable the custom menu block.
|
||||||
$menu_name = 'menu-' . $menu_name; // Drupal prepends the name with 'menu-'.
|
$menu_name = 'menu-' . $menu_name; // Drupal prepends the name with 'menu-'.
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
// Confirm that the custom menu block is available.
|
||||||
$this->drupalGet("admin/structure/block/list/block_plugin_ui:{$default_theme}/add");
|
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add');
|
||||||
$this->assertText($title);
|
$this->assertText($title);
|
||||||
$block = array(
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost("admin/structure/block/manage/menu_menu_block:$menu_name/$default_theme", $block, t('Save block'));
|
|
||||||
$this->assertResponse(200);
|
|
||||||
|
|
||||||
|
// Enable the block.
|
||||||
|
$this->drupalPlaceBlock('menu_menu_block:' . $menu_name);
|
||||||
return menu_load($menu_name);
|
return menu_load($menu_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,22 +60,8 @@ class NodeBlockFunctionalTest extends NodeTestBase {
|
||||||
'access content' => FALSE,
|
'access content' => FALSE,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Enable the recent content block.
|
// Enable the recent content block with two items.
|
||||||
$block_id = 'node_recent_block';
|
$block = $this->drupalPlaceBlock('node_recent_block', array('machine_name' => 'test_block', 'block_count' => 2));
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Node enabled.');
|
|
||||||
|
|
||||||
// Set the number of recent posts to 2.
|
|
||||||
$block['config_id'] = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name'];
|
|
||||||
$config = config($block['config_id']);
|
|
||||||
$config->set('block_count', 2);
|
|
||||||
$config->save();
|
|
||||||
|
|
||||||
// Test that block is not visible without nodes.
|
// Test that block is not visible without nodes.
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
|
@ -105,7 +91,7 @@ class NodeBlockFunctionalTest extends NodeTestBase {
|
||||||
// see the block.
|
// see the block.
|
||||||
$this->drupalLogout();
|
$this->drupalLogout();
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertNoText($block['title'], 'Block was not found.');
|
$this->assertNoText($block['subject'], 'Block was not found.');
|
||||||
|
|
||||||
// Test that only the 2 latest nodes are shown.
|
// Test that only the 2 latest nodes are shown.
|
||||||
$this->drupalLogin($this->webUser);
|
$this->drupalLogin($this->webUser);
|
||||||
|
@ -114,7 +100,7 @@ class NodeBlockFunctionalTest extends NodeTestBase {
|
||||||
$this->assertText($node3->label(), 'Node found in block.');
|
$this->assertText($node3->label(), 'Node found in block.');
|
||||||
|
|
||||||
// Check to make sure nodes are in the right order.
|
// Check to make sure nodes are in the right order.
|
||||||
$this->assertTrue($this->xpath('//div[@id="block-' . strtolower($block['machine_name']) . '"]/div/table/tbody/tr[position() = 1]/td/div/a[text() = "' . $node3->label() . '"]'), 'Nodes were ordered correctly in block.');
|
$this->assertTrue($this->xpath('//div[@id="block-test-block"]/div/table/tbody/tr[position() = 1]/td/div/a[text() = "' . $node3->label() . '"]'), 'Nodes were ordered correctly in block.');
|
||||||
|
|
||||||
$this->drupalLogout();
|
$this->drupalLogout();
|
||||||
$this->drupalLogin($this->adminUser);
|
$this->drupalLogin($this->adminUser);
|
||||||
|
@ -137,21 +123,10 @@ class NodeBlockFunctionalTest extends NodeTestBase {
|
||||||
$this->assertText($node3->label(), 'Node found in block.');
|
$this->assertText($node3->label(), 'Node found in block.');
|
||||||
$this->assertText($node4->label(), 'Node found in block.');
|
$this->assertText($node4->label(), 'Node found in block.');
|
||||||
|
|
||||||
// Enable the "Powered by Drupal" block and test the visibility by node
|
// Enable the "Powered by Drupal" block only on article nodes.
|
||||||
// type functionality.
|
$block = $this->drupalPlaceBlock('system_powered_by_block', array(
|
||||||
$block_name = 'system_powered_by_block';
|
|
||||||
$block = array(
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'visibility[node_type][types][article]' => TRUE,
|
'visibility[node_type][types][article]' => TRUE,
|
||||||
);
|
));
|
||||||
// Set the block to be shown only on node/xx if node is an article.
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_name . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText('The block configuration has been saved.', 'Block was saved');
|
|
||||||
|
|
||||||
// Configure the new forum topics block to only show 2 topics.
|
|
||||||
$block['config_id'] = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name'];
|
|
||||||
$config = config($block['config_id']);
|
$config = config($block['config_id']);
|
||||||
$node_type_visibility = $config->get('visibility.node_type.types.article');
|
$node_type_visibility = $config->get('visibility.node_type.types.article');
|
||||||
$this->assertEqual($node_type_visibility, 'article', 'Visibility settings were saved to configuration');
|
$this->assertEqual($node_type_visibility, 'article', 'Visibility settings were saved to configuration');
|
||||||
|
@ -161,12 +136,13 @@ class NodeBlockFunctionalTest extends NodeTestBase {
|
||||||
|
|
||||||
// Verify visibility rules.
|
// Verify visibility rules.
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertNoText($block['title'], 'Block was not displayed on the front page.');
|
$this->assertNoText($block['subject'], 'Block was not displayed on the front page.');
|
||||||
$this->drupalGet('node/add/article');
|
$this->drupalGet('node/add/article');
|
||||||
$this->assertText($block['title'], 'Block was displayed on the node/add/article page.');
|
$this->assertText($block['subject'], 'Block was displayed on the node/add/article page.');
|
||||||
$this->drupalGet('node/' . $node1->nid);
|
$this->drupalGet('node/' . $node1->nid);
|
||||||
$this->assertText($block['title'], 'Block was displayed on the node/N when node is of type article.');
|
$this->assertText($block['subject'], 'Block was displayed on the node/N when node is of type article.');
|
||||||
$this->drupalGet('node/' . $node5->nid);
|
$this->drupalGet('node/' . $node5->nid);
|
||||||
$this->assertNoText($block['title'], 'Block was not displayed on nodes of type page.');
|
$this->assertNoText($block['subject'], 'Block was not displayed on nodes of type page.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Definition of Drupal\node\Tests\NodeBlockTest.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Drupal\node\Tests;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the availability of the syndicate block.
|
|
||||||
*/
|
|
||||||
class NodeBlockTest extends NodeTestBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modules to enable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public static $modules = array('block');
|
|
||||||
|
|
||||||
public static function getInfo() {
|
|
||||||
return array(
|
|
||||||
'name' => 'Block availability',
|
|
||||||
'description' => 'Check if the syndicate block is available.',
|
|
||||||
'group' => 'Node',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setUp() {
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
// Create a user and log in.
|
|
||||||
$admin_user = $this->drupalCreateUser(array('administer blocks'));
|
|
||||||
$this->drupalLogin($admin_user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests that the "Syndicate" block is shown when enabled.
|
|
||||||
*/
|
|
||||||
public function testSyndicateBlock() {
|
|
||||||
$block_id = 'node_syndicate_block';
|
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_second',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Enable the syndicate block.
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'Node syndicate block enabled.');
|
|
||||||
|
|
||||||
// Confirm that the block's xpath is available.
|
|
||||||
$xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-' . strtr(strtolower($block['machine_name']), '-', '_')));
|
|
||||||
$this->assertFieldByXPath($xpath, NULL, 'Syndicate block found.');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Definition of Drupal\node\Tests\NodeSyndicateBlockTest.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Drupal\node\Tests;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the availability of the syndicate block.
|
||||||
|
*/
|
||||||
|
class NodeSyndicateBlockTest extends NodeTestBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modules to enable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $modules = array('block');
|
||||||
|
|
||||||
|
public static function getInfo() {
|
||||||
|
return array(
|
||||||
|
'name' => 'Syndicate block',
|
||||||
|
'description' => 'Check if the syndicate block is available.',
|
||||||
|
'group' => 'Node',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
// Create a user and log in.
|
||||||
|
$admin_user = $this->drupalCreateUser(array('administer blocks'));
|
||||||
|
$this->drupalLogin($admin_user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the "Syndicate" block is shown when enabled.
|
||||||
|
*/
|
||||||
|
public function testSyndicateBlock() {
|
||||||
|
// Place the "Syndicate" block and confirm that it is rendered.
|
||||||
|
$this->drupalPlaceBlock('node_syndicate_block', array('machine_name' => 'test_syndicate_block'));
|
||||||
|
$this->assertFieldByXPath('//div[@id="block-test-syndicate-block"]/*', NULL, 'Syndicate block found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -24,16 +24,10 @@ abstract class OpenIDTestBase extends WebTestBase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
// Enable user login block.
|
||||||
$this->admin_user = $this->drupalCreateUser(array('administer blocks'));
|
$this->admin_user = $this->drupalCreateUser(array('administer blocks'));
|
||||||
$this->drupalLogin($this->admin_user);
|
$this->drupalLogin($this->admin_user);
|
||||||
|
$this->drupalPlaceBlock('user_login_block');
|
||||||
// Enable user login block.
|
|
||||||
$edit = array(
|
|
||||||
'machine_name' => 'user_login',
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/user_login_block/stark', $edit, t('Save block'));
|
|
||||||
|
|
||||||
$this->drupalLogout();
|
$this->drupalLogout();
|
||||||
|
|
||||||
// Use a different front page than login page for testing OpenID login from
|
// Use a different front page than login page for testing OpenID login from
|
||||||
|
|
|
@ -46,18 +46,8 @@ class PollBlockTest extends PollTestBase {
|
||||||
* Tests creating, viewing, voting on recent poll block.
|
* Tests creating, viewing, voting on recent poll block.
|
||||||
*/
|
*/
|
||||||
function testRecentBlock() {
|
function testRecentBlock() {
|
||||||
$block_id = 'poll_recent_block';
|
// Enable the recent poll block.
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$this->drupalPlaceBlock('poll_recent_block');
|
||||||
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'footer',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Enable the most recent poll block.
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), '"Most recent poll" block enabled');
|
|
||||||
|
|
||||||
// Create a poll which should appear in recent polls block.
|
// Create a poll which should appear in recent polls block.
|
||||||
$title = $this->randomName();
|
$title = $this->randomName();
|
||||||
|
|
|
@ -7,10 +7,11 @@
|
||||||
|
|
||||||
namespace Drupal\search\Tests;
|
namespace Drupal\search\Tests;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the rendering of the search block.
|
||||||
|
*/
|
||||||
class SearchBlockTest extends SearchTestBase {
|
class SearchBlockTest extends SearchTestBase {
|
||||||
|
|
||||||
protected $adminUser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modules to enable.
|
* Modules to enable.
|
||||||
*
|
*
|
||||||
|
@ -30,27 +31,16 @@ class SearchBlockTest extends SearchTestBase {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// Create and login user.
|
// Create and login user.
|
||||||
$this->adminUser = $this->drupalCreateUser(array('administer blocks', 'search content'));
|
$admin_user = $this->drupalCreateUser(array('administer blocks', 'search content'));
|
||||||
$this->drupalLogin($this->adminUser);
|
$this->drupalLogin($admin_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the search form block can be placed and works.
|
* Test that the search form block can be placed and works.
|
||||||
*/
|
*/
|
||||||
protected function testSearchFormBlock() {
|
protected function testSearchFormBlock() {
|
||||||
$block_id = 'search_form_block';
|
$block = $this->drupalPlaceBlock('search_form_block');
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$this->assertText($block['subject'], 'Block title was found.');
|
||||||
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'content',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Enable the search block.
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), '"Search form" block enabled');
|
|
||||||
$this->assertText($block['title'], 'Block title was found.');
|
|
||||||
|
|
||||||
// Test a normal search via the block form, from the front page.
|
// Test a normal search via the block form, from the front page.
|
||||||
$terms = array('search_block_form' => 'test');
|
$terms = array('search_block_form' => 'test');
|
||||||
|
@ -64,7 +54,6 @@ class SearchBlockTest extends SearchTestBase {
|
||||||
$this->assertResponse(200);
|
$this->assertResponse(200);
|
||||||
$this->assertText('Your search yielded no results');
|
$this->assertText('Your search yielded no results');
|
||||||
|
|
||||||
$block['config_id'] = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name'];
|
|
||||||
$config = config($block['config_id']);
|
$config = config($block['config_id']);
|
||||||
$config->set('visibility.path.pages', 'search');
|
$config->set('visibility.path.pages', 'search');
|
||||||
$config->save();
|
$config->save();
|
||||||
|
@ -92,4 +81,5 @@ class SearchBlockTest extends SearchTestBase {
|
||||||
'Redirected to correct url.'
|
'Redirected to correct url.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,11 +51,7 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
|
||||||
search_update_totals();
|
search_update_totals();
|
||||||
|
|
||||||
// Enable the search block.
|
// Enable the search block.
|
||||||
$edit = array(
|
$this->drupalPlaceBlock('search_form_block');
|
||||||
'machine_name' => 'search',
|
|
||||||
'region' => 'content',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/search_form_block/stark', $edit, t('Save block'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -339,6 +339,79 @@ abstract class WebTestBase extends TestBase {
|
||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a block instance based on default settings.
|
||||||
|
*
|
||||||
|
* Note: Until this can be done programmatically, the active user account
|
||||||
|
* must have permission to administer blocks.
|
||||||
|
*
|
||||||
|
* @param string $plugin_id
|
||||||
|
* The plugin ID of the block type for this block instance.
|
||||||
|
* @param array $settings
|
||||||
|
* (optional) An associative array of settings for the block instance.
|
||||||
|
* Override the defaults by specifying the key and value in the array, for
|
||||||
|
* example:
|
||||||
|
* @code
|
||||||
|
* $this->drupalPlaceBlock('system_powered_by_block', array(
|
||||||
|
* 'title' => t('Hello, world!'),
|
||||||
|
* ));
|
||||||
|
* @endcode
|
||||||
|
* The following defaults are provided:
|
||||||
|
* - title: Random string.
|
||||||
|
* - machine_name: Random string.
|
||||||
|
* - region: 'sidebar_first'.
|
||||||
|
* @param string $theme
|
||||||
|
* (optional) The theme for which to add a block instance. Defaults to the
|
||||||
|
* default theme.
|
||||||
|
*
|
||||||
|
* @return array|false
|
||||||
|
* The block instance configuration from BlockBase::getConfig(), or FALSE
|
||||||
|
* on failure.
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* Create the block programmatically once block instances are configuration
|
||||||
|
* entities.
|
||||||
|
* @todo
|
||||||
|
* Add support for creating custom block instances.
|
||||||
|
*/
|
||||||
|
protected function drupalPlaceBlock($plugin_id, array $settings = array(), $theme = NULL) {
|
||||||
|
// Confirm that the active user has permission to add the block instance.
|
||||||
|
// @todo Remove this check once it is possible to do this programmatically.
|
||||||
|
if (!empty($this->loggedInUser) && !user_access('administer blocks', $this->loggedInUser)) {
|
||||||
|
$this->fail('The logged in user does not have permission to administer blocks.');
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no theme was specified, use the default theme.
|
||||||
|
$theme = $theme ?: variable_get('theme_default', 'stark');
|
||||||
|
|
||||||
|
// Populate some default block settings.
|
||||||
|
$settings += array(
|
||||||
|
'title' => $this->randomName(8),
|
||||||
|
'machine_name' => strtolower($this->randomName(8)),
|
||||||
|
'region' => 'sidebar_first',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Submit the block instance configuration.
|
||||||
|
$this->drupalPost('admin/structure/block/manage/' . $plugin_id . '/' . $theme, $settings, t('Save block'));
|
||||||
|
$this->assertText(
|
||||||
|
t('The block configuration has been saved.'),
|
||||||
|
format_string(
|
||||||
|
'%plugin block instance added for %theme',
|
||||||
|
array(
|
||||||
|
'%plugin' => $plugin_id,
|
||||||
|
'%theme' => $theme,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Return the created block instance.
|
||||||
|
$instance_id = "plugin.core.block.$theme." . $settings['machine_name'];
|
||||||
|
$manager = $this->container->get('plugin.manager.block');
|
||||||
|
$block = $manager->getInstance(array('config' => $instance_id));
|
||||||
|
return $block->getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list files that can be used in tests.
|
* Get a list files that can be used in tests.
|
||||||
*
|
*
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Drupal\statistics\Tests;
|
||||||
* Tests that report pages render properly, and that access logging works.
|
* Tests that report pages render properly, and that access logging works.
|
||||||
*/
|
*/
|
||||||
class StatisticsReportsTest extends StatisticsTestBase {
|
class StatisticsReportsTest extends StatisticsTestBase {
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
'name' => 'Statistics reports tests',
|
'name' => 'Statistics reports tests',
|
||||||
|
@ -86,16 +87,12 @@ class StatisticsReportsTest extends StatisticsTestBase {
|
||||||
drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
|
drupal_http_request($stats_path, array('method' => 'POST', 'data' => $post, 'headers' => $headers, 'timeout' => 10000));
|
||||||
|
|
||||||
// Configure and save the block.
|
// Configure and save the block.
|
||||||
$block_id = 'statistics_popular_block';
|
$this->drupalPlaceBlock('statistics_popular_block', array(
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
'title' => 'Popular content',
|
||||||
$block = array(
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
'statistics_block_top_day_num' => 3,
|
'statistics_block_top_day_num' => 3,
|
||||||
'statistics_block_top_all_num' => 3,
|
'statistics_block_top_all_num' => 3,
|
||||||
'statistics_block_top_last_num' => 3,
|
'statistics_block_top_last_num' => 3,
|
||||||
);
|
));
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
|
|
||||||
// Get some page and check if the block is displayed.
|
// Get some page and check if the block is displayed.
|
||||||
$this->drupalGet('user');
|
$this->drupalGet('user');
|
||||||
|
@ -106,4 +103,5 @@ class StatisticsReportsTest extends StatisticsTestBase {
|
||||||
|
|
||||||
$this->assertRaw(l($node->label(), 'node/' . $node->nid), 'Found link to visited node.');
|
$this->assertRaw(l($node->label(), 'node/' . $node->nid), 'Found link to visited node.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,11 @@ class BreadcrumbTest extends MenuTestBase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $modules = array('menu_test');
|
public static $modules = array('menu_test', 'block');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test paths in the Standard profile.
|
||||||
|
*/
|
||||||
protected $profile = 'standard';
|
protected $profile = 'standard';
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
|
@ -39,14 +42,12 @@ class BreadcrumbTest extends MenuTestBase {
|
||||||
// This test puts menu links in the Tools menu and then tests for their
|
// This test puts menu links in the Tools menu and then tests for their
|
||||||
// presence on the page, so we need to ensure that the Tools block will be
|
// presence on the page, so we need to ensure that the Tools block will be
|
||||||
// displayed in the default theme and admin theme.
|
// displayed in the default theme and admin theme.
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$settings = array(
|
||||||
$admin_theme = variable_get('admin_theme', 'seven');
|
|
||||||
$edit = array(
|
|
||||||
'machine_name' => 'system_menu_tools',
|
'machine_name' => 'system_menu_tools',
|
||||||
'region' => 'content',
|
'region' => 'content',
|
||||||
);
|
);
|
||||||
$this->drupalPost("admin/structure/block/manage/system_menu_block:menu-tools/{$default_theme}", $edit, t('Save block'));
|
$this->drupalPlaceBlock('system_menu_block:menu-tools', $settings);
|
||||||
$this->drupalPost("admin/structure/block/manage/system_menu_block:menu-tools/{$admin_theme}", $edit, t('Save block'));
|
$this->drupalPlaceBlock('system_menu_block:menu-tools', $settings, config('system.theme')->get('admin'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,24 +33,10 @@ class TrailTest extends MenuTestBase {
|
||||||
$this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'administer blocks'));
|
$this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'administer blocks'));
|
||||||
$this->drupalLogin($this->admin_user);
|
$this->drupalLogin($this->admin_user);
|
||||||
|
|
||||||
// This test puts menu links in the Tools menu and then tests for their
|
// This test puts menu links in the Tools and Administration menus and then
|
||||||
// presence on the page, so we need to ensure that the Tools block will be
|
// tests for their presence on the page.
|
||||||
// displayed in the default theme.
|
$this->drupalPlaceBlock('system_menu_block:menu-tools');
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$this->drupalPlaceBlock('system_menu_block:menu-admin');
|
||||||
$block = array(
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost("admin/structure/block/manage/system_menu_block:menu-tools/{$default_theme}", $block, t('Save block'));
|
|
||||||
|
|
||||||
// This test puts menu links in the Administration menu and then tests for
|
|
||||||
// their presence on the page, so we need to ensure that the Administration
|
|
||||||
// block will be displayed in the default theme.
|
|
||||||
$block = array(
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost("admin/structure/block/manage/system_menu_block:menu-admin/{$default_theme}", $block, t('Save block'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,13 +54,9 @@ class AccessDeniedTest extends WebTestBase {
|
||||||
$this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration'));
|
$this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration'));
|
||||||
|
|
||||||
// Enable the user login block.
|
// Enable the user login block.
|
||||||
$edit = array(
|
$this->drupalPlaceBlock('user_login_block', array('machine_name' => 'login'));
|
||||||
'machine_name' => 'login',
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/user_login_block/stark', $edit, t('Save block'));
|
|
||||||
|
|
||||||
// Logout and check that the user login block is shown on custom 403 pages.
|
// Log out and check that the user login block is shown on custom 403 pages.
|
||||||
$this->drupalLogout();
|
$this->drupalLogout();
|
||||||
$this->drupalGet('admin');
|
$this->drupalGet('admin');
|
||||||
$this->assertText($this->admin_user->name, 'Found the custom 403 page');
|
$this->assertText($this->admin_user->name, 'Found the custom 403 page');
|
||||||
|
|
|
@ -35,26 +35,27 @@ class BlockUpgradePathTest extends UpgradePathTestBase {
|
||||||
public function testBlockUpgradeTitleLength() {
|
public function testBlockUpgradeTitleLength() {
|
||||||
$this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
|
$this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
|
||||||
|
|
||||||
$block_id = 'system_powered_by_block';
|
// Add a block instance with a 255-character title.
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$title = $this->randomName(255);
|
||||||
$block = array(
|
$this->drupalPlaceBlock('system_powered_by_block', array('title' => $title));
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add a new custom block with a title of 255 characters.
|
|
||||||
$block['title'] = $this->randomName(255);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
// Confirm that the custom block has been created, and title matches input.
|
// Confirm that the custom block has been created, and title matches input.
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertText($block['title'], 'Block with title longer than 64 characters successfully created.');
|
$this->assertText($title, 'Block with title longer than 64 characters successfully created.');
|
||||||
|
|
||||||
|
// Try to add a block with a title over 255 characters.
|
||||||
|
// WebTestBase::drupalPlaceBlock() asserts that the block is created
|
||||||
|
// successfully. In this case we expect the block creation to fail, so
|
||||||
|
// create a new instance of the block manually.
|
||||||
|
$settings = array(
|
||||||
|
'title' => $this->randomName(256),
|
||||||
|
'machine_name' => strtolower($this->randomName(8)),
|
||||||
|
'region' => 'sidebar_first',
|
||||||
|
);
|
||||||
|
$this->drupalPost('admin/structure/block/manage/system_powered_by_block/' . variable_get('theme_default', 'stark'), $settings, t('Save block'));
|
||||||
|
|
||||||
// Add a new custom block with a title over 255 characters.
|
|
||||||
$block['title'] = $this->randomName(256);
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
// Confirm that the custom block cannot be created with title longer than
|
// Confirm that the custom block cannot be created with title longer than
|
||||||
// the maximum number of characters.
|
// the maximum number of characters.
|
||||||
$this->assertText('Block title cannot be longer than 255 characters', 'Block with title longer than 255 characters created unsuccessfully.');
|
$this->assertText('Block title cannot be longer than 255 characters');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,7 @@ class TranslationTest extends WebTestBase {
|
||||||
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.');
|
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.');
|
||||||
|
|
||||||
// Enable the language switcher block.
|
// Enable the language switcher block.
|
||||||
$edit = array('machine_name' => 'language_switcher', 'region' => 'sidebar_first');
|
$this->drupalPlaceBlock('language_block:language_interface');
|
||||||
$this->drupalPost('admin/structure/block/manage/language_block:language_interface/bartik', $edit, t('Save block'));
|
|
||||||
|
|
||||||
// Reset static caches in our local language environment.
|
// Reset static caches in our local language environment.
|
||||||
$this->resetCaches();
|
$this->resetCaches();
|
||||||
|
|
|
@ -41,20 +41,7 @@ class UserBlocksTests extends WebTestBase {
|
||||||
|
|
||||||
$this->adminUser = $this->drupalCreateUser(array('administer blocks'));
|
$this->adminUser = $this->drupalCreateUser(array('administer blocks'));
|
||||||
$this->drupalLogin($this->adminUser);
|
$this->drupalLogin($this->adminUser);
|
||||||
|
$this->drupalPlaceBlock('user_login_block');
|
||||||
$block_id = 'user_login_block';
|
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
|
||||||
|
|
||||||
$block = array(
|
|
||||||
'title' => $this->randomName(8),
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Enable the user login block.
|
|
||||||
$this->drupalPost('admin/structure/block/manage/' . $block_id . '/' . $default_theme, $block, t('Save block'));
|
|
||||||
$this->assertText(t('The block configuration has been saved.'), 'User login block enabled');
|
|
||||||
$this->plugin_id = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name'];
|
|
||||||
$this->drupalLogout($this->adminUser);
|
$this->drupalLogout($this->adminUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,15 +53,12 @@ class OverrideDisplaysTest extends UITestBase {
|
||||||
$this->assertResponse(200);
|
$this->assertResponse(200);
|
||||||
$this->assertText($original_title);
|
$this->assertText($original_title);
|
||||||
|
|
||||||
// Put the block into the first sidebar region.
|
// Confirm that the view block is available in the block administration UI.
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add');
|
||||||
$this->drupalGet("admin/structure/block/list/block_plugin_ui:{$default_theme}/add");
|
|
||||||
$this->assertText('View: ' . $view['human_name']);
|
$this->assertText('View: ' . $view['human_name']);
|
||||||
$block = array(
|
|
||||||
'machine_name' => $this->randomName(8),
|
// Place the block.
|
||||||
'region' => 'sidebar_first',
|
$this->drupalPlaceBlock("views_block:{$view['name']}-block_1");
|
||||||
);
|
|
||||||
$this->drupalPost("admin/structure/block/manage/views_block:{$view['name']}-block_1/{$default_theme}", $block, t('Save block'));
|
|
||||||
|
|
||||||
// Make sure the title appears in the block.
|
// Make sure the title appears in the block.
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
|
@ -115,15 +112,12 @@ class OverrideDisplaysTest extends UITestBase {
|
||||||
$this->assertText($view['page[title]']);
|
$this->assertText($view['page[title]']);
|
||||||
$this->assertNoText($view['block[title]']);
|
$this->assertNoText($view['block[title]']);
|
||||||
|
|
||||||
// Put the block into the first sidebar region.
|
// Confirm that the block is available in the block administration UI.
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add');
|
||||||
$this->drupalGet("admin/structure/block/list/block_plugin_ui:{$default_theme}/add");
|
|
||||||
$this->assertText('View: ' . $view['human_name']);
|
$this->assertText('View: ' . $view['human_name']);
|
||||||
$block = array(
|
|
||||||
'machine_name' => $this->randomName(8),
|
// Place the block.
|
||||||
'region' => 'sidebar_first',
|
$this->drupalPlaceBlock("views_block:{$view['name']}-block_1");
|
||||||
);
|
|
||||||
$this->drupalPost("admin/structure/block/manage/views_block:{$view['name']}-block_1/{$default_theme}", $block, t('Save block'));
|
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertText($view['block[title]']);
|
$this->assertText($view['block[title]']);
|
||||||
$this->assertNoText($view['page[title]']);
|
$this->assertNoText($view['page[title]']);
|
||||||
|
|
|
@ -122,15 +122,12 @@ class BasicTest extends WizardTestBase {
|
||||||
$this->assertText($view3['description']);
|
$this->assertText($view3['description']);
|
||||||
$this->assertLinkByHref(url($view3['page[path]']));
|
$this->assertLinkByHref(url($view3['page[path]']));
|
||||||
|
|
||||||
// Put the block into the first sidebar region.
|
// Confirm that the block is available in the block administration UI.
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add');
|
||||||
$this->drupalGet("admin/structure/block/list/block_plugin_ui:{$default_theme}/add");
|
|
||||||
$this->assertText('View: ' . $view3['human_name']);
|
$this->assertText('View: ' . $view3['human_name']);
|
||||||
$block = array(
|
|
||||||
'machine_name' => $this->randomName(8),
|
// Place the block.
|
||||||
'region' => 'sidebar_first',
|
$this->drupalPlaceBlock("views_block:{$view3['name']}-block_1");
|
||||||
);
|
|
||||||
$this->drupalPost("admin/structure/block/manage/views_block:{$view3['name']}-block_1/{$default_theme}", $block, t('Save block'));
|
|
||||||
|
|
||||||
// Visit a random page (not the one that displays the view itself) and look
|
// Visit a random page (not the one that displays the view itself) and look
|
||||||
// for the expected node title in the block.
|
// for the expected node title in the block.
|
||||||
|
|
|
@ -74,17 +74,12 @@ class ItemsPerPageTest extends WizardTestBase {
|
||||||
$pos2 = strpos($content, $node2->label());
|
$pos2 = strpos($content, $node2->label());
|
||||||
$this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, t('The nodes appear in the expected order in the page display.'));
|
$this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, t('The nodes appear in the expected order in the page display.'));
|
||||||
|
|
||||||
$default_theme = variable_get('theme_default', 'stark');
|
// Confirm that the block is listed in the block administration UI.
|
||||||
$this->drupalGet("admin/structure/block/list/block_plugin_ui:{$default_theme}/add");
|
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add');
|
||||||
$this->assertText('View: ' . $view['human_name']);
|
$this->assertText('View: ' . $view['human_name']);
|
||||||
// Put the block into the first sidebar region, visit a page that displays
|
// Place the block, visit a page that displays the block, and check that the
|
||||||
// the block, and check that the nodes we expect appear in the correct
|
// nodes we expect appear in the correct order.
|
||||||
// order.
|
$this->drupalPlaceBlock("views_block:{$view['name']}-block_1");
|
||||||
$block = array(
|
|
||||||
'machine_name' => $this->randomName(8),
|
|
||||||
'region' => 'sidebar_first',
|
|
||||||
);
|
|
||||||
$this->drupalPost("admin/structure/block/manage/views_block:{$view['name']}-block_1/{$default_theme}", $block, t('Save block'));
|
|
||||||
|
|
||||||
$this->drupalGet('user');
|
$this->drupalGet('user');
|
||||||
$content = $this->drupalGetContent();
|
$content = $this->drupalGetContent();
|
||||||
|
|
Loading…
Reference in New Issue