2019-02-19 22:43:14 +01:00
|
|
|
<?php
|
|
|
|
class Test_Db_Activitypub_Followers extends WP_UnitTestCase {
|
|
|
|
public function test_get_followers() {
|
|
|
|
$followers = array( 'https://example.com/author/jon', 'https://example.org/author/doe' );
|
|
|
|
$followers[] = array(
|
|
|
|
'type' => 'Person',
|
|
|
|
'id' => 'http://sally.example.org',
|
|
|
|
'name' => 'Sally Smith',
|
|
|
|
);
|
2020-05-12 20:30:06 +02:00
|
|
|
\update_user_meta( 1, 'activitypub_followers', $followers );
|
2019-02-19 22:43:14 +01:00
|
|
|
|
2019-11-18 20:57:00 +01:00
|
|
|
$db_followers = \Activitypub\Peer\Followers::get_followers( 1 );
|
2019-02-19 22:43:14 +01:00
|
|
|
|
2019-12-01 21:20:26 +01:00
|
|
|
$this->assertEquals( 3, \count( $db_followers ) );
|
2019-02-19 22:43:14 +01:00
|
|
|
|
|
|
|
$this->assertSame( array( 'https://example.com/author/jon', 'https://example.org/author/doe', 'http://sally.example.org' ), $db_followers );
|
|
|
|
}
|
2019-02-28 19:32:03 +01:00
|
|
|
|
|
|
|
public function test_add_follower() {
|
2019-12-01 21:20:26 +01:00
|
|
|
$follower = 'https://example.com/author/' . \time();
|
2019-11-18 20:57:00 +01:00
|
|
|
\Activitypub\Peer\Followers::add_follower( $follower, 1 );
|
2019-02-28 19:32:03 +01:00
|
|
|
|
2019-11-18 20:57:00 +01:00
|
|
|
$db_followers = \Activitypub\Peer\Followers::get_followers( 1 );
|
2019-02-28 19:32:03 +01:00
|
|
|
|
|
|
|
$this->assertContains( $follower, $db_followers );
|
|
|
|
}
|
2019-02-19 22:43:14 +01:00
|
|
|
}
|