fix unittests
This commit is contained in:
parent
0185e38013
commit
e57932b099
1 changed files with 47 additions and 49 deletions
|
@ -1,9 +1,7 @@
|
|||
<?php
|
||||
class Test_Inbox extends WP_UnitTestCase {
|
||||
#[\ReturnTypeWillChange]
|
||||
|
||||
var $post_permalink;
|
||||
var $user_url;
|
||||
public $post_permalink;
|
||||
public $user_url;
|
||||
|
||||
public function setUp() {
|
||||
$authordata = \get_userdata( 1 );
|
||||
|
@ -22,9 +20,9 @@ class Test_Inbox extends WP_UnitTestCase {
|
|||
|
||||
public static function get_remote_metadata_by_actor( $value, $actor ) {
|
||||
return array(
|
||||
"name" => "Example User",
|
||||
"icon" => array(
|
||||
"url" => "https://example.com/icon",
|
||||
'name' => 'Example User',
|
||||
'icon' => array(
|
||||
'url' => 'https://example.com/icon',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -32,37 +30,37 @@ class Test_Inbox extends WP_UnitTestCase {
|
|||
public function test_convert_object_to_comment_data_basic() {
|
||||
$inbox = new \Activitypub\Rest\Inbox();
|
||||
$object = array(
|
||||
"actor" => $this->user_url,
|
||||
"to" => [ $this->user_url ],
|
||||
"cc" => [ "https://www.w3.org/ns/activitystreams#Public" ],
|
||||
"object" => array(
|
||||
"id" => "123",
|
||||
"url" => "https://example.com/example",
|
||||
"inReplyTo" => $this->post_permalink,
|
||||
"content" => "example",
|
||||
'actor' => $this->user_url,
|
||||
'to' => [ $this->user_url ],
|
||||
'cc' => [ 'https://www.w3.org/ns/activitystreams#Public' ],
|
||||
'object' => array(
|
||||
'id' => '123',
|
||||
'url' => 'https://example.com/example',
|
||||
'inReplyTo' => $this->post_permalink,
|
||||
'content' => 'example',
|
||||
),
|
||||
);
|
||||
$converted = $inbox->convert_object_to_comment_data( $object );
|
||||
|
||||
$this->assertGreaterThan(1, $converted["comment_post_ID"]);
|
||||
$this->assertEquals($converted["comment_author"], "Example User");
|
||||
$this->assertEquals($converted["comment_author_url"], "http://example.org");
|
||||
$this->assertEquals($converted["comment_content"], "example");
|
||||
$this->assertEquals($converted["comment_type"], "");
|
||||
$this->assertEquals($converted["comment_author_email"], "");
|
||||
$this->assertEquals($converted["comment_parent"], 0);
|
||||
$this->assertArrayHasKey("comment_meta", $converted);
|
||||
$this->assertEquals($converted["comment_meta"]["source_id"], "http://123");
|
||||
$this->assertEquals($converted["comment_meta"]["source_url"], "https://example.com/example");
|
||||
$this->assertEquals($converted["comment_meta"]["avatar_url"], "https://example.com/icon");
|
||||
$this->assertEquals($converted["comment_meta"]["protocol"], "activitypub");
|
||||
$this->assertGreaterThan( 1, $converted['comment_post_ID'] );
|
||||
$this->assertEquals( $converted['comment_author'], 'Example User' );
|
||||
$this->assertEquals( $converted['comment_author_url'], 'http://example.org' );
|
||||
$this->assertEquals( $converted['comment_content'], 'example' );
|
||||
$this->assertEquals( $converted['comment_type'], '' );
|
||||
$this->assertEquals( $converted['comment_author_email'], '' );
|
||||
$this->assertEquals( $converted['comment_parent'], 0 );
|
||||
$this->assertArrayHasKey( 'comment_meta', $converted );
|
||||
$this->assertEquals( $converted['comment_meta']['source_id'], 'http://123' );
|
||||
$this->assertEquals( $converted['comment_meta']['source_url'], 'https://example.com/example' );
|
||||
$this->assertEquals( $converted['comment_meta']['avatar_url'], 'https://example.com/icon' );
|
||||
$this->assertEquals( $converted['comment_meta']['protocol'], 'activitypub' );
|
||||
}
|
||||
|
||||
public function test_convert_object_to_comment_data_non_public_rejected() {
|
||||
$inbox = new \Activitypub\Rest\Inbox();
|
||||
$object = array(
|
||||
"to" => ["https://example.com/profile/test"],
|
||||
"cc" => [],
|
||||
'to' => array( 'https://example.com/profile/test' ),
|
||||
'cc' => array(),
|
||||
);
|
||||
$converted = $inbox->convert_object_to_comment_data( $object );
|
||||
$this->assertFalse( $converted );
|
||||
|
|
Loading…
Reference in a new issue