Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -42,6 +42,13 @@ content:
|
|||
weight: 15
|
||||
region: content
|
||||
third_party_settings: { }
|
||||
status:
|
||||
type: boolean_checkbox
|
||||
settings:
|
||||
display_label: true
|
||||
weight: 120
|
||||
region: content
|
||||
third_party_settings: { }
|
||||
sticky:
|
||||
type: boolean_checkbox
|
||||
settings:
|
||||
|
|
|
@ -2,11 +2,11 @@ name: Forum
|
|||
type: module
|
||||
description: 'Provides discussion forums.'
|
||||
dependencies:
|
||||
- node
|
||||
- history
|
||||
- taxonomy
|
||||
- comment
|
||||
- options
|
||||
- drupal:node
|
||||
- drupal:history
|
||||
- drupal:taxonomy
|
||||
- drupal:comment
|
||||
- drupal:options
|
||||
package: Core
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
|
|
|
@ -455,17 +455,20 @@ function template_preprocess_forums(&$variables) {
|
|||
$variables['topics'][$id]->title_link = \Drupal::l($topic->getTitle(), $topic->urlInfo());
|
||||
$variables['topics'][$id]->message = '';
|
||||
}
|
||||
$forum_submitted = ['#theme' => 'forum_submitted', '#topic' => (object) [
|
||||
'uid' => $topic->getOwnerId(),
|
||||
'name' => $topic->getOwner()->getDisplayName(),
|
||||
'created' => $topic->getCreatedTime(),
|
||||
]];
|
||||
$variables['topics'][$id]->submitted = drupal_render($forum_submitted);
|
||||
$forum_submitted = [
|
||||
'#theme' => 'forum_submitted',
|
||||
'#topic' => (object) [
|
||||
'uid' => $topic->getOwnerId(),
|
||||
'name' => $topic->getOwner()->getDisplayName(),
|
||||
'created' => $topic->getCreatedTime(),
|
||||
],
|
||||
];
|
||||
$variables['topics'][$id]->submitted = \Drupal::service('renderer')->render($forum_submitted);
|
||||
$forum_submitted = [
|
||||
'#theme' => 'forum_submitted',
|
||||
'#topic' => isset($topic->last_reply) ? $topic->last_reply : NULL,
|
||||
];
|
||||
$variables['topics'][$id]->last_reply = drupal_render($forum_submitted);
|
||||
$variables['topics'][$id]->last_reply = \Drupal::service('renderer')->render($forum_submitted);
|
||||
|
||||
$variables['topics'][$id]->new_text = '';
|
||||
$variables['topics'][$id]->new_url = '';
|
||||
|
@ -519,6 +522,7 @@ function template_preprocess_forums(&$variables) {
|
|||
$table['#rows'][] = $row;
|
||||
}
|
||||
|
||||
$variables['topics_original'] = $variables['topics'];
|
||||
$variables['topics'] = $table;
|
||||
$variables['topics_pager'] = [
|
||||
'#type' => 'pager',
|
||||
|
@ -569,7 +573,7 @@ function template_preprocess_forum_list(&$variables) {
|
|||
$variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics;
|
||||
}
|
||||
$forum_submitted = ['#theme' => 'forum_submitted', '#topic' => $forum->last_post];
|
||||
$variables['forums'][$id]->last_reply = drupal_render($forum_submitted);
|
||||
$variables['forums'][$id]->last_reply = \Drupal::service('renderer')->render($forum_submitted);
|
||||
}
|
||||
|
||||
$variables['pager'] = [
|
||||
|
@ -636,7 +640,7 @@ function template_preprocess_forum_submitted(&$variables) {
|
|||
$variables['author'] = '';
|
||||
if (isset($variables['topic']->uid)) {
|
||||
$username = ['#theme' => 'username', '#account' => User::load($variables['topic']->uid)];
|
||||
$variables['author'] = drupal_render($username);
|
||||
$variables['author'] = \Drupal::service('renderer')->render($username);
|
||||
}
|
||||
$variables['time'] = isset($variables['topic']->created) ? \Drupal::service('date.formatter')->formatTimeDiffSince($variables['topic']->created) : '';
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ function forum_views_data() {
|
|||
'filter' => [
|
||||
'title' => t('Has taxonomy term'),
|
||||
'id' => 'taxonomy_index_tid',
|
||||
'hierarchy table' => 'taxonomy_term_hierarchy',
|
||||
'hierarchy table' => 'taxonomy_term__parent',
|
||||
'numeric' => TRUE,
|
||||
'skip base' => 'taxonomy_term_data',
|
||||
'allow empty' => TRUE,
|
||||
|
@ -86,7 +86,6 @@ function forum_views_data() {
|
|||
],
|
||||
];
|
||||
|
||||
|
||||
$data['forum_index']['created'] = [
|
||||
'title' => t('Post date'),
|
||||
'help' => t('The date the content was posted.'),
|
||||
|
@ -94,7 +93,7 @@ function forum_views_data() {
|
|||
'id' => 'date',
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'date'
|
||||
'id' => 'date',
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'date',
|
||||
|
|
|
@ -2,6 +2,7 @@ id: d6_forum_settings
|
|||
label: Forum configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
|
@ -11,6 +12,7 @@ source:
|
|||
- forum_block_num_0
|
||||
- forum_block_num_1
|
||||
- forum_nav_vocabulary
|
||||
source_module: forum
|
||||
process:
|
||||
'block/active/limit': forum_block_num_0
|
||||
'block/new/limit': forum_block_num_1
|
|
@ -2,6 +2,7 @@ id: d7_forum_settings
|
|||
label: Forum configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
|
@ -11,6 +12,7 @@ source:
|
|||
- forum_block_num_active
|
||||
- forum_block_num_new
|
||||
- forum_nav_vocabulary
|
||||
source_module: forum
|
||||
process:
|
||||
'block/active/limit': forum_block_num_active
|
||||
'block/new/limit': forum_block_num_new
|
|
@ -42,6 +42,13 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
|
|||
*/
|
||||
protected $forumManager;
|
||||
|
||||
/**
|
||||
* The taxonomy term storage.
|
||||
*
|
||||
* @var \Drupal\taxonomy\TermStorageInterface
|
||||
*/
|
||||
protected $termStorage;
|
||||
|
||||
/**
|
||||
* Constructs a forum breadcrumb builder object.
|
||||
*
|
||||
|
@ -59,6 +66,7 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
|
|||
$this->config = $config_factory->get('forum.settings');
|
||||
$this->forumManager = $forum_manager;
|
||||
$this->setStringTranslation($string_translation);
|
||||
$this->termStorage = $entity_manager->getStorage('taxonomy_term');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ class ForumListingBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
|||
$term_id = $term->id();
|
||||
$breadcrumb->addCacheableDependency($term);
|
||||
|
||||
$parents = $this->forumManager->getParents($term_id);
|
||||
$parents = $this->termStorage->loadAllParents($term_id);
|
||||
if ($parents) {
|
||||
foreach (array_reverse($parents) as $parent) {
|
||||
if ($parent->id() != $term_id) {
|
||||
|
|
|
@ -26,7 +26,7 @@ class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
|||
$breadcrumb = parent::build($route_match);
|
||||
$breadcrumb->addCacheContexts(['route']);
|
||||
|
||||
$parents = $this->forumManager->getParents($route_match->getParameter('node')->forum_tid);
|
||||
$parents = $this->termStorage->loadAllParents($route_match->getParameter('node')->forum_tid);
|
||||
if ($parents) {
|
||||
$parents = array_reverse($parents);
|
||||
foreach ($parents as $parent) {
|
||||
|
|
|
@ -6,6 +6,8 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
|
||||
/**
|
||||
* Base form for container term edit forms.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ContainerForm extends ForumForm {
|
||||
|
||||
|
@ -20,9 +22,8 @@ class ContainerForm extends ForumForm {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$taxonomy_term = $this->entity;
|
||||
// Build the bulk of the form from the parent forum form.
|
||||
$form = parent::form($form, $form_state, $taxonomy_term);
|
||||
$form = parent::form($form, $form_state);
|
||||
|
||||
// Set the title and description of the name field.
|
||||
$form['name']['#title'] = $this->t('Container name');
|
||||
|
|
|
@ -9,6 +9,8 @@ use Drupal\taxonomy\TermInterface;
|
|||
|
||||
/**
|
||||
* Builds the form to delete a forum term.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DeleteForm extends ConfirmFormBase {
|
||||
|
||||
|
@ -61,7 +63,7 @@ class DeleteForm extends ConfirmFormBase {
|
|||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->taxonomyTerm->delete();
|
||||
drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', ['%label' => $this->taxonomyTerm->label()]));
|
||||
$this->messenger()->addStatus($this->t('The forum %label and all sub-forums have been deleted.', ['%label' => $this->taxonomyTerm->label()]));
|
||||
$this->logger('forum')->notice('forum: deleted %label and all its sub-forums.', ['%label' => $this->taxonomyTerm->label()]);
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ use Drupal\taxonomy\TermForm;
|
|||
|
||||
/**
|
||||
* Base form for forum term edit forms.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ForumForm extends TermForm {
|
||||
|
||||
|
@ -29,9 +31,8 @@ class ForumForm extends TermForm {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$taxonomy_term = $this->entity;
|
||||
// Build the bulk of the form from the parent taxonomy term form.
|
||||
$form = parent::form($form, $form_state, $taxonomy_term);
|
||||
$form = parent::form($form, $form_state);
|
||||
|
||||
// Set the title and description of the name field.
|
||||
$form['name']['#title'] = $this->t('Forum name');
|
||||
|
@ -48,7 +49,7 @@ class ForumForm extends TermForm {
|
|||
|
||||
// Our parent field is different to the taxonomy term.
|
||||
$form['parent']['#tree'] = TRUE;
|
||||
$form['parent'][0] = $this->forumParentSelect($taxonomy_term->id(), $this->t('Parent'));
|
||||
$form['parent'][0] = $this->forumParentSelect($this->entity->id(), $this->t('Parent'));
|
||||
|
||||
$form['#theme_wrappers'] = ['form__forum'];
|
||||
$this->forumFormType = $this->t('forum');
|
||||
|
@ -76,18 +77,18 @@ class ForumForm extends TermForm {
|
|||
$status = $term_storage->save($term);
|
||||
|
||||
$route_name = $this->urlStub == 'container' ? 'entity.taxonomy_term.forum_edit_container_form' : 'entity.taxonomy_term.forum_edit_form';
|
||||
$route_parameters = ['taxonomy_term' => $term->id()];
|
||||
$route_parameters = ['taxonomy_term' => $term->id()];
|
||||
$link = $this->l($this->t('Edit'), new Url($route_name, $route_parameters));
|
||||
$view_link = $term->link($term->getName());
|
||||
switch ($status) {
|
||||
case SAVED_NEW:
|
||||
drupal_set_message($this->t('Created new @type %term.', ['%term' => $view_link, '@type' => $this->forumFormType]));
|
||||
$this->messenger()->addStatus($this->t('Created new @type %term.', ['%term' => $view_link, '@type' => $this->forumFormType]));
|
||||
$this->logger('forum')->notice('Created new @type %term.', ['%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link]);
|
||||
$form_state->setValue('tid', $term->id());
|
||||
break;
|
||||
|
||||
case SAVED_UPDATED:
|
||||
drupal_set_message($this->t('The @type %term has been updated.', ['%term' => $term->getName(), '@type' => $this->forumFormType]));
|
||||
$this->messenger()->addStatus($this->t('The @type %term has been updated.', ['%term' => $term->getName(), '@type' => $this->forumFormType]));
|
||||
$this->logger('forum')->notice('Updated @type %term.', ['%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link]);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,13 @@ use Drupal\Core\Render\Element;
|
|||
use Drupal\Core\Url;
|
||||
use Drupal\taxonomy\Form\OverviewTerms;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\taxonomy\VocabularyInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Provides forum overview form for the forum vocabulary.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Overview extends OverviewTerms {
|
||||
|
||||
|
@ -45,7 +48,7 @@ class Overview extends OverviewTerms {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
public function buildForm(array $form, FormStateInterface $form_state, VocabularyInterface $taxonomy_vocabulary = NULL) {
|
||||
$forum_config = $this->config('forum.settings');
|
||||
$vid = $forum_config->get('vocabulary');
|
||||
$vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($vid);
|
||||
|
@ -58,21 +61,30 @@ class Overview extends OverviewTerms {
|
|||
|
||||
foreach (Element::children($form['terms']) as $key) {
|
||||
if (isset($form['terms'][$key]['#term'])) {
|
||||
/** @var \Drupal\taxonomy\TermInterface $term */
|
||||
$term = $form['terms'][$key]['#term'];
|
||||
$form['terms'][$key]['term']['#url'] = Url::fromRoute('forum.page', ['taxonomy_term' => $term->id()]);
|
||||
unset($form['terms'][$key]['operations']['#links']['delete']);
|
||||
$route_parameters = $form['terms'][$key]['operations']['#links']['edit']['url']->getRouteParameters();
|
||||
|
||||
if (!empty($term->forum_container->value)) {
|
||||
$form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit container');
|
||||
$form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_container_form', $route_parameters);
|
||||
$title = $this->t('edit container');
|
||||
$url = Url::fromRoute('entity.taxonomy_term.forum_edit_container_form', ['taxonomy_term' => $term->id()]);
|
||||
}
|
||||
else {
|
||||
$form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit forum');
|
||||
$form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_form', $route_parameters);
|
||||
$title = $this->t('edit forum');
|
||||
$url = Url::fromRoute('entity.taxonomy_term.forum_edit_form', ['taxonomy_term' => $term->id()]);
|
||||
}
|
||||
// We don't want the redirect from the link so we can redirect the
|
||||
// delete action.
|
||||
unset($form['terms'][$key]['operations']['#links']['edit']['query']['destination']);
|
||||
|
||||
// Re-create the operations column and add only the edit link.
|
||||
$form['terms'][$key]['operations'] = [
|
||||
'#type' => 'operations',
|
||||
'#links' => [
|
||||
'edit' => [
|
||||
'title' => $title,
|
||||
'url' => $url,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +94,7 @@ class Overview extends OverviewTerms {
|
|||
// Use the existing taxonomy overview submit handler.
|
||||
$form['terms']['#empty'] = $this->t('No containers or forums available. <a href=":container">Add container</a> or <a href=":forum">Add forum</a>.', [
|
||||
':container' => $this->url('forum.add_container'),
|
||||
':forum' => $this->url('forum.add_forum')
|
||||
':forum' => $this->url('forum.add_forum'),
|
||||
]);
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\forum;
|
||||
|
||||
use Drupal\comment\CommentInterface;
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\node\NodeInterface;
|
||||
|
@ -103,7 +104,7 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
|
|||
':status' => CommentInterface::PUBLISHED,
|
||||
])->fetchObject();
|
||||
$this->database->update('forum_index')
|
||||
->fields( [
|
||||
->fields([
|
||||
'comment_count' => $count,
|
||||
'last_comment_timestamp' => $last_reply->created,
|
||||
])
|
||||
|
@ -114,7 +115,7 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
|
|||
// Comments do not exist.
|
||||
// @todo This should be actually filtering on the desired node language
|
||||
$this->database->update('forum_index')
|
||||
->fields( [
|
||||
->fields([
|
||||
'comment_count' => 0,
|
||||
'last_comment_timestamp' => $node->getCreatedTime(),
|
||||
])
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace Drupal\forum;
|
|||
|
||||
use Drupal\node\NodeInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Handles CRUD operations to {forum_index} table.
|
||||
*/
|
||||
|
|
|
@ -184,7 +184,7 @@ class ForumManager implements ForumManagerInterface {
|
|||
'cid',
|
||||
'last_comment_uid',
|
||||
'last_comment_timestamp',
|
||||
'comment_count'
|
||||
'comment_count',
|
||||
]);
|
||||
|
||||
$query->join('forum_index', 'f', 'f.nid = n.nid');
|
||||
|
@ -435,7 +435,7 @@ class ForumManager implements ForumManagerInterface {
|
|||
'container' => 1,
|
||||
'parents' => [],
|
||||
'isIndex' => TRUE,
|
||||
'vid' => $vid
|
||||
'vid' => $vid,
|
||||
]);
|
||||
|
||||
// Load the tree below.
|
||||
|
|
|
@ -7,6 +7,8 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
|
||||
/**
|
||||
* Configure forum settings for this site.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ForumSettingsForm extends ConfigFormBase {
|
||||
|
||||
|
@ -50,7 +52,7 @@ class ForumSettingsForm extends ConfigFormBase {
|
|||
1 => $this->t('Date - newest first'),
|
||||
2 => $this->t('Date - oldest first'),
|
||||
3 => $this->t('Posts - most active first'),
|
||||
4 => $this->t('Posts - least active first')
|
||||
4 => $this->t('Posts - least active first'),
|
||||
];
|
||||
$form['forum_order'] = [
|
||||
'#type' => 'radios',
|
||||
|
|
|
@ -62,12 +62,12 @@ class ForumUninstallValidator implements ModuleUninstallValidatorInterface {
|
|||
if ($vocabulary->access('view')) {
|
||||
$reasons[] = $this->t('To uninstall Forum, first delete all <a href=":url">%vocabulary</a> terms', [
|
||||
'%vocabulary' => $vocabulary->label(),
|
||||
':url' => $vocabulary->url('overview-form'),
|
||||
':url' => $vocabulary->toUrl('overview-form')->toString(),
|
||||
]);
|
||||
}
|
||||
else {
|
||||
$reasons[] = $this->t('To uninstall Forum, first delete all %vocabulary terms', [
|
||||
'%vocabulary' => $vocabulary->label()
|
||||
'%vocabulary' => $vocabulary->label(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Available variables:
|
||||
* - forums: The forums to display (as processed by forum-list.html.twig).
|
||||
* - topics: The topics to display.
|
||||
* - topics_original: Original topics data before modification.
|
||||
* - topics_pager: The topics pager.
|
||||
* - forums_defined: A flag to indicate that the forums are configured.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\forum\Tests\Views;
|
||||
namespace Drupal\Tests\forum\Functional\Views;
|
||||
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
|
||||
/**
|
||||
|
@ -28,13 +28,12 @@ class ForumIntegrationTest extends ViewTestBase {
|
|||
*/
|
||||
public static $testViews = ['test_forum_index'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), ['forum_test_views']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the integration.
|
||||
*/
|
||||
|
@ -72,17 +71,17 @@ class ForumIntegrationTest extends ViewTestBase {
|
|||
$expected_result[] = [
|
||||
'nid' => $nodes[0]->id(),
|
||||
'sticky' => NodeInterface::STICKY,
|
||||
'comment_count' => 1.
|
||||
'comment_count' => 1.,
|
||||
];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[1]->id(),
|
||||
'sticky' => NodeInterface::NOT_STICKY,
|
||||
'comment_count' => 2.
|
||||
'comment_count' => 2.,
|
||||
];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[2]->id(),
|
||||
'sticky' => NodeInterface::NOT_STICKY,
|
||||
'comment_count' => 3.
|
||||
'comment_count' => 3.,
|
||||
];
|
||||
$column_map = [
|
||||
'nid' => 'nid',
|
|
@ -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