Update to Drupal 8.2.2. For more information, see https://www.drupal.org/project/drupal/releases/8.2.2
This commit is contained in:
parent
23ffed3665
commit
507b45a0ed
378 changed files with 11434 additions and 5542 deletions
|
@ -237,7 +237,7 @@ class BlockForm extends EntityForm {
|
|||
// @todo Allow list of conditions to be configured in
|
||||
// https://www.drupal.org/node/2284687.
|
||||
$visibility = $this->entity->getVisibility();
|
||||
foreach ($this->manager->getDefinitions() as $condition_id => $definition) {
|
||||
foreach ($this->manager->getDefinitionsForContexts($form_state->getTemporaryValue('gathered_contexts')) as $condition_id => $definition) {
|
||||
// Don't display the current theme condition.
|
||||
if ($condition_id == 'current_theme') {
|
||||
continue;
|
||||
|
|
|
@ -8,7 +8,6 @@ use Drupal\Core\Controller\ControllerBase;
|
|||
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
|
||||
use Drupal\Core\Menu\LocalActionManagerInterface;
|
||||
use Drupal\Core\Plugin\Context\LazyContextRepository;
|
||||
use Drupal\Core\Routing\RedirectDestinationInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
@ -47,13 +46,6 @@ class BlockLibraryController extends ControllerBase {
|
|||
*/
|
||||
protected $localActionManager;
|
||||
|
||||
/**
|
||||
* The redirect destination.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RedirectDestinationInterface
|
||||
*/
|
||||
protected $redirectDestination;
|
||||
|
||||
/**
|
||||
* Constructs a BlockLibraryController object.
|
||||
*
|
||||
|
@ -65,15 +57,12 @@ class BlockLibraryController extends ControllerBase {
|
|||
* The current route match.
|
||||
* @param \Drupal\Core\Menu\LocalActionManagerInterface $local_action_manager
|
||||
* The local action manager.
|
||||
* @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination
|
||||
* The redirect destination.
|
||||
*/
|
||||
public function __construct(BlockManagerInterface $block_manager, LazyContextRepository $context_repository, RouteMatchInterface $route_match, LocalActionManagerInterface $local_action_manager, RedirectDestinationInterface $redirect_destination) {
|
||||
public function __construct(BlockManagerInterface $block_manager, LazyContextRepository $context_repository, RouteMatchInterface $route_match, LocalActionManagerInterface $local_action_manager) {
|
||||
$this->blockManager = $block_manager;
|
||||
$this->routeMatch = $route_match;
|
||||
$this->localActionManager = $local_action_manager;
|
||||
$this->contextRepository = $context_repository;
|
||||
$this->redirectDestination = $redirect_destination;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,8 +73,7 @@ class BlockLibraryController extends ControllerBase {
|
|||
$container->get('plugin.manager.block'),
|
||||
$container->get('context.repository'),
|
||||
$container->get('current_route_match'),
|
||||
$container->get('plugin.manager.menu.local_action'),
|
||||
$container->get('redirect.destination')
|
||||
$container->get('plugin.manager.menu.local_action')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -148,10 +136,6 @@ class BlockLibraryController extends ControllerBase {
|
|||
if (isset($weight)) {
|
||||
$links['add']['query']['weight'] = $weight;
|
||||
}
|
||||
$destination = $this->redirectDestination->get();
|
||||
if ($destination) {
|
||||
$links['add']['query']['destination'] = $destination;
|
||||
}
|
||||
$row['operations']['data'] = [
|
||||
'#type' => 'operations',
|
||||
'#links' => $links,
|
||||
|
|
|
@ -128,49 +128,6 @@ class BlockTest extends BlockTestBase {
|
|||
$this->assertNoText($title, 'Block was not displayed to anonymous users on the front page.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests adding a block from the library page with a destination query string.
|
||||
*/
|
||||
public function testAddBlockFromLibrary() {
|
||||
$default_theme = $this->config('system.theme')->get('default');
|
||||
$help_url = Url::fromRoute('help.page', ['name' => 'block']);
|
||||
// Set up the request so we land on the block help page after creation.
|
||||
$options = [
|
||||
'query' => [
|
||||
'region' => 'sidebar_first',
|
||||
'destination' => $help_url->toString(),
|
||||
],
|
||||
];
|
||||
$this->drupalGet(Url::fromRoute('block.admin_library', ['theme' => $default_theme], $options));
|
||||
|
||||
$block_name = 'system_powered_by_block';
|
||||
$add_url = Url::fromRoute('block.admin_add', ['plugin_id' => $block_name, 'theme' => $default_theme]);
|
||||
$links = $this->xpath('//a[contains(@href, :href)]', [':href' => $add_url->toString()]);
|
||||
$this->assertEqual(1, count($links), 'Found one matching link');
|
||||
|
||||
list($path, $query_string) = explode('?', $links[0]['href'], 2);
|
||||
parse_str($query_string, $query_parts);
|
||||
$this->assertEqual(t('Place block'), (string) $links[0]);
|
||||
$this->assertEqual($help_url->toString(), $query_parts['destination'], 'Expected destination query string is in href');
|
||||
|
||||
// Create a random title for the block.
|
||||
$title = $this->randomMachineName(8);
|
||||
$block_id = strtolower($this->randomMachineName(8));
|
||||
$edit = [
|
||||
'id' => $block_id,
|
||||
'settings[label]' => $title,
|
||||
];
|
||||
// Create the block using the link parsed from the library page.
|
||||
$this->drupalPostForm($this->getAbsoluteUrl($links[0]['href']), $edit, t('Save block'));
|
||||
// Verify that we are redirected according to the original request.
|
||||
$this->assertUrl($help_url);
|
||||
|
||||
// Ensure that the block was created.
|
||||
/** @var \Drupal\block\BlockInterface $block */
|
||||
$block = Block::load($block_id);
|
||||
$this->assertEqual($title, $block->label(), 'Found the block with expected title.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests adding a block from the library page with a weight query string.
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ class BlockUiTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('block', 'block_test', 'help');
|
||||
public static $modules = array('block', 'block_test', 'help', 'condition_test');
|
||||
|
||||
protected $regions;
|
||||
|
||||
|
@ -248,6 +248,11 @@ class BlockUiTest extends WebTestBase {
|
|||
$this->drupalGet('');
|
||||
$this->assertText('No context mapping selected.');
|
||||
$this->assertNoText('User context found.');
|
||||
|
||||
// Tests that conditions with missing context are not displayed.
|
||||
$this->drupalGet('admin/structure/block/manage/testcontextawareblock');
|
||||
$this->assertNoRaw('No existing type');
|
||||
$this->assertNoFieldByXPath('//*[@name="visibility[condition_test_no_existing_type][negate]"]');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\block\Kernel\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests block source plugin.
|
||||
*
|
||||
* @covers \Drupal\block\Plugin\migrate\source\Block
|
||||
* @group block
|
||||
*/
|
||||
class BlockTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['block', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['blocks'] = [
|
||||
[
|
||||
'bid' => 1,
|
||||
'module' => 'block',
|
||||
'delta' => '1',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'left',
|
||||
'visibility' => 0,
|
||||
'pages' => '',
|
||||
'title' => 'Test Title 01',
|
||||
'cache' => -1,
|
||||
],
|
||||
[
|
||||
'bid' => 2,
|
||||
'module' => 'block',
|
||||
'delta' => '2',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 5,
|
||||
'region' => 'right',
|
||||
'visibility' => 0,
|
||||
'pages' => '<front>',
|
||||
'title' => 'Test Title 02',
|
||||
'cache' => -1,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['blocks_roles'] = [
|
||||
[
|
||||
'module' => 'block',
|
||||
'delta' => 1,
|
||||
'rid' => 2,
|
||||
],
|
||||
[
|
||||
'module' => 'block',
|
||||
'delta' => 2,
|
||||
'rid' => 2,
|
||||
],
|
||||
[
|
||||
'module' => 'block',
|
||||
'delta' => 2,
|
||||
'rid' => 100,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['role'] = [
|
||||
[
|
||||
'rid' => 2,
|
||||
'name' => 'authenticated user',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['system'] = [
|
||||
[
|
||||
'filename' => 'modules/system/system.module',
|
||||
'name' => 'system',
|
||||
'type' => 'module',
|
||||
'owner' => '',
|
||||
'status' => '1',
|
||||
'throttle' => '0',
|
||||
'bootstrap' => '0',
|
||||
'schema_version' => '6055',
|
||||
'weight' => '0',
|
||||
'info' => 'a:0:{}',
|
||||
]
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'bid' => 1,
|
||||
'module' => 'block',
|
||||
'delta' => '1',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'left',
|
||||
'visibility' => 0,
|
||||
'pages' => '',
|
||||
'title' => 'Test Title 01',
|
||||
'cache' => -1,
|
||||
'roles' => [2]
|
||||
],
|
||||
[
|
||||
'bid' => 2,
|
||||
'module' => 'block',
|
||||
'delta' => '2',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 5,
|
||||
'region' => 'right',
|
||||
'visibility' => 0,
|
||||
'pages' => '<front>',
|
||||
'title' => 'Test Title 02',
|
||||
'cache' => -1,
|
||||
'roles' => [2]
|
||||
],
|
||||
];
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\block\Unit\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests block source plugin.
|
||||
*
|
||||
* @coversDefaultClass \Drupal\block\Plugin\migrate\source\Block
|
||||
* @group block
|
||||
*/
|
||||
class BlockTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\block\Plugin\migrate\source\Block';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'block',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Sample block instance query results from the source.
|
||||
*/
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'bid' => 1,
|
||||
'module' => 'block',
|
||||
'delta' => '1',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'left',
|
||||
'visibility' => 0,
|
||||
'pages' => '',
|
||||
'title' => 'Test Title 01',
|
||||
'cache' => -1,
|
||||
'roles' => [2]
|
||||
),
|
||||
array(
|
||||
'bid' => 2,
|
||||
'module' => 'block',
|
||||
'delta' => '2',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 5,
|
||||
'region' => 'right',
|
||||
'visibility' => 0,
|
||||
'pages' => '<front>',
|
||||
'title' => 'Test Title 02',
|
||||
'cache' => -1,
|
||||
'roles' => [2]
|
||||
),
|
||||
);
|
||||
/**
|
||||
* Sample block table.
|
||||
*/
|
||||
protected $expectedBlocks = array(
|
||||
array(
|
||||
'bid' => 1,
|
||||
'module' => 'block',
|
||||
'delta' => '1',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'left',
|
||||
'visibility' => 0,
|
||||
'pages' => '',
|
||||
'title' => 'Test Title 01',
|
||||
'cache' => -1,
|
||||
),
|
||||
array(
|
||||
'bid' => 2,
|
||||
'module' => 'block',
|
||||
'delta' => '2',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 5,
|
||||
'region' => 'right',
|
||||
'visibility' => 0,
|
||||
'pages' => '<front>',
|
||||
'title' => 'Test Title 02',
|
||||
'cache' => -1,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Sample block roles table.
|
||||
*/
|
||||
protected $expectedBlocksRoles = array(
|
||||
array(
|
||||
'module' => 'block',
|
||||
'delta' => 1,
|
||||
'rid' => 2,
|
||||
),
|
||||
array(
|
||||
'module' => 'block',
|
||||
'delta' => 2,
|
||||
'rid' => 2,
|
||||
),
|
||||
array(
|
||||
'module' => 'block',
|
||||
'delta' => 2,
|
||||
'rid' => 100,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Sample role table.
|
||||
*/
|
||||
protected $expectedRole = array(
|
||||
array(
|
||||
'rid' => 2,
|
||||
'name' => 'authenticated user',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Prepopulate database contents.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['blocks'] = $this->expectedBlocks;
|
||||
$this->databaseContents['blocks_roles'] = $this->expectedBlocksRoles;
|
||||
$this->databaseContents['role'] = $this->expectedRole;
|
||||
$this->databaseContents['system'] = array(
|
||||
array(
|
||||
'filename' => 'modules/system/system.module',
|
||||
'name' => 'system',
|
||||
'type' => 'module',
|
||||
'owner' => '',
|
||||
'status' => '1',
|
||||
'throttle' => '0',
|
||||
'bootstrap' => '0',
|
||||
'schema_version' => '6055',
|
||||
'weight' => '0',
|
||||
'info' => 'a:0:{}',
|
||||
)
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue