-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
use BookStack\Entities\Models\Book;
use Tests\TestCase;
$resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
$resp->assertJson(['data' => [
[
- 'id' => $firstBook->id,
+ 'id' => $firstBook->id,
'name' => $firstBook->name,
'slug' => $firstBook->slug,
- ]
+ ],
]]);
}
{
$this->actingAsApiEditor();
$details = [
- 'name' => 'My API book',
+ 'name' => 'My API book',
'description' => 'A book created via the API',
];
$resp = $this->postJson($this->baseEndpoint, $details);
$resp->assertStatus(422);
$resp->assertJson([
- "error" => [
- "message" => "The given data was invalid.",
- "validation" => [
- "name" => ["The name field is required."]
+ 'error' => [
+ 'message' => 'The given data was invalid.',
+ 'validation' => [
+ 'name' => ['The name field is required.'],
],
- "code" => 422,
+ 'code' => 422,
],
]);
}
$resp->assertStatus(200);
$resp->assertJson([
- 'id' => $book->id,
- 'slug' => $book->slug,
+ 'id' => $book->id,
+ 'slug' => $book->slug,
'created_by' => [
'name' => $book->createdBy->name,
],
'name' => $book->createdBy->name,
],
'owned_by' => [
- 'name' => $book->ownedBy->name
+ 'name' => $book->ownedBy->name,
],
]);
}
$this->actingAsApiEditor();
$book = Book::visible()->first();
$details = [
- 'name' => 'My updated API book',
+ 'name' => 'My updated API book',
'description' => 'A book created via the API',
];
$resp->assertSee('# ' . $book->pages()->first()->name);
$resp->assertSee('# ' . $book->chapters()->first()->name);
}
-}
\ No newline at end of file
+}