Skip to content

Commit

Permalink
Fix correct post ID vs post object
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheu committed Sep 4, 2023
1 parent 51504c2 commit f4fd257
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/phpunit/test-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@ public function set_up() {

public function testMigrateWpAuthorsPagination() : void {
$factory = self::factory()->post;
$post_ids = [];
$posts = [];

for ( $i = 0; $i < 200; $i++ ) {
$post = $factory->create_and_get( [
$posts[] = $factory->create_and_get( [
'post_author' => self::$users['admin']->ID,
POSTS_PARAM => [
self::$users['editor']->ID,
],
] );

$post_ids[] = $post->ID;
}

$paged_post_id = $post_ids[100];
$authorship_authors = \Authorship\get_authors( $paged_post_id );
$paged_post = $posts[100]; // Any post from second page of results.
$authorship_authors = \Authorship\get_authors( $paged_post );

// Asset initial authorship authors set correctly.
$this->assertCount( 1, $authorship_authors );
Expand All @@ -51,7 +49,7 @@ public function testMigrateWpAuthorsPagination() : void {
] );

// Verify author data migrated correctly.
$authorship_authors = \Authorship\get_authors( $paged_post_id );
$authorship_authors = \Authorship\get_authors( $paged_post->ID );
$this->assertCount( 1, $authorship_authors );
$this->assertSame( self::$users['admin']->ID, $authorship_authors[0]->ID );
}
Expand Down

0 comments on commit f4fd257

Please sign in to comment.