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
|
@ -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