Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -8,6 +8,7 @@
namespace Drupal\book;
use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Link;
@ -72,6 +73,8 @@ class BookBreadcrumbBuilder implements BreadcrumbBuilderInterface {
*/
public function build(RouteMatchInterface $route_match) {
$book_nids = array();
$breadcrumb = new Breadcrumb();
$links = array(Link::createFromRoute($this->t('Home'), '<front>'));
$book = $route_match->getParameter('node')->book;
$depth = 1;
@ -92,7 +95,9 @@ class BookBreadcrumbBuilder implements BreadcrumbBuilderInterface {
$depth++;
}
}
return $links;
$breadcrumb->setLinks($links);
$breadcrumb->setCacheContexts(['route.book_navigation']);
return $breadcrumb;
}
}

View file

@ -24,7 +24,7 @@ class BookTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('book', 'block', 'node_access_test');
public static $modules = array('book', 'block', 'node_access_test', 'book_test');
/**
* A book node.
@ -109,6 +109,45 @@ class BookTest extends WebTestBase {
return $nodes;
}
/**
* Tests the book navigation cache context.
*
* @see \Drupal\book\Cache\BookNavigationCacheContext
*/
public function testBookNavigationCacheContext() {
// Create a page node.
$this->drupalCreateContentType(['type' => 'page']);
$page = $this->drupalCreateNode();
// Create a book, consisting of book nodes.
$book_nodes = $this->createBook();
// Enable the debug output.
\Drupal::state()->set('book_test.debug_book_navigation_cache_context', TRUE);
$this->drupalLogin($this->bookAuthor);
// On non-node route.
$this->drupalGet('');
$this->assertRaw('[route.book_navigation]=book.none');
// On non-book node route.
$this->drupalGet($page->urlInfo());
$this->assertRaw('[route.book_navigation]=book.none');
// On book node route.
$this->drupalGet($book_nodes[0]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|3');
$this->drupalGet($book_nodes[1]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|3|4');
$this->drupalGet($book_nodes[2]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|3|5');
$this->drupalGet($book_nodes[3]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|6');
$this->drupalGet($book_nodes[4]->urlInfo());
$this->assertRaw('[route.book_navigation]=0|2|7');
}
/**
* Tests saving the book outline on an empty book.
*/
@ -303,7 +342,7 @@ class BookTest extends WebTestBase {
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
$edit = array();
$edit['title[0][value]'] = $number . ' - SimpleTest test node ' . $this->randomMachineName(10);
$edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10);
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
$edit['book[bid]'] = $book_nid;

View file

@ -57,7 +57,7 @@ class BookUninstallTest extends KernelTestBase {
$allowed_types[] = $content_type->id();
$book_config->set('allowed_types', $allowed_types)->save();
$node = Node::create(array('type' => $content_type->id()));
$node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
$node->book['bid'] = 'new';
$node->save();
@ -65,7 +65,7 @@ class BookUninstallTest extends KernelTestBase {
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
$this->assertEqual(['To uninstall Book, delete all content that is part of a book'], $validation_reasons['book']);
$book_node = Node::create(array('type' => 'book'));
$book_node = Node::create(array('title' => $this->randomString(), 'type' => 'book'));
$book_node->book['bid'] = FALSE;
$book_node->save();
@ -84,7 +84,7 @@ class BookUninstallTest extends KernelTestBase {
$module_data = _system_rebuild_module_data();
$this->assertFalse(isset($module_data['book']->info['required']), 'The book module is not required.');
$node = Node::create(array('type' => $content_type->id()));
$node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
$node->save();
// One node exists but is not part of a book therefore the book module is
// not required.

View file

@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to book.settings.yml.
*
* @group book
* @group migrate_drupal_6
*/
class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
@ -31,7 +31,6 @@ class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Variable.php']);
$this->executeMigration('d6_book_settings');
}

View file

@ -13,7 +13,7 @@ use Drupal\node\Entity\Node;
/**
* Upgrade book structure.
*
* @group book
* @group migrate_drupal_6
*/
class MigrateBookTest extends MigrateDrupal6TestBase {
@ -29,7 +29,15 @@ class MigrateBookTest extends MigrateDrupal6TestBase {
$this->installSchema('book', array('book'));
$this->installSchema('node', array('node_access'));
$id_mappings = array();
// 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',
@ -39,11 +47,9 @@ class MigrateBookTest extends MigrateDrupal6TestBase {
));
$entity->enforceIsNew();
$entity->save();
$id_mappings['d6_node'][] = array(array($i), array($i));
$id_mappings['d6_node__story'][] = array(array($i), array($i));
}
$this->prepareMigrations($id_mappings);
// Load database dumps to provide source data.
$this->loadDumps(['Book.php', 'MenuLinks.php']);
$this->executeMigration('d6_book');
}