Skip to content

Commit 4adb7de

Browse files
committed
Add tests for compilation exception
1 parent ace9725 commit 4adb7de

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/Unit/GrammarTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tests\Unit;
44

55
use EllGreen\LaravelLoadFile\Builder\Builder;
6+
use EllGreen\LaravelLoadFile\Exceptions\CompilationException;
67
use EllGreen\LaravelLoadFile\Grammar;
78
use Illuminate\Database\DatabaseManager;
89
use Illuminate\Database\Query\Expression;
@@ -28,6 +29,42 @@ protected function setUp(): void
2829
->columns(['forename', 'surname', 'employee_id']);
2930
}
3031

32+
public function testNoFileThrowsException()
33+
{
34+
$this->expectException(CompilationException::class);
35+
36+
$builder = (new Builder(
37+
$this->createMock(DatabaseManager::class),
38+
$this->createMock(Grammar::class),
39+
))->into('table');
40+
41+
$this->grammar->compileLoadFile($builder);
42+
}
43+
44+
public function testNoTableThrowsException()
45+
{
46+
$this->expectException(CompilationException::class);
47+
48+
$builder = (new Builder(
49+
$this->createMock(DatabaseManager::class),
50+
$this->createMock(Grammar::class),
51+
))->file('path/to/file');
52+
53+
$this->grammar->compileLoadFile($builder);
54+
}
55+
56+
public function testNoTableOrFileThrowsException()
57+
{
58+
$this->expectException(CompilationException::class);
59+
60+
$builder = new Builder(
61+
$this->createMock(DatabaseManager::class),
62+
$this->createMock(Grammar::class),
63+
);
64+
65+
$this->grammar->compileLoadFile($builder);
66+
}
67+
3168
public function testSimpleCompile()
3269
{
3370
$this->assertSqlAndBindings(<<<'SQL'

0 commit comments

Comments
 (0)