File tree Expand file tree Collapse file tree 2 files changed +0
-39
lines changed Expand file tree Collapse file tree 2 files changed +0
-39
lines changed Original file line number Diff line number Diff line change 13
13
use Laravel \Scout \Engines \Engine ;
14
14
use Laravel \Scout \Searchable ;
15
15
use LogicException ;
16
- use MongoDB \BSON \Regex ;
17
16
use MongoDB \BSON \Serializable ;
18
17
use MongoDB \BSON \UTCDateTime ;
19
18
use MongoDB \Collection as MongoDBCollection ;
41
40
use function is_iterable ;
42
41
use function is_string ;
43
42
use function iterator_to_array ;
44
- use function preg_quote ;
45
43
use function sleep ;
46
44
use function sprintf ;
47
45
use function substr ;
@@ -428,22 +426,6 @@ public function deleteIndex($name): void
428
426
$ this ->database ->selectCollection ($ name )->drop ();
429
427
}
430
428
431
- /**
432
- * Delete all "search indexes", i.e. all MongoDB collections.
433
- */
434
- public function deleteAllIndexes ()
435
- {
436
- $ collectionNames = $ this ->database ->listCollectionNames ([
437
- 'filter ' => [
438
- 'name ' => new Regex ('^ ' . preg_quote ($ this ->prefix )),
439
- ],
440
- ]);
441
-
442
- foreach ($ collectionNames as $ collectionName ) {
443
- $ this ->database ->selectCollection ($ collectionName )->drop ();
444
- }
445
- }
446
-
447
429
/** Get the MongoDB collection used to search for the provided model */
448
430
private function getSearchableCollection (Model |EloquentCollection $ model ): MongoDBCollection
449
431
{
Original file line number Diff line number Diff line change 2
2
3
3
namespace MongoDB \Laravel \Tests \Scout ;
4
4
5
- use ArrayIterator ;
6
5
use Closure ;
7
6
use DateTimeImmutable ;
8
7
use Illuminate \Database \Eloquent \Collection as EloquentCollection ;
12
11
use LogicException ;
13
12
use Mockery as m ;
14
13
use MongoDB \BSON \Document ;
15
- use MongoDB \BSON \Regex ;
16
14
use MongoDB \BSON \UTCDateTime ;
17
15
use MongoDB \Collection ;
18
16
use MongoDB \Database ;
@@ -552,25 +550,6 @@ public function testDeleteWithRemoveableScoutCollection(): void
552
550
$ engine ->delete ($ job ->models );
553
551
}
554
552
555
- public function testDeleteAll (): void
556
- {
557
- $ collectionNames = ['scout-prefix-table1 ' , 'scout-prefix-table2 ' ];
558
- $ database = m::mock (Database::class);
559
- $ database ->shouldReceive ('listCollectionNames ' )
560
- // Name prefix is escaped
561
- ->with (['filter ' => ['name ' => new Regex ('^scout\-prefix\- ' )]])
562
- ->andReturn (new ArrayIterator ($ collectionNames ));
563
-
564
- foreach ($ collectionNames as $ collectionName ) {
565
- $ collection = m::mock (Collection::class);
566
- $ database ->shouldReceive ('selectCollection ' )->with ($ collectionName )->andReturn ($ collection );
567
- $ collection ->shouldReceive ('drop ' )->with ()->once ();
568
- }
569
-
570
- $ engine = new ScoutEngine ($ database , softDelete: false , prefix: 'scout-prefix- ' );
571
- $ engine ->deleteAllIndexes ();
572
- }
573
-
574
553
public function testItCannotIndexInTheSameNamespace ()
575
554
{
576
555
self ::expectException (LogicException::class);
You can’t perform that action at this time.
0 commit comments