2020-05-14 22:33:09 +02:00
|
|
|
<?php
|
|
|
|
class Test_Activitypub_Post extends WP_UnitTestCase {
|
|
|
|
public function test_to_array() {
|
|
|
|
$post = \wp_insert_post(
|
|
|
|
array(
|
|
|
|
'post_author' => 1,
|
|
|
|
'post_content' => 'test',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$permalink = \get_permalink( $post );
|
|
|
|
|
2023-11-20 18:27:29 +01:00
|
|
|
$activitypub_post = \Activitypub\Transformers_Manager::instance()->get_transformer( get_post( $post ) )->set_wp_post( get_post( $post ) )->to_object();
|
2020-05-14 22:33:09 +02:00
|
|
|
|
2020-10-01 19:57:19 +02:00
|
|
|
$this->assertEquals( $permalink, $activitypub_post->get_id() );
|
2020-05-14 22:33:09 +02:00
|
|
|
|
|
|
|
\wp_trash_post( $post );
|
|
|
|
|
2023-11-20 18:27:29 +01:00
|
|
|
$activitypub_post = \Activitypub\Transformers_Manager::instance()->get_transformer( get_post( $post ) )->set_wp_post( get_post( $post ) )->to_object();
|
2020-05-14 22:33:09 +02:00
|
|
|
|
2020-10-01 19:57:19 +02:00
|
|
|
$this->assertEquals( $permalink, $activitypub_post->get_id() );
|
2023-09-27 11:05:11 +02:00
|
|
|
|
|
|
|
$cached = \get_post_meta( $post, 'activitypub_canonical_url', true );
|
|
|
|
|
|
|
|
$this->assertEquals( $cached, $activitypub_post->get_id() );
|
2020-05-14 22:33:09 +02:00
|
|
|
}
|
|
|
|
}
|