Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Aug 22, 2024
1 parent 805761f commit 96cc9f7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
15 changes: 13 additions & 2 deletions src/Laravel/Tests/JsonApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,19 @@ public function testCreateBook(): void
'/api/books',
[
'data' => [
'attributes' => ['name' => 'Don Quichotte', 'isbn' => fake()->isbn13(), 'publicationDate' => fake()->date()],
'relationships' => ['author' => ['data' => ['id' => $this->getIriFromResource($author), 'type' => 'Author']]],
'attributes' => [
'name' => 'Don Quichotte',
'isbn' => fake()->isbn13(),
'publicationDate' => fake()->optional()->date(),
],
'relationships' => [
'author' => [
'data' => [
'id' => $this->getIriFromResource($author),
'type' => 'Author',
],
],
],
],
],
[
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/Tests/JsonLdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testCreateBook(): void
'name' => 'Don Quichotte',
'author' => $this->getIriFromResource($author),
'isbn' => fake()->isbn13(),
'publicationDate' => fake()->date(),
'publicationDate' => fake()->optional()->date(),
],
[
'accept' => 'application/ld+json',
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/workbench/database/factories/BookFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function definition(): array
'id' => (string) new Ulid(),
'author_id' => AuthorFactory::new(),
'isbn' => fake()->isbn13(),
'publication_date' => fake()->date(),
'publication_date' => fake()->optional()->date(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function up(): void
$table->ulid('id')->primary();
$table->string('name');
$table->string('isbn');
$table->date('publication_date');
$table->date('publication_date')->nullable();
$table->integer('author_id')->unsigned();
$table->foreign('author_id')->references('id')->on('authors');
$table->timestamps();
Expand Down

0 comments on commit 96cc9f7

Please sign in to comment.