Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -5,5 +5,5 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- forum
|
||||
- views
|
||||
- drupal:forum
|
||||
- drupal:views
|
||||
|
|
|
@ -52,7 +52,6 @@ class ForumBlockTest extends BrowserTestBase {
|
|||
// Create 5 forum topics.
|
||||
$topics = $this->createForumTopics();
|
||||
|
||||
|
||||
$this->assertLink(t('More'), 0, 'New forum topics block has a "more"-link.');
|
||||
$this->assertLinkByHref('forum', 0, 'New forum topics block has a "more"-link.');
|
||||
|
||||
|
@ -170,7 +169,7 @@ class ForumBlockTest extends BrowserTestBase {
|
|||
];
|
||||
|
||||
// Create the forum topic, preselecting the forum ID via a URL parameter.
|
||||
$this->drupalPostForm('node/add/forum', $edit, t('Save and publish'), ['query' => ['forum_id' => 1]]);
|
||||
$this->drupalPostForm('node/add/forum', $edit, t('Save'), ['query' => ['forum_id' => 1]]);
|
||||
$topics[] = $title;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class ForumIndexTest extends BrowserTestBase {
|
|||
$this->drupalGet("forum/$tid");
|
||||
$this->clickLink(t('Add new @node_type', ['@node_type' => 'Forum topic']));
|
||||
$this->assertUrl('node/add/forum', ['query' => ['forum_id' => $tid]]);
|
||||
$this->drupalPostForm(NULL, $edit, t('Save and publish'));
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
|
||||
// Check that the node exists in the database.
|
||||
$node = $this->drupalGetNodeByTitle($title);
|
||||
|
@ -57,6 +57,8 @@ class ForumIndexTest extends BrowserTestBase {
|
|||
'parent[0]' => $tid,
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/forum/add/forum', $edit, t('Save'));
|
||||
$this->assertSession()->linkExists(t('edit forum'));
|
||||
|
||||
$tid_child = $tid + 1;
|
||||
|
||||
// Verify that the node appears on the index.
|
||||
|
@ -69,9 +71,9 @@ class ForumIndexTest extends BrowserTestBase {
|
|||
$this->assertCacheTag('taxonomy_term:' . $tid);
|
||||
$this->assertCacheTag('taxonomy_term:' . $tid_child);
|
||||
|
||||
|
||||
// Unpublish the node.
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and unpublish'));
|
||||
$edit = ['status[value]' => FALSE];
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
|
||||
$this->drupalGet('node/' . $node->id());
|
||||
$this->assertText(t('Access denied'), 'Unpublished node is no longer accessible.');
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ class ForumNodeAccessTest extends BrowserTestBase {
|
|||
$public_node = $this->drupalGetNodeByTitle($public_node_title);
|
||||
$this->assertTrue(!empty($public_node), 'New public forum node found in database.');
|
||||
|
||||
|
||||
// Enable the new and active forum blocks.
|
||||
$this->drupalPlaceBlock('forum_active_block');
|
||||
$this->drupalPlaceBlock('forum_new_block');
|
||||
|
|
|
@ -118,7 +118,7 @@ class ForumTest extends BrowserTestBase {
|
|||
* Tests forum functionality through the admin and user interfaces.
|
||||
*/
|
||||
public function testForum() {
|
||||
//Check that the basic forum install creates a default forum topic
|
||||
// Check that the basic forum install creates a default forum topic
|
||||
$this->drupalGet('/forum');
|
||||
// Look for the "General discussion" default forum
|
||||
$this->assertRaw(Link::createFromRoute(t('General discussion'), 'forum.page', ['taxonomy_term' => 1])->toString(), "Found the default forum at the /forum listing");
|
||||
|
@ -266,7 +266,12 @@ class ForumTest extends BrowserTestBase {
|
|||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalPostForm('node/add/forum', $edit, t('Save'));
|
||||
|
||||
$nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
|
||||
$nid_count = $this->container->get('entity_type.manager')
|
||||
->getStorage('node')
|
||||
->getQuery()
|
||||
->accessCheck(FALSE)
|
||||
->count()
|
||||
->execute();
|
||||
$this->assertEqual(0, $nid_count, 'A forum node was not created when missing a forum vocabulary.');
|
||||
|
||||
// Reset the defaults for future tests.
|
||||
|
@ -427,18 +432,30 @@ class ForumTest extends BrowserTestBase {
|
|||
$view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'term/']);
|
||||
$this->assert(isset($view_link), 'The message area contains a link to a term');
|
||||
|
||||
/** @var \Drupal\taxonomy\TermStorageInterface $taxonomy_term_storage */
|
||||
$taxonomy_term_storage = $this->container->get('entity_type.manager')->getStorage('taxonomy_term');
|
||||
// Verify forum.
|
||||
$term = db_query("SELECT * FROM {taxonomy_term_field_data} t WHERE t.vid = :vid AND t.name = :name AND t.description__value = :desc AND t.default_langcode = 1", [':vid' => $this->config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description])->fetchAssoc();
|
||||
$term = $taxonomy_term_storage->loadByProperties([
|
||||
'vid' => $this->config('forum.settings')->get('vocabulary'),
|
||||
'name' => $name,
|
||||
'description__value' => $description,
|
||||
]);
|
||||
$term = array_shift($term);
|
||||
$this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database');
|
||||
|
||||
// Verify forum hierarchy.
|
||||
$tid = $term['tid'];
|
||||
$parent_tid = db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = :tid", [':tid' => $tid])->fetchField();
|
||||
$tid = $term->id();
|
||||
$parent_tid = $taxonomy_term_storage->loadParents($tid);
|
||||
$parent_tid = empty($parent_tid) ? 0 : array_shift($parent_tid)->id();
|
||||
$this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container');
|
||||
|
||||
$forum = $this->container->get('entity.manager')->getStorage('taxonomy_term')->load($tid);
|
||||
$forum = $taxonomy_term_storage->load($tid);
|
||||
$this->assertEqual(($type == 'forum container'), (bool) $forum->forum_container->value);
|
||||
return $term;
|
||||
return [
|
||||
'tid' => $tid,
|
||||
'name' => $term->getName(),
|
||||
'vid' => $term->bundle(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -525,8 +542,8 @@ class ForumTest extends BrowserTestBase {
|
|||
* @param bool $container
|
||||
* TRUE if $forum is a container; FALSE otherwise.
|
||||
*
|
||||
* @return object
|
||||
* The created topic node.
|
||||
* @return object|null
|
||||
* The created topic node or NULL if the forum is a container.
|
||||
*/
|
||||
public function createForumTopic($forum, $container = FALSE) {
|
||||
// Generate a random subject/body.
|
||||
|
@ -633,10 +650,14 @@ class ForumTest extends BrowserTestBase {
|
|||
$this->assertText(t('Forum topic @title has been updated.', ['@title' => $edit['title[0][value]']]), 'Forum node was edited');
|
||||
|
||||
// Verify topic was moved to a different forum.
|
||||
$forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", [
|
||||
':nid' => $node->id(),
|
||||
':vid' => $node->getRevisionId(),
|
||||
])->fetchField();
|
||||
$forum_tid = $this->container
|
||||
->get('database')
|
||||
->select('forum', 'f')
|
||||
->fields('f', ['tid'])
|
||||
->condition('nid', $node->id())
|
||||
->condition('vid', $node->getRevisionId())
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertTrue($forum_tid == $this->rootForum['tid'], 'The forum topic is linked to a different forum');
|
||||
|
||||
// Delete forum node.
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\forum\Functional\Views;
|
||||
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
|
||||
/**
|
||||
* Tests the forum integration into views.
|
||||
*
|
||||
* @group forum
|
||||
*/
|
||||
class ForumIntegrationTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['forum_test_views'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_forum_index'];
|
||||
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), ['forum_test_views']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the integration.
|
||||
*/
|
||||
public function testForumIntegration() {
|
||||
// Create a forum.
|
||||
$entity_manager = $this->container->get('entity.manager');
|
||||
$term = $entity_manager->getStorage('taxonomy_term')->create(['vid' => 'forums', 'name' => $this->randomMachineName()]);
|
||||
$term->save();
|
||||
|
||||
$comment_storage = $entity_manager->getStorage('comment');
|
||||
|
||||
// Create some nodes which are part of this forum with some comments.
|
||||
$nodes = [];
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$node = $this->drupalCreateNode(['type' => 'forum', 'taxonomy_forums' => [$term->id()], 'sticky' => $i == 0 ? NodeInterface::STICKY : NodeInterface::NOT_STICKY]);
|
||||
$nodes[] = $node;
|
||||
}
|
||||
|
||||
$account = $this->drupalCreateUser(['skip comment approval']);
|
||||
$this->drupalLogin($account);
|
||||
|
||||
$comments = [];
|
||||
foreach ($nodes as $index => $node) {
|
||||
for ($i = 0; $i <= $index; $i++) {
|
||||
$comment = $comment_storage->create(['entity_type' => 'node', 'entity_id' => $node->id(), 'field_name' => 'comment_forum']);
|
||||
$comment->save();
|
||||
$comments[$comment->get('entity_id')->target_id][$comment->id()] = $comment;
|
||||
}
|
||||
}
|
||||
|
||||
$view = Views::getView('test_forum_index');
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = [];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[0]->id(),
|
||||
'sticky' => NodeInterface::STICKY,
|
||||
'comment_count' => 1.,
|
||||
];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[1]->id(),
|
||||
'sticky' => NodeInterface::NOT_STICKY,
|
||||
'comment_count' => 2.,
|
||||
];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[2]->id(),
|
||||
'sticky' => NodeInterface::NOT_STICKY,
|
||||
'comment_count' => 3.,
|
||||
];
|
||||
$column_map = [
|
||||
'nid' => 'nid',
|
||||
'forum_index_sticky' => 'sticky',
|
||||
'forum_index_comment_count' => 'comment_count',
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $expected_result, $column_map);
|
||||
}
|
||||
|
||||
}
|
|
@ -36,7 +36,7 @@ class MigrateForumConfigsTest extends MigrateDrupal6TestBase {
|
|||
$this->assertIdentical(15, $config->get('topics.hot_threshold'));
|
||||
$this->assertIdentical(25, $config->get('topics.page_limit'));
|
||||
$this->assertIdentical(1, $config->get('topics.order'));
|
||||
$this->assertIdentical('vocabulary_1_i_0_', $config->get('vocabulary'));
|
||||
$this->assertIdentical('forums', $config->get('vocabulary'));
|
||||
// This is 'forum_block_num_0' in D6, but block:active:limit' in D8.
|
||||
$this->assertSame(3, $config->get('block.active.limit'));
|
||||
// This is 'forum_block_num_1' in D6, but 'block:new:limit' in D8.
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\forum\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeTestBase;
|
||||
|
||||
/**
|
||||
* Tests forum migration from Drupal 6 to Drupal 8.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateForumTest extends MigrateNodeTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'comment',
|
||||
'forum',
|
||||
'menu_ui',
|
||||
'taxonomy',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('comment');
|
||||
$this->installSchema('comment', ['comment_entity_statistics']);
|
||||
$this->installSchema('forum', ['forum', 'forum_index']);
|
||||
$this->installConfig(['comment', 'forum']);
|
||||
$this->migrateContent();
|
||||
$this->migrateTaxonomy();
|
||||
$this->executeMigrations([
|
||||
'd6_comment_type',
|
||||
'd6_comment_field',
|
||||
'd6_comment_field_instance',
|
||||
'd6_comment_entity_display',
|
||||
'd6_comment_entity_form_display',
|
||||
'd6_comment',
|
||||
'd6_term_node',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests forum migration.
|
||||
*/
|
||||
public function testForumMigration() {
|
||||
// Tests that the taxonomy_forums field storage config exists.
|
||||
$field_storage_config = FieldStorageConfig::load('node.taxonomy_forums');
|
||||
$this->assertInstanceOf(FieldStorageConfig::class, $field_storage_config);
|
||||
|
||||
// Tests that the taxonomy_forums field config exists.
|
||||
$field_config = FieldConfig::load('node.forum.taxonomy_forums');
|
||||
$this->assertInstanceOf(FieldConfig::class, $field_config);
|
||||
|
||||
// Tests that the taxonomy_forums entity view display component exists.
|
||||
$entity_view_display = EntityViewDisplay::load('node.forum.default')->getComponent('taxonomy_forums');
|
||||
$this->assertTrue(is_array($entity_view_display));
|
||||
|
||||
// Tests that the taxonomy_forums entity form display component exists.
|
||||
$entity_form_display = EntityFormDisplay::load('node.forum.default')->getComponent('taxonomy_forums');
|
||||
$this->assertTrue(is_array($entity_form_display));
|
||||
|
||||
// Test that the taxonomy_forums field has the right value.
|
||||
$node = Node::load(19);
|
||||
$this->assertEquals(8, $node->taxonomy_forums->target_id);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
|
|||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\taxonomy\TermStorageInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
|
@ -138,12 +139,12 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
$term2 = $prophecy->reveal();
|
||||
|
||||
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
|
||||
$forum_manager->expects($this->at(0))
|
||||
->method('getParents')
|
||||
$term_storage = $this->getMockBuilder(TermStorageInterface::class)->getMock();
|
||||
$term_storage->expects($this->at(0))
|
||||
->method('loadAllParents')
|
||||
->will($this->returnValue([$term1]));
|
||||
$forum_manager->expects($this->at(1))
|
||||
->method('getParents')
|
||||
$term_storage->expects($this->at(1))
|
||||
->method('loadAllParents')
|
||||
->will($this->returnValue([$term1, $term2]));
|
||||
|
||||
// The root forum.
|
||||
|
@ -167,6 +168,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
->method('getStorage')
|
||||
->will($this->returnValueMap([
|
||||
['taxonomy_vocabulary', $vocab_storage],
|
||||
['taxonomy_term', $term_storage],
|
||||
]));
|
||||
|
||||
$config_factory = $this->getConfigFactoryStub(
|
||||
|
@ -177,6 +179,8 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
]
|
||||
);
|
||||
|
||||
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
|
||||
|
||||
// Build a breadcrumb builder to test.
|
||||
$breadcrumb_builder = $this->getMock(
|
||||
'Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder', NULL, [
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
|
|||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\taxonomy\TermStorageInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
|
@ -149,11 +150,12 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
|||
$forum_manager = $this->getMockBuilder('Drupal\forum\ForumManagerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$forum_manager->expects($this->at(0))
|
||||
->method('getParents')
|
||||
$term_storage = $this->getMockBuilder(TermStorageInterface::class)->getMock();
|
||||
$term_storage->expects($this->at(0))
|
||||
->method('loadAllParents')
|
||||
->will($this->returnValue([$term1]));
|
||||
$forum_manager->expects($this->at(1))
|
||||
->method('getParents')
|
||||
$term_storage->expects($this->at(1))
|
||||
->method('loadAllParents')
|
||||
->will($this->returnValue([$term1, $term2]));
|
||||
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface');
|
||||
|
@ -176,6 +178,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
|||
->method('getStorage')
|
||||
->will($this->returnValueMap([
|
||||
['taxonomy_vocabulary', $vocab_storage],
|
||||
['taxonomy_term', $term_storage],
|
||||
]));
|
||||
|
||||
$config_factory = $this->getConfigFactoryStub(
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\forum\Unit;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\simpletest\AssertHelperTrait;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
|
@ -103,13 +104,16 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
|||
->method('hasForumNodes')
|
||||
->willReturn(TRUE);
|
||||
|
||||
$url = $this->prophesize(Url::class);
|
||||
$url->toString()->willReturn('/path/to/vocabulary/overview');
|
||||
|
||||
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('label')
|
||||
->willReturn('Vocabulary label');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('url')
|
||||
->willReturn('/path/to/vocabulary/overview');
|
||||
->method('toUrl')
|
||||
->willReturn($url->reveal());
|
||||
$vocabulary->expects($this->once())
|
||||
->method('access')
|
||||
->willReturn(TRUE);
|
||||
|
@ -143,7 +147,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
|||
->method('label')
|
||||
->willReturn('Vocabulary label');
|
||||
$vocabulary->expects($this->never())
|
||||
->method('url');
|
||||
->method('toUrl');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('access')
|
||||
->willReturn(FALSE);
|
||||
|
@ -172,10 +176,13 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
|||
->method('hasForumNodes')
|
||||
->willReturn(FALSE);
|
||||
|
||||
$url = $this->prophesize(Url::class);
|
||||
$url->toString()->willReturn('/path/to/vocabulary/overview');
|
||||
|
||||
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('url')
|
||||
->willReturn('/path/to/vocabulary/overview');
|
||||
->method('toUrl')
|
||||
->willReturn($url->reveal());
|
||||
$vocabulary->expects($this->once())
|
||||
->method('label')
|
||||
->willReturn('Vocabulary label');
|
||||
|
@ -211,7 +218,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
|||
->method('label')
|
||||
->willReturn('Vocabulary label');
|
||||
$vocabulary->expects($this->never())
|
||||
->method('url');
|
||||
->method('toUrl');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('access')
|
||||
->willReturn(FALSE);
|
||||
|
|
Reference in a new issue