alias(static fn (array $data): array => $data + ['slashed' => 1]); Functions\expect('wp_update_post')->once() ->with(['post_title' => 'A', 'ID' => 5, 'slashed' => 1], true) ->andReturn(5); PostRow::update(5, ['post_title' => 'A'], 'nie'); } public function testUpdateThrowsTheFailureWithWordPressReason(): void { Functions\when('wp_update_post')->justReturn(new WP_Error('db', 'Datenbank weg')); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Post 5 could not be updated: Datenbank weg'); PostRow::update(5, ['post_title' => 'A'], 'Post 5 could not be updated'); } public function testSaveReportsAZeroResultAsUnknownError(): void { Functions\when('wp_update_post')->justReturn(0); self::assertSame('unknown error', PostRow::save(5, ['post_title' => 'A'])); Functions\when('wp_update_post')->justReturn(5); self::assertNull(PostRow::save(5, ['post_title' => 'A'])); } }