We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||||
2 | |||||
3 | namespace Backpack\CRUD\Tests\Unit\CrudPanel; |
||||
4 | |||||
5 | use Backpack\CRUD\Tests\config\CrudPanel\BaseCrudPanel; |
||||
6 | use Backpack\CRUD\Tests\config\Models\TestModel; |
||||
7 | use Illuminate\Database\Eloquent\Builder; |
||||
8 | |||||
9 | /** |
||||
10 | * @covers Backpack\CRUD\app\Library\CrudPanel\CrudPanel |
||||
11 | */ |
||||
12 | class CrudPanelTest extends BaseCrudPanel |
||||
13 | { |
||||
14 | public function testSetModelFromModelClass() |
||||
15 | { |
||||
16 | $this->crudPanel->setModel(TestModel::class); |
||||
17 | $this->assertEquals($this->model, get_class($this->crudPanel->model)); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
18 | $this->assertInstanceOf(TestModel::class, $this->crudPanel->model); |
||||
19 | $this->assertInstanceOf(Builder::class, $this->crudPanel->query); |
||||
20 | } |
||||
21 | |||||
22 | public function testSetModelFromModelClassName() |
||||
23 | { |
||||
24 | $modelClassName = '\Backpack\CRUD\Tests\config\Models\TestModel'; |
||||
25 | |||||
26 | $this->crudPanel->setModel($modelClassName); |
||||
27 | |||||
28 | $this->assertEquals($this->model, get_class($this->crudPanel->model)); |
||||
0 ignored issues
–
show
$this->crudPanel->model of type string is incompatible with the type object expected by parameter $object of get_class() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
29 | $this->assertInstanceOf($modelClassName, $this->crudPanel->model); |
||||
0 ignored issues
–
show
$modelClassName of type object is incompatible with the type string expected by parameter $expected of PHPUnit\Framework\Assert::assertInstanceOf() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
30 | $this->assertInstanceOf(Builder::class, $this->crudPanel->query); |
||||
31 | } |
||||
32 | |||||
33 | public function testSetUnknownModel() |
||||
34 | { |
||||
35 | $this->expectException(\Exception::class); |
||||
36 | |||||
37 | $this->crudPanel->setModel('\Foo\Bar'); |
||||
38 | } |
||||
39 | |||||
40 | public function testSetUnknownRouteName() |
||||
41 | { |
||||
42 | $this->expectException(\Exception::class); |
||||
43 | |||||
44 | $this->crudPanel->setRouteName('unknown.route.name'); |
||||
45 | } |
||||
46 | |||||
47 | public function testItThrowsExceptionIfModelIsNotUsingCrudTrait() |
||||
48 | { |
||||
49 | try { |
||||
50 | $this->crudPanel->setModel('\Backpack\CRUD\Tests\config\Models\ModelWithoutCrudTrait'); |
||||
51 | } catch (\Throwable $e) { |
||||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||||
52 | } |
||||
53 | $this->assertEquals( |
||||
54 | new \Exception('Please use CrudTrait on the model.', 500), |
||||
55 | $e |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
56 | ); |
||||
57 | } |
||||
58 | } |
||||
59 |