diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php index b52aebf..1af69e8 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php @@ -51,17 +51,11 @@ public function testBlockLinks() { )); $this->drupalLogin($admin_user); - $block = array( - 'label' => 'feed-' . $feed->title, - 'configuration' => array( - 'block_count' => 2, - ), - ); - $this->drupalPlaceBlock("aggregator_feed_block:{$feed->fid}", $block); + $block = $this->drupalPlaceBlock("aggregator_feed_block:{$feed->fid}", array('label' => 'feed-' . $feed->title), array('block_count' => 2)); // Confirm that the block is now being displayed on pages. $this->drupalGet('node'); - $this->assertText(t($block['label']), 'Feed block is displayed on the page.'); + $this->assertText($block->label(), 'Feed block is displayed on the page.'); // Find the expected read_more link. $href = 'aggregator/sources/' . $feed->fid; @@ -79,7 +73,7 @@ public function testBlockLinks() { aggregator_save_feed((array) $feed); // Check that the block is no longer displayed. $this->drupalGet('node'); - $this->assertNoText(t($block['label']), 'Feed block is not displayed on the page when number of items is set to 0.'); + $this->assertNoText($block->label(), 'Feed block is not displayed on the page when number of items is set to 0.'); } /** diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php index beb2fcc..1b76d07 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php @@ -99,9 +99,8 @@ public function testLanguageBlockVisibilityLanguageDelete() { ), ), 'machine_name' => 'language_block_test', - 'region' => 'sidebar_first', ); - $block = $this->drupalPlaceBlock('system_powered_by_block', $edit, t('Save block')); + $block = $this->drupalPlaceBlock('system_powered_by_block', $edit); // Check that we have the language in config after saving the setting. $visibility = $block->get('visibility'); diff --git a/core/modules/book/lib/Drupal/book/Tests/BookTest.php b/core/modules/book/lib/Drupal/book/Tests/BookTest.php index ae0bdae..0a1ffcf 100644 --- a/core/modules/book/lib/Drupal/book/Tests/BookTest.php +++ b/core/modules/book/lib/Drupal/book/Tests/BookTest.php @@ -331,7 +331,7 @@ function testBookNavigationBlock() { */ function testNavigationBlockOnAccessModuleEnabled() { $this->drupalLogin($this->admin_user); - $block = $this->drupalPlaceBlock('book_navigation', array('book_block_mode' => 'book pages')); + $block = $this->drupalPlaceBlock('book_navigation', array(), array('block_mode' => 'book pages')); // Give anonymous users the permission 'node test view'. $edit = array(); @@ -351,6 +351,10 @@ function testNavigationBlockOnAccessModuleEnabled() { // Test correct display of the block to anonymous users. $this->drupalGet('node/' . $this->book->nid); $this->assertText($block->label(), 'Book navigation block is displayed to anonymous users.'); + + // Test the 'book pages' block_mode setting. + $this->drupalGet(''); + $this->assertNoText($block->label(), 'Book navigation block is not shown on non-book pages.'); } /** diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php index 8d9ad8c..9f4b4a9 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php @@ -46,7 +46,7 @@ public static function getInfo() { */ function testRecentCommentBlock() { $this->drupalLogin($this->admin_user); - $block = $this->drupalPlaceBlock('recent_comments', array('configuration' => array('block_count' => 2))); + $block = $this->drupalPlaceBlock('recent_comments', array(), array('block_count' => 2)); // Add some test comments, one without a subject. $comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName()); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php index cb1368f..c3105db 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php @@ -61,7 +61,7 @@ public function testRecentNodeBlock() { )); // Enable the recent content block with two items. - $block = $this->drupalPlaceBlock('node_recent_block', array('machine_name' => 'test_block', 'configuration' => array('block_count' => 2))); + $block = $this->drupalPlaceBlock('node_recent_block', array('machine_name' => 'test_block'), array('block_count' => 2)); // Test that block is not visible without nodes. $this->drupalGet(''); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 7ac863e..1b57f61 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -347,40 +347,41 @@ protected function drupalCreateContentType($settings = array()) { * * @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 + * @param array $values + * (optional) An associative array of values for the block entity. + * 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!'), + * 'label' => t('Hello, world!'), * )); * @endcode * The following defaults are provided: - * - title: Random string. + * - label: 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. + * - theme: The default theme. + * @param array $configuration + * (optional) An associative array of plugin-specific configuration. * - * @return array|false - * The block instance configuration from BlockBase::getConfig(), or FALSE - * on failure. + * @return \Drupal\block\Plugin\Core\Entity\Block + * The block entity. * * @todo * Add support for creating custom block instances. */ - protected function drupalPlaceBlock($plugin_id, array $settings = array(), $theme = NULL) { - // If no theme was specified, use the default theme. - $theme = $theme ?: variable_get('theme_default', 'stark'); - $machine_name = isset($settings['machine_name']) ? $settings['machine_name'] : strtolower($this->randomName(8)); - $block = entity_create('block', $settings + array( + protected function drupalPlaceBlock($plugin_id, array $values = array(), array $configuration = array()) { + $values += array( 'plugin' => $plugin_id, 'label' => $this->randomName(8), - 'id' => $theme . '.' . $machine_name, 'region' => 'sidebar_first', - )); + 'theme' => variable_get('theme_default', 'stark'), + 'machine_name' => strtolower($this->randomName(8)), + ); + // Build the ID out of the theme and machine_name. + $values['id'] = $values['theme'] . '.' . $values['machine_name']; + $values['configuration'] = $configuration; + $block = entity_create('block', $values); $block->save(); return $block; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php index 9c51a89..88f188a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php @@ -47,7 +47,8 @@ function setUp() { 'region' => 'content', ); $this->drupalPlaceBlock('system_menu_block:menu-tools', $settings); - $this->drupalPlaceBlock('system_menu_block:menu-tools', $settings, config('system.theme')->get('admin')); + $settings['theme'] = config('system.theme')->get('admin'); + $this->drupalPlaceBlock('system_menu_block:menu-tools', $settings); } /**