Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -96,7 +96,7 @@ class BookBreadcrumbBuilder implements BreadcrumbBuilderInterface {
}
}
$breadcrumb->setLinks($links);
$breadcrumb->setCacheContexts(['route.book_navigation']);
$breadcrumb->addCacheContexts(['route.book_navigation']);
return $breadcrumb;
}

View file

@ -357,7 +357,7 @@ class BookManager implements BookManagerInterface {
'#type' => 'select',
'#title' => $this->t('Parent item'),
'#default_value' => $book_link['pid'],
'#description' => $this->t('The parent page in the book. The maximum depth for a book and all child pages is !maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => static::BOOK_MAX_DEPTH)),
'#description' => $this->t('The parent page in the book. The maximum depth for a book and all child pages is @maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array('@maxdepth' => static::BOOK_MAX_DEPTH)),
'#options' => $this->getTableOfContents($book_link['bid'], $book_link['parent_depth_limit'], array($book_link['nid'])),
'#attributes' => array('class' => array('book-title-select')),
'#prefix' => '<div id="edit-book-plid-wrapper">',
@ -539,30 +539,33 @@ class BookManager implements BookManagerInterface {
$items = [];
foreach ($tree as $data) {
$class = ['menu-item'];
$element = [];
// Generally we only deal with visible links, but just in case.
if (!$data['link']['access']) {
continue;
}
// Set a class for the <li>-tag. Since $data['below'] may contain local
// tasks, only set 'expanded' class if the link also has children within
// Set a class for the <li> tag. Since $data['below'] may contain local
// tasks, only set 'expanded' to true if the link also has children within
// the current book.
$element['is_expanded'] = FALSE;
$element['is_collapsed'] = FALSE;
if ($data['link']['has_children'] && $data['below']) {
$class[] = 'menu-item--expanded';
$element['is_expanded'] = TRUE;
}
elseif ($data['link']['has_children']) {
$class[] = 'menu-item--collapsed';
$element['is_collapsed'] = TRUE;
}
// Set a class if the link is in the active trail.
// Set a helper variable to indicate whether the link is in the active
// trail.
$element['in_active_trail'] = FALSE;
if ($data['link']['in_active_trail']) {
$class[] = 'menu-item--active-trail';
$element['in_active_trail'] = TRUE;
}
// Allow book-specific theme overrides.
$element = [];
$element['attributes'] = new Attribute();
$element['attributes']['class'] = $class;
$element['title'] = $data['link']['title'];
$node = $this->entityManager->getStorage('node')->load($data['link']['nid']);
$element['url'] = $node->urlInfo();

View file

@ -8,6 +8,7 @@
namespace Drupal\book\Tests;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\user\RoleInterface;
@ -67,6 +68,7 @@ class BookTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$this->drupalPlaceBlock('system_breadcrumb_block');
$this->drupalPlaceBlock('page_title_block');
// node_access_test requires a node_access_rebuild().
node_access_rebuild();
@ -124,11 +126,12 @@ class BookTest extends WebTestBase {
// Enable the debug output.
\Drupal::state()->set('book_test.debug_book_navigation_cache_context', TRUE);
Cache::invalidateTags(['book_test.debug_book_navigation_cache_context']);
$this->drupalLogin($this->bookAuthor);
// On non-node route.
$this->drupalGet('');
$this->drupalGet($this->adminUser->urlInfo());
$this->assertRaw('[route.book_navigation]=book.none');
// On non-book node route.
@ -494,99 +497,6 @@ class BookTest extends WebTestBase {
$this->assertTrue(empty($node->book), 'Deleting childless top-level book node properly allowed.');
}
/*
* Tests node type changing machine name when type is a book allowed type.
*/
function testBookNodeTypeChange() {
$this->drupalLogin($this->adminUser);
// Change the name, machine name and description.
$edit = array(
'name' => 'Bar',
'type' => 'bar',
);
$this->drupalPostForm('admin/structure/types/manage/book', $edit, t('Save content type'));
// Ensure that the config book.settings:allowed_types has been updated with
// the new machine and the old one has been removed.
$this->assertTrue(book_type_is_allowed('bar'), 'Config book.settings:allowed_types contains the updated node type machine name "bar".');
$this->assertFalse(book_type_is_allowed('book'), 'Config book.settings:allowed_types does not contain the old node type machine name "book".');
$edit = array(
'name' => 'Basic page',
'title_label' => 'Title for basic page',
'type' => 'page',
);
$this->drupalPostForm('admin/structure/types/add', $edit, t('Save content type'));
// Add page to the allowed node types.
$edit = array(
'book_allowed_types[page]' => 'page',
'book_allowed_types[bar]' => 'bar',
);
$this->drupalPostForm('admin/structure/book/settings', $edit, t('Save configuration'));
$this->assertTrue(book_type_is_allowed('bar'), 'Config book.settings:allowed_types contains the bar node type.');
$this->assertTrue(book_type_is_allowed('page'), 'Config book.settings:allowed_types contains the page node type.');
// Test the order of the book.settings::allowed_types configuration is as
// expected. The point of this test is to prove that after changing a node
// type going to admin/structure/book/settings and pressing save without
// changing anything should not alter the book.settings configuration. The
// order will be:
// @code
// array(
// 'bar',
// 'page',
// );
// @endcode
$current_config = $this->config('book.settings')->get();
$this->drupalPostForm('admin/structure/book/settings', array(), t('Save configuration'));
$this->assertIdentical($current_config, $this->config('book.settings')->get());
// Change the name, machine name and description.
$edit = array(
'name' => 'Zebra book',
'type' => 'zebra',
);
$this->drupalPostForm('admin/structure/types/manage/bar', $edit, t('Save content type'));
$this->assertTrue(book_type_is_allowed('zebra'), 'Config book.settings:allowed_types contains the zebra node type.');
$this->assertTrue(book_type_is_allowed('page'), 'Config book.settings:allowed_types contains the page node type.');
// Test the order of the book.settings::allowed_types configuration is as
// expected. The order should be:
// @code
// array(
// 'page',
// 'zebra',
// );
// @endcode
$current_config = $this->config('book.settings')->get();
$this->drupalPostForm('admin/structure/book/settings', array(), t('Save configuration'));
$this->assertIdentical($current_config, $this->config('book.settings')->get());
$edit = array(
'name' => 'Animal book',
'type' => 'zebra',
);
$this->drupalPostForm('admin/structure/types/manage/zebra', $edit, t('Save content type'));
// Test the order of the book.settings::allowed_types configuration is as
// expected. The order should be:
// @code
// array(
// 'page',
// 'zebra',
// );
// @endcode
$current_config = $this->config('book.settings')->get();
$this->drupalPostForm('admin/structure/book/settings', array(), t('Save configuration'));
$this->assertIdentical($current_config, $this->config('book.settings')->get());
// Ensure that after all the node type changes book.settings:child_type has
// the expected value.
$this->assertEqual($this->config('book.settings')->get('child_type'), 'zebra');
}
/**
* Tests re-ordering of books.
*/

View file

@ -23,7 +23,7 @@ class BookUninstallTest extends KernelTestBase {
*
* @var array
*/
public static $modules = array('system', 'user', 'field', 'filter', 'text', 'entity_reference', 'node', 'book');
public static $modules = ['system', 'user', 'field', 'filter', 'text', 'node', 'book'];
/**
* {@inheritdoc}

View file

@ -20,11 +20,9 @@ class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('book', 'system', 'node', 'field', 'text', 'entity_reference');
public static $modules = ['book'];
/**
* {@inheritdoc}

View file

@ -17,39 +17,19 @@ use Drupal\node\Entity\Node;
*/
class MigrateBookTest extends MigrateDrupal6TestBase {
public static $modules = array('book', 'system', 'node', 'field', 'text', 'entity_reference', 'user');
/**
* {@inheritdoc}
*/
public static $modules = ['book'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installSchema('book', array('book'));
$this->installSchema('node', array('node_access'));
// Create a default bogus mapping for all variants of d6_node.
$id_mappings = array(
'd6_node:*' => array(
array(
array(0),
array(0),
),
),
);
for ($i = 4; $i <= 8; $i++) {
$entity = entity_create('node', array(
'type' => 'story',
'title' => "Node $i",
'nid' => $i,
'status' => TRUE,
));
$entity->enforceIsNew();
$entity->save();
$id_mappings['d6_node__story'][] = array(array($i), array($i));
}
$this->prepareMigrations($id_mappings);
$this->installSchema('book', ['book']);
$this->installSchema('node', ['node_access']);
$this->migrateContent();
$this->executeMigration('d6_book');
}