44
55use Tempest \Database \Config \DatabaseDialect ;
66use Tempest \Database \Database ;
7- use Tempest \Database \Exceptions \HasManyRelationCouldNotBeInsterted ;
8- use Tempest \Database \Exceptions \HasOneRelationCouldNotBeInserted ;
97use Tempest \Database \Migrations \CreateMigrationsTable ;
108use Tempest \Database \PrimaryKey ;
119use Tempest \Database \Query ;
@@ -26,10 +24,7 @@ final class InsertQueryBuilderTest extends FrameworkIntegrationTestCase
2624 public function test_insert_on_plain_table (): void
2725 {
2826 $ query = query ('chapters ' )
29- ->insert (
30- title: 'Chapter 01 ' ,
31- index: 1 ,
32- )
27+ ->insert (title: 'Chapter 01 ' , index: 1 )
3328 ->build ();
3429
3530 $ expected = $ this ->buildExpectedInsert ('INSERT INTO `chapters` (`title`, `index`) VALUES (?, ?) ' );
@@ -72,11 +67,7 @@ public function test_insert_with_batch(): void
7267
7368 public function test_insert_on_model_table (): void
7469 {
75- $ author = new Author (
76- name: 'brent ' ,
77- type: AuthorType::A,
78- );
79-
70+ $ author = new Author (name: 'brent ' , type: AuthorType::A);
8071 $ query = query (Author::class)
8172 ->insert (
8273 $ author ,
@@ -94,15 +85,11 @@ public function test_insert_on_model_table_with_new_relation(): void
9485 {
9586 $ book = Book::new (
9687 title: 'Timeline Taxi ' ,
97- author: Author::new (
98- name: 'Brent ' ,
99- ),
88+ author: Author::new (name: 'Brent ' ),
10089 );
10190
10291 $ bookQuery = query (Book::class)
103- ->insert (
104- $ book ,
105- )
92+ ->insert ($ book )
10693 ->build ();
10794
10895 $ expectedBookQuery = $ this ->buildExpectedInsert ('INSERT INTO `books` (`title`, `author_id`) VALUES (?, ?) ' );
@@ -130,9 +117,7 @@ public function test_insert_on_model_table_with_existing_relation(): void
130117 );
131118
132119 $ bookQuery = query (Book::class)
133- ->insert (
134- $ book ,
135- )
120+ ->insert ($ book )
136121 ->build ();
137122
138123 $ expectedBookQuery = $ this ->buildExpectedInsert ('INSERT INTO `books` (`title`, `author_id`) VALUES (?, ?) ' );
@@ -142,30 +127,6 @@ public function test_insert_on_model_table_with_existing_relation(): void
142127 $ this ->assertSame (10 , $ bookQuery ->bindings [1 ]);
143128 }
144129
145- public function test_inserting_has_many_via_parent_model_throws_exception (): void
146- {
147- $ this ->assertException (HasManyRelationCouldNotBeInsterted::class, function (): void {
148- query (Book::class)
149- ->insert (
150- title: 'Timeline Taxi ' ,
151- chapters: ['title ' => 'Chapter 01 ' ],
152- )
153- ->build ();
154- });
155- }
156-
157- public function test_inserting_has_one_via_parent_model_throws_exception (): void
158- {
159- $ this ->assertException (HasOneRelationCouldNotBeInserted::class, function (): void {
160- query (Book::class)
161- ->insert (
162- title: 'Timeline Taxi ' ,
163- isbn: ['value ' => '979-8344313764 ' ],
164- )
165- ->build ();
166- });
167- }
168-
169130 public function test_then_method (): void
170131 {
171132 $ this ->migrate (CreateMigrationsTable::class, CreatePublishersTable::class, CreateAuthorTable::class, CreateBookTable::class, CreateChapterTable::class);
@@ -218,7 +179,9 @@ public function test_insert_mapping(): void
218179 {
219180 $ author = Author::new (name: 'test ' );
220181
221- $ query = query (Author::class)->insert ($ author )->build ();
182+ $ query = query (Author::class)
183+ ->insert ($ author )
184+ ->build ();
222185
223186 $ dialect = $ this ->container ->get (Database::class)->dialect ;
224187
0 commit comments