update drupal
This commit is contained in:
@@ -7,6 +7,7 @@ use Drupal\comment\CommentInterface;
|
||||
use Drupal\comment\CommentManagerInterface;
|
||||
use Drupal\Tests\comment\Functional\CommentTestBase;
|
||||
use Drupal\Tests\rdf\Traits\RdfParsingTrait;
|
||||
use Drupal\user\Entity\User;
|
||||
use Drupal\user\RoleInterface;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
|
||||
@@ -24,7 +25,7 @@ class CommentAttributesTest extends CommentTestBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['views', 'node', 'comment', 'rdf'];
|
||||
public static $modules = ['views', 'node', 'comment', 'rdf', 'user_hooks_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -148,6 +149,9 @@ class CommentAttributesTest extends CommentTestBase {
|
||||
* Tests comment author link markup has not been broken by RDF.
|
||||
*/
|
||||
public function testCommentRdfAuthorMarkup() {
|
||||
// Set to test the altered display name.
|
||||
\Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
|
||||
|
||||
// Post a comment as a registered user.
|
||||
$this->saveComment($this->node->id(), $this->webUser->id());
|
||||
|
||||
@@ -158,7 +162,7 @@ class CommentAttributesTest extends CommentTestBase {
|
||||
// Ensure that the author link still works properly after the author output
|
||||
// is modified by the RDF module.
|
||||
$this->drupalGet('node/' . $this->node->id());
|
||||
$this->assertSession()->linkExists($this->webUser->getAccountName());
|
||||
$this->assertSession()->linkExistsExact($this->webUser->getDisplayName());
|
||||
$this->assertLinkByHref('user/' . $this->webUser->id());
|
||||
}
|
||||
|
||||
@@ -169,6 +173,9 @@ class CommentAttributesTest extends CommentTestBase {
|
||||
* on comments from registered and anonymous users.
|
||||
*/
|
||||
public function testCommentRdfaMarkup() {
|
||||
// Set to test the altered display name.
|
||||
\Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
|
||||
|
||||
// Posts comment #1 on behalf of registered user.
|
||||
$comment1 = $this->saveComment($this->node->id(), $this->webUser->id());
|
||||
|
||||
@@ -187,12 +194,13 @@ class CommentAttributesTest extends CommentTestBase {
|
||||
$anonymous_user['homepage'] = 'http://example.org/';
|
||||
$comment2 = $this->saveComment($this->node->id(), 0, $anonymous_user);
|
||||
|
||||
$anonymous = User::load(0);
|
||||
// Tests comment #2 as anonymous user.
|
||||
$this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user);
|
||||
$this->_testBasicCommentRdfaMarkup($comment2, $anonymous);
|
||||
|
||||
// Tests comment #2 as logged in user.
|
||||
$this->drupalLogin($this->webUser);
|
||||
$this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user);
|
||||
$this->_testBasicCommentRdfaMarkup($comment2, $anonymous);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +248,7 @@ class CommentAttributesTest extends CommentTestBase {
|
||||
* @param $account
|
||||
* An array containing information about an anonymous user.
|
||||
*/
|
||||
public function _testBasicCommentRdfaMarkup(CommentInterface $comment, $account = []) {
|
||||
public function _testBasicCommentRdfaMarkup(CommentInterface $comment, $account = NULL) {
|
||||
$this->drupalGet($this->node->toUrl());
|
||||
$comment_uri = $comment->toUrl('canonical', ['absolute' => TRUE])->toString();
|
||||
|
||||
@@ -303,7 +311,7 @@ class CommentAttributesTest extends CommentTestBase {
|
||||
}
|
||||
|
||||
// Author name.
|
||||
$name = empty($account["name"]) ? $this->webUser->getAccountName() : $account["name"] . " (not verified)";
|
||||
$name = $account ? $account->getDisplayName() . " (not verified)" : $this->webUser->getDisplayName();
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $name,
|
||||
|
||||
@@ -61,7 +61,7 @@ class GetRdfNamespacesTest extends BrowserTestBase {
|
||||
$this->fail('Expected exception not thrown for conflicting namespace declaration.');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Expected exception thrown: ' . $e->getMessage());
|
||||
// Expected exception; just continue testing.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class UserAttributesTest extends BrowserTestBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['rdf', 'node'];
|
||||
public static $modules = ['rdf', 'node', 'user_hooks_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -47,6 +47,9 @@ class UserAttributesTest extends BrowserTestBase {
|
||||
|
||||
// Prepares commonly used URIs.
|
||||
$this->baseUri = Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString();
|
||||
|
||||
// Set to test the altered display name.
|
||||
\Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +90,7 @@ class UserAttributesTest extends BrowserTestBase {
|
||||
// User name.
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $author->getAccountName(),
|
||||
'value' => $author->getDisplayName(),
|
||||
];
|
||||
$this->assertTrue($this->hasRdfProperty($this->getSession()->getPage()->getContent(), $this->baseUri, $account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).');
|
||||
|
||||
@@ -108,7 +111,7 @@ class UserAttributesTest extends BrowserTestBase {
|
||||
// User name.
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $author->getAccountName(),
|
||||
'value' => $author->getDisplayName(),
|
||||
];
|
||||
$this->assertTrue($this->hasRdfProperty($this->getSession()->getPage()->getContent(), $this->baseUri, $account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\rdf\Kernel;
|
||||
|
||||
use Drupal\Core\Field\FieldItemList;
|
||||
use Drupal\Core\Field\Plugin\Field\FieldType\CreatedItem;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
|
||||
/**
|
||||
* Tests rdf_comment_storage_load.
|
||||
*
|
||||
* @group rdf
|
||||
*/
|
||||
class RdfCommentStorageLoadTest extends EntityKernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['comment', 'rdf'];
|
||||
|
||||
/**
|
||||
* Tests rdf_comment_storage_load.
|
||||
*/
|
||||
public function testRdfCommentStorageLoad() {
|
||||
$field_created_item = $this->prophesize(CreatedItem::class);
|
||||
$field_created_item->setValue([time()]);
|
||||
|
||||
$field_list = $this->prophesize(FieldItemList::class);
|
||||
$field_list->reveal();
|
||||
$field_list->first()->willReturn($field_created_item->reveal());
|
||||
|
||||
$comment = $this->prophesize(Comment::class);
|
||||
$comment->bundle()->willReturn('page');
|
||||
$comment->get('created')->willReturn($field_list);
|
||||
$comment->getFieldDefinitions()->willReturn(NULL);
|
||||
// Set commented entity and parent entity to NULL.
|
||||
$comment->getCommentedEntity()->willReturn(NULL);
|
||||
$comment->getParentComment()->willReturn(NULL);
|
||||
|
||||
/** @var \Drupal\Core\Extension\ModuleHandler $module_handler */
|
||||
$module_handler = \Drupal::service('module_handler');
|
||||
$module_handler->invoke('rdf', 'comment_storage_load', [[$comment->reveal()]]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user