Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -10,7 +10,6 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
|||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\user\Entity\User;
|
||||
|
@ -447,7 +446,7 @@ function template_preprocess_forums(&$variables) {
|
|||
// them is a shadow copy.
|
||||
if ($variables['tid'] != $topic->forum_tid) {
|
||||
$variables['topics'][$id]->moved = TRUE;
|
||||
$variables['topics'][$id]->title = SafeMarkup::checkPlain($topic->getTitle());
|
||||
$variables['topics'][$id]->title = $topic->getTitle();
|
||||
$variables['topics'][$id]->message = \Drupal::l(t('This topic has been moved'), new Url('forum.page', ['taxonomy_term' => $topic->forum_tid]));
|
||||
}
|
||||
else {
|
||||
|
@ -542,7 +541,7 @@ function template_preprocess_forum_list(&$variables) {
|
|||
foreach ($variables['forums'] as $id => $forum) {
|
||||
$variables['forums'][$id]->description = array('#markup' => $forum->description->value);
|
||||
$variables['forums'][$id]->link = forum_uri($forum);
|
||||
$variables['forums'][$id]->name = SafeMarkup::checkPlain($forum->label());
|
||||
$variables['forums'][$id]->name = $forum->label();
|
||||
$variables['forums'][$id]->is_container = !empty($forum->forum_container->value);
|
||||
$variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even';
|
||||
$row++;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\forum\Breadcrumb;
|
||||
|
||||
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
|
||||
use Drupal\Core\Breadcrumb\Breadcrumb;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Link;
|
||||
|
@ -65,14 +66,18 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function build(RouteMatchInterface $route_match) {
|
||||
$breadcrumb[] = Link::createFromRoute($this->t('Home'), '<front>');
|
||||
$breadcrumb = new Breadcrumb();
|
||||
$breadcrumb->setCacheContexts(['route']);
|
||||
|
||||
$links[] = Link::createFromRoute($this->t('Home'), '<front>');
|
||||
|
||||
$vocabulary = $this->entityManager
|
||||
->getStorage('taxonomy_vocabulary')
|
||||
->load($this->config->get('vocabulary'));
|
||||
$breadcrumb[] = Link::createFromRoute($vocabulary->label(), 'forum.index');
|
||||
$breadcrumb->addCacheableDependency($vocabulary);
|
||||
$links[] = Link::createFromRoute($vocabulary->label(), 'forum.index');
|
||||
|
||||
return $breadcrumb;
|
||||
return $breadcrumb->setLinks($links);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,19 +27,26 @@ class ForumListingBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
|||
*/
|
||||
public function build(RouteMatchInterface $route_match) {
|
||||
$breadcrumb = parent::build($route_match);
|
||||
$breadcrumb->addCacheContexts(['route']);
|
||||
|
||||
// Add all parent forums to breadcrumbs.
|
||||
$term_id = $route_match->getParameter('taxonomy_term')->id();
|
||||
/** @var \Drupal\Taxonomy\TermInterface $term */
|
||||
$term = $route_match->getParameter('taxonomy_term');
|
||||
$term_id = $term->id();
|
||||
$breadcrumb->addCacheableDependency($term);
|
||||
|
||||
$parents = $this->forumManager->getParents($term_id);
|
||||
if ($parents) {
|
||||
foreach (array_reverse($parents) as $parent) {
|
||||
if ($parent->id() != $term_id) {
|
||||
$breadcrumb[] = Link::createFromRoute($parent->label(), 'forum.page', array(
|
||||
$breadcrumb->addCacheableDependency($parent);
|
||||
$breadcrumb->addLink(Link::createFromRoute($parent->label(), 'forum.page', [
|
||||
'taxonomy_term' => $parent->id(),
|
||||
));
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $breadcrumb;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,18 +29,21 @@ class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
|||
*/
|
||||
public function build(RouteMatchInterface $route_match) {
|
||||
$breadcrumb = parent::build($route_match);
|
||||
$breadcrumb->addCacheContexts(['route']);
|
||||
|
||||
$parents = $this->forumManager->getParents($route_match->getParameter('node')->forum_tid);
|
||||
if ($parents) {
|
||||
$parents = array_reverse($parents);
|
||||
foreach ($parents as $parent) {
|
||||
$breadcrumb[] = Link::createFromRoute($parent->label(), 'forum.page',
|
||||
$breadcrumb->addCacheableDependency($parent);
|
||||
$breadcrumb->addLink(Link::createFromRoute($parent->label(), 'forum.page',
|
||||
array(
|
||||
'taxonomy_term' => $parent->id(),
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return $breadcrumb;
|
||||
}
|
||||
|
||||
|
|
|
@ -190,6 +190,7 @@ class ForumController extends ControllerBase {
|
|||
else {
|
||||
// Set the page title to forum's vocabulary name.
|
||||
$build['#title'] = $vocabulary->label();
|
||||
$this->renderer->addCacheableDependency($build, $vocabulary);
|
||||
}
|
||||
return $build;
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ class ForumTest extends WebTestBase {
|
|||
'access comments',
|
||||
));
|
||||
$this->drupalPlaceBlock('help_block', array('region' => 'help'));
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,6 +236,7 @@ class ForumTest extends WebTestBase {
|
|||
|
||||
// Test the root forum page title change.
|
||||
$this->drupalGet('forum');
|
||||
$this->assertCacheTag('config:taxonomy.vocabulary.' . $this->forum['vid']);
|
||||
$this->assertTitle(t('Forums | Drupal'));
|
||||
$vocabulary = Vocabulary::load($this->forum['vid']);
|
||||
$vocabulary->set('name', 'Discussions');
|
||||
|
|
|
@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
/**
|
||||
* Upgrade variables to forum.settings.yml.
|
||||
*
|
||||
* @group forum
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateForumConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
|
@ -36,7 +36,6 @@ class MigrateForumConfigsTest extends MigrateDrupal6TestBase {
|
|||
array(array(1), array('vocabulary_1_i_0_')),
|
||||
)
|
||||
));
|
||||
$this->loadDumps(['Variable.php']);
|
||||
$this->executeMigration('d6_forum_settings');
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
|
||||
namespace Drupal\Tests\forum\Unit\Breadcrumb;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase
|
||||
|
@ -16,6 +18,22 @@ use Drupal\Tests\UnitTestCase;
|
|||
*/
|
||||
class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cache_contexts_manager->expects($this->any())
|
||||
->method('validate_tokens');
|
||||
$container = new Container();
|
||||
$container->set('cache_contexts_manager', $cache_contexts_manager);
|
||||
\Drupal::setContainer($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ForumBreadcrumbBuilderBase::__construct().
|
||||
*
|
||||
|
@ -74,16 +92,18 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$vocab_item = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
||||
$vocab_item->expects($this->any())
|
||||
->method('label')
|
||||
->will($this->returnValue('Fora_is_the_plural_of_forum'));
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface');
|
||||
$prophecy->label()->willReturn('Fora_is_the_plural_of_forum');
|
||||
$prophecy->id()->willReturn(5);
|
||||
$prophecy->getCacheTags()->willReturn(['taxonomy_vocabulary:5']);
|
||||
$prophecy->getCacheContexts()->willReturn([]);
|
||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
|
||||
$vocab_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$vocab_storage->expects($this->any())
|
||||
->method('load')
|
||||
->will($this->returnValueMap(array(
|
||||
array('forums', $vocab_item),
|
||||
array('forums', $prophecy->reveal()),
|
||||
)));
|
||||
|
||||
$entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManagerInterface')
|
||||
|
@ -128,7 +148,11 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
|
|||
);
|
||||
|
||||
// And finally, the test.
|
||||
$this->assertEquals($expected, $breadcrumb_builder->build($route_match));
|
||||
$breadcrumb = $breadcrumb_builder->build($route_match);
|
||||
$this->assertEquals($expected, $breadcrumb->getLinks());
|
||||
$this->assertEquals(['route'], $breadcrumb->getCacheContexts());
|
||||
$this->assertEquals(['taxonomy_vocabulary:5'], $breadcrumb->getCacheTags());
|
||||
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
|
||||
namespace Drupal\Tests\forum\Unit\Breadcrumb;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder
|
||||
|
@ -17,6 +19,22 @@ use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
|||
*/
|
||||
class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cache_contexts_manager->expects($this->any())
|
||||
->method('validate_tokens');
|
||||
$container = new Container();
|
||||
$container->set('cache_contexts_manager', $cache_contexts_manager);
|
||||
\Drupal::setContainer($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ForumListingBreadcrumbBuilder::applies().
|
||||
*
|
||||
|
@ -105,25 +123,21 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
*/
|
||||
public function testBuild() {
|
||||
// Build all our dependencies, backwards.
|
||||
$term1 = $this->getMockBuilder('Drupal\taxonomy\Entity\Term')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$term1->expects($this->any())
|
||||
->method('label')
|
||||
->will($this->returnValue('Something'));
|
||||
$term1->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue(1));
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\Entity\Term');
|
||||
$prophecy->label()->willReturn('Something');
|
||||
$prophecy->id()->willReturn(1);
|
||||
$prophecy->getCacheTags()->willReturn(['taxonomy_term:1']);
|
||||
$prophecy->getCacheContexts()->willReturn([]);
|
||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
$term1 = $prophecy->reveal();
|
||||
|
||||
$term2 = $this->getMockBuilder('Drupal\taxonomy\Entity\Term')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$term2->expects($this->any())
|
||||
->method('label')
|
||||
->will($this->returnValue('Something else'));
|
||||
$term2->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue(2));
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\Entity\Term');
|
||||
$prophecy->label()->willReturn('Something else');
|
||||
$prophecy->id()->willReturn(2);
|
||||
$prophecy->getCacheTags()->willReturn(['taxonomy_term:2']);
|
||||
$prophecy->getCacheContexts()->willReturn([]);
|
||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
$term2 = $prophecy->reveal();
|
||||
|
||||
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
|
||||
$forum_manager->expects($this->at(0))
|
||||
|
@ -134,15 +148,17 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
->will($this->returnValue(array($term1, $term2)));
|
||||
|
||||
// The root forum.
|
||||
$vocab_item = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
||||
$vocab_item->expects($this->any())
|
||||
->method('label')
|
||||
->will($this->returnValue('Fora_is_the_plural_of_forum'));
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface');
|
||||
$prophecy->label()->willReturn('Fora_is_the_plural_of_forum');
|
||||
$prophecy->id()->willReturn(5);
|
||||
$prophecy->getCacheTags()->willReturn(['taxonomy_vocabulary:5']);
|
||||
$prophecy->getCacheContexts()->willReturn([]);
|
||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
$vocab_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$vocab_storage->expects($this->any())
|
||||
->method('load')
|
||||
->will($this->returnValueMap(array(
|
||||
array('forums', $vocab_item),
|
||||
array('forums', $prophecy->reveal()),
|
||||
)));
|
||||
|
||||
$entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManagerInterface')
|
||||
|
@ -176,13 +192,13 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
$breadcrumb_builder->setStringTranslation($translation_manager);
|
||||
|
||||
// The forum listing we need a breadcrumb back from.
|
||||
$forum_listing = $this->getMockBuilder('Drupal\taxonomy\Entity\Term')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$forum_listing->tid = 23;
|
||||
$forum_listing->expects($this->any())
|
||||
->method('label')
|
||||
->will($this->returnValue('You_should_not_see_this'));
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\Entity\Term');
|
||||
$prophecy->label()->willReturn('You_should_not_see_this');
|
||||
$prophecy->id()->willReturn(23);
|
||||
$prophecy->getCacheTags()->willReturn(['taxonomy_term:23']);
|
||||
$prophecy->getCacheContexts()->willReturn([]);
|
||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
$forum_listing = $prophecy->reveal();
|
||||
|
||||
// Our data set.
|
||||
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
|
||||
|
@ -197,7 +213,11 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
Link::createFromRoute('Fora_is_the_plural_of_forum', 'forum.index'),
|
||||
Link::createFromRoute('Something', 'forum.page', array('taxonomy_term' => 1)),
|
||||
);
|
||||
$this->assertEquals($expected1, $breadcrumb_builder->build($route_match));
|
||||
$breadcrumb = $breadcrumb_builder->build($route_match);
|
||||
$this->assertEquals($expected1, $breadcrumb->getLinks());
|
||||
$this->assertEquals(['route'], $breadcrumb->getCacheContexts());
|
||||
$this->assertEquals(['taxonomy_term:1', 'taxonomy_term:23', 'taxonomy_vocabulary:5'], $breadcrumb->getCacheTags());
|
||||
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
|
||||
|
||||
// Second test.
|
||||
$expected2 = array(
|
||||
|
@ -206,7 +226,12 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
Link::createFromRoute('Something else', 'forum.page', array('taxonomy_term' => 2)),
|
||||
Link::createFromRoute('Something', 'forum.page', array('taxonomy_term' => 1)),
|
||||
);
|
||||
$this->assertEquals($expected2, $breadcrumb_builder->build($route_match));
|
||||
$breadcrumb = $breadcrumb_builder->build($route_match);
|
||||
$this->assertEquals($expected2, $breadcrumb->getLinks());
|
||||
$this->assertEquals(['route'], $breadcrumb->getCacheContexts());
|
||||
$this->assertEquals(['taxonomy_term:1', 'taxonomy_term:2', 'taxonomy_term:23', 'taxonomy_vocabulary:5'], $breadcrumb->getCacheTags());
|
||||
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
|
||||
namespace Drupal\Tests\forum\Unit\Breadcrumb;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder
|
||||
|
@ -17,6 +18,22 @@ use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
|||
*/
|
||||
class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cache_contexts_manager->expects($this->any())
|
||||
->method('validate_tokens');
|
||||
$container = new Container();
|
||||
$container->set('cache_contexts_manager', $cache_contexts_manager);
|
||||
\Drupal::setContainer($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ForumNodeBreadcrumbBuilder::applies().
|
||||
*
|
||||
|
@ -112,25 +129,21 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
|||
*/
|
||||
public function testBuild() {
|
||||
// Build all our dependencies, backwards.
|
||||
$term1 = $this->getMockBuilder('Drupal\Core\Entity\EntityInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$term1->expects($this->any())
|
||||
->method('label')
|
||||
->will($this->returnValue('Something'));
|
||||
$term1->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue(1));
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\Entity\Term');
|
||||
$prophecy->label()->willReturn('Something');
|
||||
$prophecy->id()->willReturn(1);
|
||||
$prophecy->getCacheTags()->willReturn(['taxonomy_term:1']);
|
||||
$prophecy->getCacheContexts()->willReturn([]);
|
||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
$term1 = $prophecy->reveal();
|
||||
|
||||
$term2 = $this->getMockBuilder('Drupal\Core\Entity\EntityInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$term2->expects($this->any())
|
||||
->method('label')
|
||||
->will($this->returnValue('Something else'));
|
||||
$term2->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue(2));
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\Entity\Term');
|
||||
$prophecy->label()->willReturn('Something else');
|
||||
$prophecy->id()->willReturn(2);
|
||||
$prophecy->getCacheTags()->willReturn(['taxonomy_term:2']);
|
||||
$prophecy->getCacheContexts()->willReturn([]);
|
||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
$term2 = $prophecy->reveal();
|
||||
|
||||
$forum_manager = $this->getMockBuilder('Drupal\forum\ForumManagerInterface')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -142,15 +155,17 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
|||
->method('getParents')
|
||||
->will($this->returnValue(array($term1, $term2)));
|
||||
|
||||
$vocab_item = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
||||
$vocab_item->expects($this->any())
|
||||
->method('label')
|
||||
->will($this->returnValue('Forums'));
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface');
|
||||
$prophecy->label()->willReturn('Forums');
|
||||
$prophecy->id()->willReturn(5);
|
||||
$prophecy->getCacheTags()->willReturn(['taxonomy_vocabulary:5']);
|
||||
$prophecy->getCacheContexts()->willReturn([]);
|
||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
$vocab_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$vocab_storage->expects($this->any())
|
||||
->method('load')
|
||||
->will($this->returnValueMap(array(
|
||||
array('forums', $vocab_item),
|
||||
array('forums', $prophecy->reveal()),
|
||||
)));
|
||||
|
||||
$entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManagerInterface')
|
||||
|
@ -203,7 +218,11 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
|||
Link::createFromRoute('Forums', 'forum.index'),
|
||||
Link::createFromRoute('Something', 'forum.page', array('taxonomy_term' => 1)),
|
||||
);
|
||||
$this->assertEquals($expected1, $breadcrumb_builder->build($route_match));
|
||||
$breadcrumb = $breadcrumb_builder->build($route_match);
|
||||
$this->assertEquals($expected1, $breadcrumb->getLinks());
|
||||
$this->assertEquals(['route'], $breadcrumb->getCacheContexts());
|
||||
$this->assertEquals(['taxonomy_term:1', 'taxonomy_vocabulary:5'], $breadcrumb->getCacheTags());
|
||||
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
|
||||
|
||||
// Second test.
|
||||
$expected2 = array(
|
||||
|
@ -212,7 +231,11 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
|||
Link::createFromRoute('Something else', 'forum.page', array('taxonomy_term' => 2)),
|
||||
Link::createFromRoute('Something', 'forum.page', array('taxonomy_term' => 1)),
|
||||
);
|
||||
$this->assertEquals($expected2, $breadcrumb_builder->build($route_match));
|
||||
$breadcrumb = $breadcrumb_builder->build($route_match);
|
||||
$this->assertEquals($expected2, $breadcrumb->getLinks());
|
||||
$this->assertEquals(['route'], $breadcrumb->getCacheContexts());
|
||||
$this->assertEquals(['taxonomy_term:1', 'taxonomy_term:2', 'taxonomy_vocabulary:5'], $breadcrumb->getCacheTags());
|
||||
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Tests\forum\Unit;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
|
@ -127,10 +126,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
|||
$module = 'forum';
|
||||
$expected = [
|
||||
'To uninstall Forum, first delete all <em>Forum</em> content',
|
||||
SafeMarkup::format('To uninstall Forum, first delete all <a href="@url">%vocabulary</a> terms', [
|
||||
'@url' => '/path/to/vocabulary/overview',
|
||||
'%vocabulary' => 'Vocabulary label',
|
||||
]),
|
||||
'To uninstall Forum, first delete all <a href="/path/to/vocabulary/overview"><em class="placeholder">Vocabulary label</em></a> terms',
|
||||
];
|
||||
$reasons = $this->forumUninstallValidator->validate($module);
|
||||
$this->assertSame($expected, $reasons);
|
||||
|
@ -164,9 +160,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
|||
$module = 'forum';
|
||||
$expected = [
|
||||
'To uninstall Forum, first delete all <em>Forum</em> content',
|
||||
SafeMarkup::format('To uninstall Forum, first delete all %vocabulary terms', [
|
||||
'%vocabulary' => 'Vocabulary label',
|
||||
]),
|
||||
'To uninstall Forum, first delete all <em class="placeholder">Vocabulary label</em> terms',
|
||||
];
|
||||
$reasons = $this->forumUninstallValidator->validate($module);
|
||||
$this->assertSame($expected, $reasons);
|
||||
|
@ -200,10 +194,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
|||
|
||||
$module = 'forum';
|
||||
$expected = [
|
||||
SafeMarkup::format('To uninstall Forum, first delete all <a href="@url">%vocabulary</a> terms', [
|
||||
'@url' => '/path/to/vocabulary/overview',
|
||||
'%vocabulary' => 'Vocabulary label',
|
||||
]),
|
||||
'To uninstall Forum, first delete all <a href="/path/to/vocabulary/overview"><em class="placeholder">Vocabulary label</em></a> terms',
|
||||
];
|
||||
$reasons = $this->forumUninstallValidator->validate($module);
|
||||
$this->assertSame($expected, $reasons);
|
||||
|
@ -236,9 +227,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
|||
|
||||
$module = 'forum';
|
||||
$expected = [
|
||||
SafeMarkup::format('To uninstall Forum, first delete all %vocabulary terms', [
|
||||
'%vocabulary' => 'Vocabulary label',
|
||||
]),
|
||||
'To uninstall Forum, first delete all <em class="placeholder">Vocabulary label</em> terms',
|
||||
];
|
||||
$reasons = $this->forumUninstallValidator->validate($module);
|
||||
$this->assertSame($expected, $reasons);
|
||||
|
|
Reference in a new issue