test: cover credential-clearing and trailing-slash URL edge cases

Also fixes a missing trailing newline in SiteResource.php.
This commit is contained in:
Doar Mihai
2026-07-19 17:05:01 +03:00
parent c2ef6d9986
commit f7b71684f1
3 changed files with 40 additions and 1 deletions
+25
View File
@@ -112,3 +112,28 @@ test('it marks the post as failed when the site is unreachable', function () {
expect($post->fresh()->status)->toBe('failed');
});
test('it correctly builds the WordPress endpoint URL when the site URL has a trailing slash', function () {
Http::fake([
'*/wp-json/wp/v2/posts' => Http::response([
'id' => 42,
'link' => 'https://wp.example.com/2026/07/hello-world/',
], 201),
]);
$site = Site::factory()->wordpress()->create(['url' => 'https://wp.example.com/']);
$post = Post::factory()->create([
'site_id' => $site->id,
'type' => 'blog',
'title' => 'Hello World',
'body' => 'Post content',
'status' => 'draft',
]);
$this->artisan('posts:publish', ['post' => $post->id])
->assertExitCode(0);
Http::assertSent(function ($request) {
return $request->url() === 'https://wp.example.com/wp-json/wp/v2/posts';
});
});