updated core from 8.4 to 8.5 : bug with login_destination
This commit is contained in:
+3
-3
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- comment
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457826
|
||||
|
||||
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- comment
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457826
|
||||
|
||||
@@ -8,8 +8,8 @@ dependencies:
|
||||
- comment
|
||||
- views
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457826
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\comment\Functional;
|
||||
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests comment administration and preview access.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentAccessTest extends BrowserTestBase {
|
||||
|
||||
use CommentTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'node',
|
||||
'comment',
|
||||
];
|
||||
|
||||
/**
|
||||
* Node for commenting.
|
||||
*
|
||||
* @var \Drupal\node\NodeInterface
|
||||
*/
|
||||
protected $unpublishedNode;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$node_type = NodeType::create([
|
||||
'type' => 'article',
|
||||
'name' => 'Article',
|
||||
]);
|
||||
$node_type->save();
|
||||
$node_author = $this->drupalCreateUser([
|
||||
'create article content',
|
||||
'access comments',
|
||||
]);
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser([
|
||||
'edit own comments',
|
||||
'skip comment approval',
|
||||
'post comments',
|
||||
'access comments',
|
||||
'access content',
|
||||
]));
|
||||
|
||||
$this->addDefaultCommentField('node', 'article');
|
||||
$this->unpublishedNode = $this->createNode([
|
||||
'title' => 'This is unpublished',
|
||||
'uid' => $node_author->id(),
|
||||
'status' => 0,
|
||||
'type' => 'article',
|
||||
]);
|
||||
$this->unpublishedNode->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests commenting disabled for access-blocked entities.
|
||||
*/
|
||||
public function testCannotCommentOnEntitiesYouCannotView() {
|
||||
$assert = $this->assertSession();
|
||||
|
||||
$comment_url = 'comment/reply/node/' . $this->unpublishedNode->id() . '/comment';
|
||||
|
||||
// Commenting on an unpublished node results in access denied.
|
||||
$this->drupalGet($comment_url);
|
||||
$assert->statusCodeEquals(403);
|
||||
|
||||
// Publishing the node grants access.
|
||||
$this->unpublishedNode->setPublished(TRUE)->save();
|
||||
$this->drupalGet($comment_url);
|
||||
$assert->statusCodeEquals(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests cannot view comment reply form on entities you cannot view.
|
||||
*/
|
||||
public function testCannotViewCommentReplyFormOnEntitiesYouCannotView() {
|
||||
$assert = $this->assertSession();
|
||||
|
||||
// Create a comment on an unpublished node.
|
||||
$comment = Comment::create([
|
||||
'entity_type' => 'node',
|
||||
'name' => 'Tony',
|
||||
'hostname' => 'magic.example.com',
|
||||
'mail' => 'foo@example.com',
|
||||
'subject' => 'Comment on unpublished node',
|
||||
'entity_id' => $this->unpublishedNode->id(),
|
||||
'comment_type' => 'comment',
|
||||
'field_name' => 'comment',
|
||||
'pid' => 0,
|
||||
'uid' => $this->unpublishedNode->getOwnerId(),
|
||||
'status' => 1,
|
||||
]);
|
||||
$comment->save();
|
||||
|
||||
$comment_url = 'comment/reply/node/' . $this->unpublishedNode->id() . '/comment/' . $comment->id();
|
||||
|
||||
// Replying to a comment on an unpublished node results in access denied.
|
||||
$this->drupalGet($comment_url);
|
||||
$assert->statusCodeEquals(403);
|
||||
|
||||
// Publishing the node grants access.
|
||||
$this->unpublishedNode->setPublished(TRUE)->save();
|
||||
$this->drupalGet($comment_url);
|
||||
$assert->statusCodeEquals(200);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class CommentActionsTest extends CommentTestBase {
|
||||
$action = Action::load('comment_unpublish_action');
|
||||
$action->execute([$comment]);
|
||||
$this->assertTrue($comment->isPublished() === FALSE, 'Comment was unpublished');
|
||||
|
||||
$this->assertArraySubset(['module' => ['comment']], $action->getDependencies());
|
||||
// Publish a comment.
|
||||
$action = Action::load('comment_publish_action');
|
||||
$action->execute([$comment]);
|
||||
|
||||
@@ -450,6 +450,7 @@ class CommentNonNodeTest extends BrowserTestBase {
|
||||
'post comments',
|
||||
'administer comment fields',
|
||||
'administer comment types',
|
||||
'view test entity',
|
||||
]);
|
||||
$this->drupalLogin($limited_user);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class CommentPreviewTest extends CommentTestBase {
|
||||
|
||||
// Add a user picture.
|
||||
$image = current($this->drupalGetTestFiles('image'));
|
||||
$user_edit['files[user_picture_0]'] = drupal_realpath($image->uri);
|
||||
$user_edit['files[user_picture_0]'] = \Drupal::service('file_system')->realpath($image->uri);
|
||||
$this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $user_edit, t('Save'));
|
||||
|
||||
// As the web user, fill in the comment form and preview the comment.
|
||||
@@ -117,6 +117,8 @@ class CommentPreviewTest extends CommentTestBase {
|
||||
|
||||
// Go back and re-submit the form.
|
||||
$this->getSession()->getDriver()->back();
|
||||
$submit_button = $this->assertSession()->buttonExists('Save');
|
||||
$submit_button->click();
|
||||
$this->assertText('Your comment has been posted.');
|
||||
$elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article');
|
||||
$this->assertEqual(2, count($elements));
|
||||
|
||||
@@ -144,6 +144,7 @@ class CommentTokenReplaceTest extends CommentTestBase {
|
||||
|
||||
// Create a user and a comment.
|
||||
$user = User::create(['name' => 'alice']);
|
||||
$user->activate();
|
||||
$user->save();
|
||||
$this->postComment($user, 'user body', 'user subject', TRUE);
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\comment\Kernel;
|
||||
|
||||
use Drupal\comment\Entity\CommentType;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests that comment bundles behave as expected.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentBundlesTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['comment', 'node', 'taxonomy', 'user'];
|
||||
|
||||
/**
|
||||
* Entity type ids to use for target_entity_type_id on comment bundles.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $targetEntityTypes;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
|
||||
*/
|
||||
protected $entityFieldManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->entityFieldManager = $this->container->get('entity_field.manager');
|
||||
|
||||
$this->installEntitySchema('comment');
|
||||
|
||||
// Create multiple comment bundles,
|
||||
// each of which has a different target entity type.
|
||||
$this->targetEntityTypes = [
|
||||
'comment' => 'Comment',
|
||||
'node' => 'Node',
|
||||
'taxonomy_term' => 'Taxonomy Term',
|
||||
];
|
||||
foreach ($this->targetEntityTypes as $id => $label) {
|
||||
CommentType::create([
|
||||
'id' => 'comment_on_' . $id,
|
||||
'label' => 'Comment on ' . $label,
|
||||
'target_entity_type_id' => $id,
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the entity_id field is set correctly for each comment bundle.
|
||||
*/
|
||||
public function testEntityIdField() {
|
||||
$field_definitions = [];
|
||||
|
||||
foreach (array_keys($this->targetEntityTypes) as $id) {
|
||||
$bundle = 'comment_on_' . $id;
|
||||
$field_definitions[$bundle] = $this->entityFieldManager
|
||||
->getFieldDefinitions('comment', $bundle);
|
||||
}
|
||||
// Test that the value of the entity_id field for each bundle is correct.
|
||||
foreach ($field_definitions as $bundle => $definition) {
|
||||
$entity_type_id = str_replace('comment_on_', '', $bundle);
|
||||
$target_type = $definition['entity_id']->getSetting('target_type');
|
||||
$this->assertEquals($entity_type_id, $target_type);
|
||||
|
||||
// Verify that the target type remains correct
|
||||
// in the deeply-nested object properties.
|
||||
$nested_target_type = $definition['entity_id']->getItemDefinition()->getFieldDefinition()->getSetting('target_type');
|
||||
$this->assertEquals($entity_type_id, $nested_target_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\Tests\comment\Kernel\Migrate;
|
||||
|
||||
use Drupal\comment\Entity\CommentType;
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
|
||||
use Drupal\migrate_drupal\Tests\StubTestTrait;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
@@ -29,6 +28,8 @@ class MigrateCommentStubTest extends MigrateDrupalTestBase {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('comment');
|
||||
$this->installEntitySchema('node');
|
||||
$this->installSchema('system', ['sequences']);
|
||||
|
||||
// Make sure uid 0 is created (default uid for comments is 0).
|
||||
$storage = \Drupal::entityManager()->getStorage('user');
|
||||
// Insert a row for the anonymous user.
|
||||
@@ -55,18 +56,6 @@ class MigrateCommentStubTest extends MigrateDrupalTestBase {
|
||||
* Tests creation of comment stubs.
|
||||
*/
|
||||
public function testStub() {
|
||||
try {
|
||||
// We expect an exception, because there's no node to reference.
|
||||
$this->performStubTest('comment');
|
||||
$this->fail('Expected exception has not been thrown.');
|
||||
}
|
||||
catch (MigrateException $e) {
|
||||
$this->assertIdentical($e->getMessage(),
|
||||
'Stubbing failed, unable to generate value for field entity_id');
|
||||
}
|
||||
|
||||
// The stub should pass when there's a node to point to.
|
||||
$this->createStub('node');
|
||||
$this->performStubTest('comment');
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
||||
*/
|
||||
protected function getMockNode($has_field, $comment_status, $form_location, $comment_count) {
|
||||
$node = $this->getMock('\Drupal\node\NodeInterface');
|
||||
$node->expects($this->once())
|
||||
$node->expects($this->any())
|
||||
->method('hasField')
|
||||
->willReturn($has_field);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user