5, 'post_type' => 'page']); Functions\when('get_post')->justReturn($post); Functions\when('current_user_can')->justReturn(true); $schema = SchemaFixture::managed(); $presenter = Mockery::mock(PostPresenter::class); $presenter->expects('full')->with($post)->andReturn(['id' => 5]); $ability = new ContentGetAbility($schema, $presenter); self::assertTrue($ability->permission(['post_id' => 5])); self::assertSame(['id' => 5], $ability->execute(['post_id' => 5])); } public function testATrashedPostCanStillBeRead(): void { $post = new WP_Post(['ID' => 5, 'post_type' => 'page', 'post_status' => 'trash']); Functions\when('get_post')->justReturn($post); Functions\when('current_user_can')->justReturn(true); $schema = SchemaFixture::managed(); $presenter = Mockery::mock(PostPresenter::class); $presenter->expects('full')->with($post)->andReturn(['id' => 5]); self::assertSame(['id' => 5], (new ContentGetAbility($schema, $presenter))->execute(['post_id' => 5])); } public function testMissingPostIsNotFound(): void { Functions\when('get_post')->justReturn(null); $schema = Mockery::mock(ContentSchema::class); $ability = new ContentGetAbility($schema, Mockery::mock(PostPresenter::class)); self::assertToolError($ability->permission(['post_id' => 99]), 'not_found'); } public function testOutputSchemaAllowsNullContentForDivi(): void { $ability = new ContentGetAbility(Mockery::mock(ContentSchema::class), Mockery::mock(PostPresenter::class)); self::assertSame(['string', 'null'], $ability->outputSchema()['properties']['content']['type']); self::assertTrue($ability->isDirect()); } }