]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - tests/ActivityGenerationTests.php
Replace common_good_random with common_random_hexstr
[quix0rs-gnu-social.git] / tests / ActivityGenerationTests.php
index b9e74a570ae141f7b3337683223a2c8be449a556..30e400e77b554457142e728676b41878faf3317f 100644 (file)
@@ -8,7 +8,8 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
 // XXX: we should probably have some common source for this stuff
 
 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('STATUSNET', true);
+define('GNUSOCIAL', true);
+define('STATUSNET', true);  // compatibility
 
 require_once INSTALLDIR . '/lib/common.php';
 
@@ -27,14 +28,14 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
     {
         parent::__construct();
 
-        $authorNick1 = 'activitygenerationtestsuser' . common_good_rand(4);
-        $authorNick2 = 'activitygenerationtestsuser' . common_good_rand(4);
+        $authorNick1 = 'activitygenerationtestsuser' . common_random_hexstr(4);
+        $authorNick2 = 'activitygenerationtestsuser' . common_random_hexstr(4);
 
-        $targetNick1 = 'activitygenerationteststarget' . common_good_rand(4);
-        $targetNick2 = 'activitygenerationteststarget' . common_good_rand(4);
+        $targetNick1 = 'activitygenerationteststarget' . common_random_hexstr(4);
+        $targetNick2 = 'activitygenerationteststarget' . common_random_hexstr(4);
 
-        $groupNick1 = 'activitygenerationtestsgroup' . common_good_rand(4);
-        $groupNick2 = 'activitygenerationtestsgroup' . common_good_rand(4);
+        $groupNick1 = 'activitygenerationtestsgroup' . common_random_hexstr(4);
+        $groupNick2 = 'activitygenerationtestsgroup' . common_random_hexstr(4);
 
         $this->author1 = User::register(array('nickname' => $authorNick1,
                                               'email' => $authorNick1 . '@example.net',
@@ -194,7 +195,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()
@@ -213,6 +214,9 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
         $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();
@@ -225,15 +229,14 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
         $actor = ActivityUtils::child($element, 'actor', Activity::SPEC);
 
-        $this->assertEquals($this->author1->uri, ActivityUtils::childContent($actor, 'id'));
-        $this->assertEquals($this->author1->nickname, ActivityUtils::childContent($actor, 'title'));
+        $this->assertEquals($actor, null);
     }
 
     public function testReplyLink()
     {
         $orig = $this->_fakeNotice($this->targetUser1);
 
-        $text = "@" . $this->targetUser1->nickname . " reply text " . common_good_rand(4);
+        $text = "@" . $this->targetUser1->nickname . " reply text " . common_random_hexstr(4);
 
         $reply = Notice::saveNew($this->author1->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
 
@@ -252,7 +255,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
     {
         $orig = $this->_fakeNotice($this->targetUser1);
 
-        $text = "@" . $this->targetUser1->nickname . " reply text " . common_good_rand(4);
+        $text = "@" . $this->targetUser1->nickname . " reply text " . common_random_hexstr(4);
 
         $reply = Notice::saveNew($this->author1->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
 
@@ -268,11 +271,11 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
     {
         $orig = $this->_fakeNotice($this->targetUser1);
 
-        $text = "@" . $this->targetUser1->nickname . " reply text " . common_good_rand(4);
+        $text = "@" . $this->targetUser1->nickname . " reply text " . common_random_hexstr(4);
 
         $reply = Notice::saveNew($this->targetUser2->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
 
-        $text = "@" . $this->targetUser1->nickname . " @" . $this->targetUser2->nickname . " reply text " . common_good_rand(4);
+        $text = "@" . $this->targetUser1->nickname . " @" . $this->targetUser2->nickname . " reply text " . common_random_hexstr(4);
 
         $reply2 = Notice::saveNew($this->author1->id, $text, 'test', array('uri' => null, 'reply_to' => $reply->id));
 
@@ -309,7 +312,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
     public function testGroupPostAttention()
     {
-        $text = "!" . $this->targetGroup1->nickname . " reply text " . common_good_rand(4);
+        $text = "!" . $this->targetGroup1->nickname . " reply text " . common_random_hexstr(4);
 
         $notice = Notice::saveNew($this->author1->id, $text, 'test', array('uri' => null));
 
@@ -323,7 +326,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
     public function testMultipleGroupPostAttention()
     {
-        $text = "!" . $this->targetGroup1->nickname . " !" . $this->targetGroup2->nickname . " reply text " . common_good_rand(4);
+        $text = "!" . $this->targetGroup1->nickname . " !" . $this->targetGroup2->nickname . " reply text " . common_random_hexstr(4);
 
         $notice = Notice::saveNew($this->author1->id, $text, 'test', array('uri' => null));
 
@@ -376,7 +379,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
     public function testTag()
     {
-        $tag1 = common_good_rand(4);
+        $tag1 = common_random_hexstr(4);
 
         $notice = $this->_fakeNotice($this->author1, '#' . $tag1);
 
@@ -392,8 +395,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
     public function testMultiTag()
     {
-        $tag1 = common_good_rand(4);
-        $tag2 = common_good_rand(4);
+        $tag1 = common_random_hexstr(4);
+        $tag2 = common_random_hexstr(4);
 
         $notice = $this->_fakeNotice($this->author1, '#' . $tag1 . ' #' . $tag2);
 
@@ -419,7 +422,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
     public function testGeotaggedActivity()
     {
-        $notice = Notice::saveNew($this->author1->id, common_good_rand(4), 'test', array('uri' => null, 'lat' => 45.5, 'lon' => -73.6));
+        $notice = Notice::saveNew($this->author1->id, common_random_hexstr(4), 'test', array('uri' => null, 'lat' => 45.5, 'lon' => -73.6));
 
         $entry = $notice->asAtomEntry();
 
@@ -515,11 +518,11 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
     {
         $orig = $this->_fakeNotice($this->targetUser1);
 
-        $text = "@" . $this->targetUser1->nickname . " reply text " . common_good_rand(4);
+        $text = "@" . $this->targetUser1->nickname . " reply text " . common_random_hexstr(4);
 
         $reply = Notice::saveNew($this->author1->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
 
-        $conv = Conversation::staticGet('id', $reply->conversation);
+        $conv = Conversation::getKV('id', $reply->conversation);
 
         $entry = $reply->asAtomEntry();
 
@@ -562,7 +565,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
         }
 
         if (empty($text)) {
-            $text = "fake-o text-o " . common_good_rand(32);
+            $text = "fake-o text-o " . common_random_hexstr(32);
         }
 
         return Notice::saveNew($user->id, $text, 'test', array('uri' => null));