X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2FActivityGenerationTests.php;h=f5ea3ad442374f308ab6acff43ffd22cd9bfeb65;hb=b53e1439969bfa2c0b551d8cc2fc8fe15652c62a;hp=8cf1b009ed6ed5379e98d68c6d0e50f5b6d20a52;hpb=021fa25e8d0dfc83b69b6e5503a8dd3468575cba;p=quix0rs-gnu-social.git diff --git a/tests/ActivityGenerationTests.php b/tests/ActivityGenerationTests.php index 8cf1b009ed..f5ea3ad442 100644 --- a/tests/ActivityGenerationTests.php +++ b/tests/ActivityGenerationTests.php @@ -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', @@ -80,7 +81,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $element = $this->_entryToElement($entry, false); - $this->assertEquals($notice->uri, ActivityUtils::childContent($element, 'id')); + $this->assertEquals($notice->getUri(), ActivityUtils::childContent($element, 'id')); $this->assertEquals($notice->content, ActivityUtils::childContent($element, 'title')); $this->assertEquals($notice->rendered, ActivityUtils::childContent($element, 'content')); $this->assertEquals(strtotime($notice->created), strtotime(ActivityUtils::childContent($element, 'published'))); @@ -209,8 +210,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $author = ActivityUtils::child($element, 'author'); - $this->assertEquals($this->author1->nickname, ActivityUtils::childContent($author, 'name')); - $this->assertEquals($this->author1->uri, ActivityUtils::childContent($author, 'uri')); + $this->assertEquals($this->author1->getNickname(), ActivityUtils::childContent($author, 'name')); + $this->assertEquals($this->author1->getUri(), ActivityUtils::childContent($author, 'uri')); } /** @@ -235,7 +236,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)); @@ -246,15 +247,15 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $irt = ActivityUtils::child($element, 'in-reply-to', 'http://purl.org/syndication/thread/1.0'); $this->assertNotNull($irt); - $this->assertEquals($orig->uri, $irt->getAttribute('ref')); - $this->assertEquals($orig->bestUrl(), $irt->getAttribute('href')); + $this->assertEquals($orig->getUri(), $irt->getAttribute('ref')); + $this->assertEquals($orig->getUrl(), $irt->getAttribute('href')); } public function testReplyAttention() { $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)); @@ -262,19 +263,18 @@ 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')); + $this->assertEquals($this->targetUser1->getUri(), ActivityUtils::getLink($element, 'mentioned')); } public function testMultipleReplyAttention() { $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)); @@ -282,7 +282,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $element = $this->_entryToElement($entry, true); - $links = ActivityUtils::getLinks($element, 'ostatus:attention'); + $links = ActivityUtils::getLinks($element, 'mentioned'); $this->assertEquals(2, count($links)); @@ -292,8 +292,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $hrefs[] = $link->getAttribute('href'); } - $this->assertTrue(in_array($this->targetUser1->uri, $hrefs)); - $this->assertTrue(in_array($this->targetUser2->uri, $hrefs)); + $this->assertTrue(in_array($this->targetUser1->getUri(), $hrefs)); + $this->assertTrue(in_array($this->targetUser2->getUri(), $hrefs)); $links = ActivityUtils::getLinks($element, 'mentioned'); @@ -305,13 +305,13 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $hrefs[] = $link->getAttribute('href'); } - $this->assertTrue(in_array($this->targetUser1->uri, $hrefs)); - $this->assertTrue(in_array($this->targetUser2->uri, $hrefs)); + $this->assertTrue(in_array($this->targetUser1->getUri(), $hrefs)); + $this->assertTrue(in_array($this->targetUser2->getUri(), $hrefs)); } 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)); @@ -319,13 +319,12 @@ 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')); + $this->assertEquals($this->targetGroup1->getUri(), ActivityUtils::getLink($element, 'mentioned')); } 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)); @@ -333,7 +332,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $element = $this->_entryToElement($entry, true); - $links = ActivityUtils::getLinks($element, 'ostatus:attention'); + $links = ActivityUtils::getLinks($element, 'mentioned'); $this->assertEquals(2, count($links)); @@ -343,8 +342,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $hrefs[] = $link->getAttribute('href'); } - $this->assertTrue(in_array($this->targetGroup1->uri, $hrefs)); - $this->assertTrue(in_array($this->targetGroup2->uri, $hrefs)); + $this->assertTrue(in_array($this->targetGroup1->getUri(), $hrefs)); + $this->assertTrue(in_array($this->targetGroup2->getUri(), $hrefs)); $links = ActivityUtils::getLinks($element, 'mentioned'); @@ -356,14 +355,14 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $hrefs[] = $link->getAttribute('href'); } - $this->assertTrue(in_array($this->targetGroup1->uri, $hrefs)); - $this->assertTrue(in_array($this->targetGroup2->uri, $hrefs)); + $this->assertTrue(in_array($this->targetGroup1->getUri(), $hrefs)); + $this->assertTrue(in_array($this->targetGroup2->getUri(), $hrefs)); } public function testRepeatLink() { $notice = $this->_fakeNotice($this->author1); - $repeat = $notice->repeat($this->author2->id, 'test'); + $repeat = $notice->repeat($this->author2->getProfile(), 'test'); $entry = $repeat->asAtomEntry(); @@ -372,13 +371,13 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $forward = ActivityUtils::child($element, 'forward', "http://ostatus.org/schema/1.0"); $this->assertNotNull($forward); - $this->assertEquals($notice->uri, $forward->getAttribute('ref')); - $this->assertEquals($notice->bestUrl(), $forward->getAttribute('href')); + $this->assertEquals($notice->getUri(), $forward->getAttribute('ref')); + $this->assertEquals($notice->getUrl(), $forward->getAttribute('href')); } public function testTag() { - $tag1 = common_good_rand(4); + $tag1 = common_random_hexstr(4); $notice = $this->_fakeNotice($this->author1, '#' . $tag1); @@ -394,8 +393,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); @@ -421,7 +420,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(); @@ -444,7 +443,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $this->assertEquals($notice->source, $noticeInfo->getAttribute('source')); $this->assertEquals('', $noticeInfo->getAttribute('repeat_of')); $this->assertEquals('', $noticeInfo->getAttribute('repeated')); - $this->assertEquals('', $noticeInfo->getAttribute('favorite')); +// $this->assertEquals('', $noticeInfo->getAttribute('favorite')); $this->assertEquals('', $noticeInfo->getAttribute('source_link')); } @@ -452,7 +451,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase { $notice = $this->_fakeNotice(); - $repeat = $notice->repeat($this->author2->id, 'test'); + $repeat = $notice->repeat($this->author2->getProfile(), 'test'); $entry = $repeat->asAtomEntry(); @@ -467,7 +466,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase { $notice = $this->_fakeNotice(); - $repeat = $notice->repeat($this->author2->id, 'test'); + $repeat = $notice->repeat($this->author2->getProfile(), 'test'); $entry = $notice->asAtomEntry(false, false, false, $this->author2); @@ -486,7 +485,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $this->assertEquals('false', $noticeInfo->getAttribute('repeated')); } - public function testNoticeInfoFave() +/* public function testNoticeInfoFave() { $notice = $this->_fakeNotice(); @@ -511,23 +510,23 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/"); $this->assertEquals('false', $noticeInfo->getAttribute('favorite')); - } + }*/ public function testConversationLink() { $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(); $element = $this->_entryToElement($entry, true); - $this->assertEquals($conv->uri, ActivityUtils::getLink($element, 'ostatus:conversation')); + $this->assertEquals($conv->getUri(), ActivityUtils::getLink($element, 'ostatus:conversation')); } function __destruct() @@ -564,7 +563,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));