|
8 | 8 | namespace Activitypub\Tests\Activity; |
9 | 9 |
|
10 | 10 | use Activitypub\Activity\Activity; |
| 11 | +use Activitypub\Collection\Actors; |
11 | 12 | use DMS\PHPUnitExtensions\ArraySubset\Assert; |
12 | 13 |
|
13 | 14 | /** |
@@ -132,4 +133,40 @@ public function test_activity_object_id() { |
132 | 133 |
|
133 | 134 | $this->assertTrue( str_starts_with( $activity->get_id(), 'https://example.com/author/123#activity-update-' ) ); |
134 | 135 | } |
| 136 | + |
| 137 | + /** |
| 138 | + * Test activity object. |
| 139 | + */ |
| 140 | + public function test_activity_object_in_reply_to() { |
| 141 | + // Create user with `activitypub` capabilities. |
| 142 | + $user_id = self::factory()->user->create( |
| 143 | + array( |
| 144 | + 'role' => 'author', |
| 145 | + ) |
| 146 | + ); |
| 147 | + |
| 148 | + // Only send minimal data. |
| 149 | + $activity_object = array( |
| 150 | + 'id' => 'https://example.com/post/123', |
| 151 | + 'type' => 'Follow', |
| 152 | + 'actor' => 'https://example.com/author/123', |
| 153 | + 'object' => 'https://example.com/post/123', |
| 154 | + 'to' => array( 'https://example.com/author/123' ), |
| 155 | + ); |
| 156 | + |
| 157 | + $activity = new Activity(); |
| 158 | + $activity->set_type( 'Accept' ); |
| 159 | + $activity->set_actor( Actors::get_by_id( $user_id )->get_id() ); |
| 160 | + $activity->set_object( $activity_object ); |
| 161 | + |
| 162 | + $this->assertContains( 'https://example.com/author/123', $activity->get_to() ); |
| 163 | + |
| 164 | + $activity->set_to( array( 'https://example.com/author/456' ) ); |
| 165 | + $activity->set_object( $activity_object ); |
| 166 | + |
| 167 | + $this->assertContains( 'https://example.com/author/456', $activity->get_to() ); |
| 168 | + |
| 169 | + // Delete user. |
| 170 | + \wp_delete_user( $user_id ); |
| 171 | + } |
135 | 172 | } |
0 commit comments