Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Status: Active » Needs review
FileSize
120.42 KB

Here's a start on the comment test. I have removed the rdf_test module from the requirements because this seems to be testing the default mappings, not those set in rdf_test.

EDIT: Gah, wrong patch!

Status: Needs review » Needs work

The last submitted patch, 1886108-01-comment-test.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
5.01 KB

Ok, this is the one that should be tested.

Status: Needs review » Needs work

The last submitted patch, 1886108-02-comment-test.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
6.79 KB

This removes the dependency on standard profile. I've only adapted the first test in the file, so the other tests are temporarily commented out.

Anonymous’s picture

Actually, that one won't quite work.

Status: Needs review » Needs work

The last submitted patch, 1886108-06-comment-test.patch, failed testing.

scor’s picture

Status: Needs work » Needs review
FileSize
18.37 KB

good job Lin on removing the dependency on standard profile. I had to grant the permission 'skip comment approval' to the web_user to reflect the standard profile. Otherwise, converted all XPaths to easyrdf based tests.

scor’s picture

removed a few lone $this->drupalGet() which were no longer necessary and fixed the url for parsing comment on a full node.

Status: Needs review » Needs work

The last submitted patch, 1886108-09-comment-test.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review

#9: 1886108-09-comment-test.patch queued for re-testing.

Anonymous’s picture

Status: Needs review » Needs work

That fail seems like a testbot glitch to me.

These changes make the test much clearer, which is great.

+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.phpundefined
@@ -41,8 +32,8 @@ public static function getInfo() {
+    $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer permissions'));
+    $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'create article content', 'access user profiles'));

We should look at which permissions are actually necessary for what the users currently do. I feel like some might not be required anymore.

+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.phpundefined
@@ -70,21 +61,38 @@ public function setUp() {
+    $comment1 = $this->saveComment($this->node1->nid, $this->web_user->uid);
+    $comment2 = $this->saveComment($this->node1->nid, $this->web_user->uid);

We don't end up using the comments that are returned here, so might as well not store them.

+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.phpundefined
@@ -70,21 +61,38 @@ public function setUp() {
+    $expected_value = array(
+      'type' => 'literal',
+      'value' => 2,
+      'datatype' => 'http://www.w3.org/2001/XMLSchema#integer',
+    );

Why is the expected value array duplicated here?

+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.phpundefined
@@ -100,15 +108,21 @@ public function testCommentRdfaMarkup() {
+    $base_uri = url('<front>', array('absolute' => TRUE));

Maybe we can move the assignment of base uri and node URIs to setup?

+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.phpundefined
@@ -118,27 +132,20 @@ public function testCommentRdfaMarkup() {
     $comment2 = $this->postComment($this->node2, $comment2_body, $comment2_subject, $anonymous_user);

We should probably be consistent and use saveComment across the board.

+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.phpundefined
@@ -118,27 +132,20 @@ public function testCommentRdfaMarkup() {
+    $comment2_uri = url('comment/' . $comment2->id(), array('fragment' => 'comment-' . $comment2->id(), 'absolute' => TRUE));

Variable isn't used.

+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.phpundefined
@@ -177,18 +199,99 @@ public function testCommentReplyOfRdfaMarkup() {
     $name = empty($account["name"]) ? $this->web_user->name : $account["name"] . " (not verified)";

It seems that this name variable is no longer used. It is set later, directly before it is used.

+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.phpundefined
@@ -177,18 +199,99 @@ public function testCommentReplyOfRdfaMarkup() {
+
+  function saveComment($nid, $uid) {

Needs documentation.

scor’s picture

Status: Needs work » Needs review
FileSize
10.8 KB
19.74 KB

thanks for the thorough review. this patch should address all remarks.
- remove $node2 since we can just as well use node1 to post the comment #2.
- $comment2_uri is definitely being used (6th remark).

scor’s picture

I actually forgot to cover the first remark of #12, and while doing that I was able to trim down the code even more! remove all our custom users and node1, which are all available via CommentTestBase.

Anonymous’s picture

Status: Needs review » Needs work

Great!

$comment2_uri is definitely being used (6th remark).

I'm pretty sure the comment2_uri on line 118 is not being used.

scor’s picture

Status: Needs work » Needs review
+    $comment_2_uri = url('comment/' . $comment_2->id(), array('fragment' => 'comment-' . $comment_2->id(), 'absolute' => TRUE));
...
+    $this->assertTrue($graph->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
...
+    $this->assertTrue($graph->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its parent comment found in RDF output (sioc:reply_of).');
Anonymous’s picture

Status: Needs review » Needs work

Right, look for comment2_uri in the function above, not comment_2_uri. I only notice this because PhpStorm tells me it is so :-P

scor’s picture

Status: Needs work » Needs review
FileSize
1.98 KB
19.7 KB

I was looking for the wrong var :\ - in chatting on IRC, Lin and I found more unused variables, which are fixed in this patch, along with some other minor docs improvments.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

This will speed up the RDF tests by removing the dependency on standard profile and will also make them more reliable since we actually parse the RDFa now.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks! :D

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.