@@ -193,15 +193,20 @@ public function testGetAndDropTypes()
193
193
DB ::statement ("create type enum_foo as enum ('new', 'open', 'closed') " );
194
194
DB ::statement ('create type range_foo as range (subtype = float8) ' );
195
195
DB ::statement ('create domain domain_foo as text ' );
196
+ DB ::statement ('create type base_foo ' );
197
+ DB ::statement ("create function foo_in(cstring) returns base_foo language internal immutable strict parallel safe as 'int2in' " );
198
+ DB ::statement ("create function foo_out(base_foo) returns cstring language internal immutable strict parallel safe as 'int2out' " );
199
+ DB ::statement ('create type base_foo (input = foo_in, output = foo_out) ' );
196
200
197
201
$ types = Schema::getTypes ();
198
202
199
- $ this ->assertCount (11 , $ types );
203
+ $ this ->assertCount (13 , $ types );
200
204
$ this ->assertTrue (collect ($ types )->contains (fn ($ type ) => $ type ['name ' ] === 'pseudo_foo ' && $ type ['type ' ] === 'pseudo ' && ! $ type ['implicit ' ]));
201
205
$ this ->assertTrue (collect ($ types )->contains (fn ($ type ) => $ type ['name ' ] === 'comp_foo ' && $ type ['type ' ] === 'composite ' && ! $ type ['implicit ' ]));
202
206
$ this ->assertTrue (collect ($ types )->contains (fn ($ type ) => $ type ['name ' ] === 'enum_foo ' && $ type ['type ' ] === 'enum ' && ! $ type ['implicit ' ]));
203
207
$ this ->assertTrue (collect ($ types )->contains (fn ($ type ) => $ type ['name ' ] === 'range_foo ' && $ type ['type ' ] === 'range ' && ! $ type ['implicit ' ]));
204
208
$ this ->assertTrue (collect ($ types )->contains (fn ($ type ) => $ type ['name ' ] === 'domain_foo ' && $ type ['type ' ] === 'domain ' && ! $ type ['implicit ' ]));
209
+ $ this ->assertTrue (collect ($ types )->contains (fn ($ type ) => $ type ['name ' ] === 'base_foo ' && $ type ['type ' ] === 'base ' && ! $ type ['implicit ' ]));
205
210
206
211
Schema::dropAllTypes ();
207
212
$ types = Schema::getTypes ();
@@ -256,6 +261,10 @@ public function testGetIndexes()
256
261
&& ! $ indexes [0 ]['unique ' ]
257
262
&& ! $ indexes [0 ]['primary ' ]
258
263
);
264
+ $ this ->assertTrue (Schema::hasIndex ('foo ' , 'my_index ' ));
265
+ $ this ->assertTrue (Schema::hasIndex ('foo ' , ['bar ' ]));
266
+ $ this ->assertFalse (Schema::hasIndex ('foo ' , 'my_index ' , 'primary ' ));
267
+ $ this ->assertFalse (Schema::hasIndex ('foo ' , ['bar ' ], 'unique ' ));
259
268
}
260
269
261
270
public function testGetUniqueIndexes ()
@@ -277,6 +286,11 @@ public function testGetUniqueIndexes()
277
286
$ this ->assertTrue (collect ($ indexes )->contains (
278
287
fn ($ index ) => $ index ['name ' ] === 'foo_baz_bar_unique ' && $ index ['columns ' ] === ['baz ' , 'bar ' ] && $ index ['unique ' ]
279
288
));
289
+ $ this ->assertTrue (Schema::hasIndex ('foo ' , 'foo_baz_bar_unique ' ));
290
+ $ this ->assertTrue (Schema::hasIndex ('foo ' , 'foo_baz_bar_unique ' , 'unique ' ));
291
+ $ this ->assertTrue (Schema::hasIndex ('foo ' , ['bar ' , 'baz ' ]));
292
+ $ this ->assertTrue (Schema::hasIndex ('foo ' , ['bar ' , 'baz ' ], 'unique ' ));
293
+ $ this ->assertFalse (Schema::hasIndex ('foo ' , ['bar ' , 'baz ' ], 'primary ' ));
280
294
}
281
295
282
296
public function testGetIndexesWithCompositeKeys ()
0 commit comments