]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - tests/ActivityGenerationTests.php
Merge branch 'master' into testing
[quix0rs-gnu-social.git] / tests / ActivityGenerationTests.php
index cc82151b99cebc908935b992ab00d3b4da422d8c..8cf1b009ed6ed5379e98d68c6d0e50f5b6d20a52 100644 (file)
@@ -165,7 +165,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
         $this->assertEquals($atomUrl, ActivityUtils::childContent($source, 'id'));
         $this->assertEquals($atomUrl, ActivityUtils::getLink($source, 'self', 'application/atom+xml'));
         $this->assertEquals($profile->profileurl, ActivityUtils::getPermalink($source));
-        $this->assertEquals($notice2->created, strtotime(ActivityUtils::childContent($source, 'updated')));
+        $this->assertEquals(strtotime($notice2->created), strtotime(ActivityUtils::childContent($source, 'updated')));
         // XXX: do we care here?
         $this->assertFalse(is_null(ActivityUtils::childContent($source, 'title')));
         $this->assertEquals(common_config('license', 'url'), ActivityUtils::getLink($source, 'license'));
@@ -194,7 +194,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
         $actor  = ActivityUtils::child($element, 'actor', Activity::SPEC);
 
         $this->assertFalse(is_null($author));
-        $this->assertFalse(is_null($actor));
+        $this->assertTrue(is_null($actor)); // <activity:actor> is obsolete, no longer added
     }
 
     public function testAuthorContent()
@@ -208,12 +208,29 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
         $element = $this->_entryToElement($entry, true);
 
         $author = ActivityUtils::child($element, 'author');
-        $actor  = ActivityUtils::child($element, 'actor', Activity::SPEC);
 
         $this->assertEquals($this->author1->nickname, ActivityUtils::childContent($author, 'name'));
         $this->assertEquals($this->author1->uri, ActivityUtils::childContent($author, 'uri'));
     }
 
+    /**
+     * We no longer create <activity:actor> entries, they have merged to <atom:author>
+     */
+    public function testActorContent()
+    {
+        $notice = $this->_fakeNotice();
+
+        // Test with author
+
+        $entry = $notice->asAtomEntry(false, false, true);
+
+        $element = $this->_entryToElement($entry, true);
+
+        $actor = ActivityUtils::child($element, 'actor', Activity::SPEC);
+
+        $this->assertEquals($actor, null);
+    }
+
     public function testReplyLink()
     {
         $orig = $this->_fakeNotice($this->targetUser1);
@@ -246,6 +263,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
         $element = $this->_entryToElement($entry, true);
 
         $this->assertEquals($this->targetUser1->uri, ActivityUtils::getLink($element, 'ostatus:attention'));
+        $this->assertEquals($this->targetUser1->uri, ActivityUtils::getLink($element, 'mentioned'));
     }
 
     public function testMultipleReplyAttention()
@@ -276,6 +294,19 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
         $this->assertTrue(in_array($this->targetUser1->uri, $hrefs));
         $this->assertTrue(in_array($this->targetUser2->uri, $hrefs));
+
+        $links = ActivityUtils::getLinks($element, 'mentioned');
+
+        $this->assertEquals(2, count($links));
+
+        $hrefs = array();
+
+        foreach ($links as $link) {
+            $hrefs[] = $link->getAttribute('href');
+        }
+
+        $this->assertTrue(in_array($this->targetUser1->uri, $hrefs));
+        $this->assertTrue(in_array($this->targetUser2->uri, $hrefs));
     }
 
     public function testGroupPostAttention()
@@ -289,6 +320,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
         $element = $this->_entryToElement($entry, true);
 
         $this->assertEquals($this->targetGroup1->uri, ActivityUtils::getLink($element, 'ostatus:attention'));
+        $this->assertEquals($this->targetGroup1->uri, ActivityUtils::getLink($element, 'mentioned'));
     }
 
     public function testMultipleGroupPostAttention()
@@ -313,6 +345,19 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
         $this->assertTrue(in_array($this->targetGroup1->uri, $hrefs));
         $this->assertTrue(in_array($this->targetGroup2->uri, $hrefs));
+
+        $links = ActivityUtils::getLinks($element, 'mentioned');
+
+        $this->assertEquals(2, count($links));
+
+        $hrefs = array();
+
+        foreach ($links as $link) {
+            $hrefs[] = $link->getAttribute('href');
+        }
+
+        $this->assertTrue(in_array($this->targetGroup1->uri, $hrefs));
+        $this->assertTrue(in_array($this->targetGroup2->uri, $hrefs));
     }
 
     public function testRepeatLink()