|
8 | 8 | use Illuminate\Support\Facades\Schema;
|
9 | 9 | use MongoDB\Laravel\Schema\Blueprint;
|
10 | 10 |
|
| 11 | +use function count; |
| 12 | + |
11 | 13 | class SchemaTest extends TestCase
|
12 | 14 | {
|
13 | 15 | public function tearDown(): void
|
@@ -377,6 +379,43 @@ public function testRenameColumn(): void
|
377 | 379 | $this->assertSame($check[2]['column'], $check2[2]['column']);
|
378 | 380 | }
|
379 | 381 |
|
| 382 | + public function testGetTables() |
| 383 | + { |
| 384 | + DB::connection('mongodb')->collection('newcollection')->insert(['test' => 'value']); |
| 385 | + DB::connection('mongodb')->collection('newcollection_two')->insert(['test' => 'value']); |
| 386 | + |
| 387 | + $tables = Schema::getTables(); |
| 388 | + $this->assertIsArray($tables); |
| 389 | + $this->assertGreaterThanOrEqual(2, count($tables)); |
| 390 | + $found = false; |
| 391 | + foreach ($tables as $table) { |
| 392 | + $this->assertArrayHasKey('name', $table); |
| 393 | + $this->assertArrayHasKey('size', $table); |
| 394 | + |
| 395 | + if ($table['name'] === 'newcollection') { |
| 396 | + $this->assertEquals(8192, $table['size']); |
| 397 | + $found = true; |
| 398 | + } |
| 399 | + } |
| 400 | + |
| 401 | + if (! $found) { |
| 402 | + $this->fail('Collection "newcollection" not found'); |
| 403 | + } |
| 404 | + } |
| 405 | + |
| 406 | + public function testGetTableListing() |
| 407 | + { |
| 408 | + DB::connection('mongodb')->collection('newcollection')->insert(['test' => 'value']); |
| 409 | + DB::connection('mongodb')->collection('newcollection_two')->insert(['test' => 'value']); |
| 410 | + |
| 411 | + $tables = Schema::getTableListing(); |
| 412 | + |
| 413 | + $this->assertIsArray($tables); |
| 414 | + $this->assertGreaterThanOrEqual(2, count($tables)); |
| 415 | + $this->assertContains('newcollection', $tables); |
| 416 | + $this->assertContains('newcollection_two', $tables); |
| 417 | + } |
| 418 | + |
380 | 419 | protected function getIndex(string $collection, string $name)
|
381 | 420 | {
|
382 | 421 | $collection = DB::getCollection($collection);
|
|
0 commit comments