Skip to content

Commit 0e14a68

Browse files
committed
chore: add test to ensure normal collections are excluded from getViews
1 parent 4890eca commit 0e14a68

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: tests/SchemaTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ public function testGetTables()
396396
{
397397
DB::connection('mongodb')->table('newcollection')->insert(['test' => 'value']);
398398
DB::connection('mongodb')->table('newcollection_two')->insert(['test' => 'value']);
399+
DB::connection('mongodb')->getDatabase()->createCollection('test_view', ['viewOn' => 'newcollection']);
399400
$dbName = DB::connection('mongodb')->getDatabaseName();
400401

401402
$tables = Schema::getTables();
@@ -408,6 +409,9 @@ public function testGetTables()
408409
$this->assertArrayHasKey('schema', $table);
409410
$this->assertArrayHasKey('schema_qualified_name', $table);
410411

412+
// Ensure "test_view" is not in the tables list
413+
$this->assertNotEquals('test_view', $table['name'], 'Standard views should not be included in the result of getTables.');
414+
411415
if ($table['name'] === 'newcollection') {
412416
$this->assertEquals(8192, $table['size']);
413417
$this->assertEquals($dbName, $table['schema']);
@@ -440,6 +444,9 @@ public function testGetViews()
440444
$this->assertArrayHasKey('schema', $table);
441445
$this->assertArrayHasKey('schema_qualified_name', $table);
442446

447+
// Ensure "normal collections" are not in the views list
448+
$this->assertNotEquals('newcollection', $table['name'], 'Normal collections should not be included in the result of getViews.');
449+
443450
if ($table['name'] === 'test_view') {
444451
$this->assertEquals($dbName, $table['schema']);
445452
$this->assertEquals($dbName . '.test_view', $table['schema_qualified_name']);

0 commit comments

Comments
 (0)