Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Issues (892)

Branch: main

tests/Unit/CrudPanel/CrudPanelTest.php (3 issues)

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
18
        $this->assertEquals($this->model, $this->crudPanel->model);
19
        $this->assertInstanceOf(TestModel::class, $this->crudPanel->model);
20
        $this->assertInstanceOf(Builder::class, $this->crudPanel->query);
21
    }
22
23
    public function testSetModelFromModelClassName()
24
    {
25
        $modelClassName = '\Backpack\CRUD\Tests\config\Models\TestModel';
26
27
        $this->crudPanel->setModel($modelClassName);
28
29
        $this->assertEquals($this->model, $this->crudPanel->model);
30
        $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 ignore-type  annotation

30
        $this->assertInstanceOf(/** @scrutinizer ignore-type */ $modelClassName, $this->crudPanel->model);
Loading history...
31
        $this->assertInstanceOf(Builder::class, $this->crudPanel->query);
32
    }
33
34
    public function testSetUnknownModel()
35
    {
36
        $this->expectException(\Exception::class);
37
38
        $this->crudPanel->setModel('\Foo\Bar');
39
    }
40
41
    public function testSetUnknownRouteName()
42
    {
43
        $this->expectException(\Exception::class);
44
45
        $this->crudPanel->setRouteName('unknown.route.name');
46
    }
47
48
    public function testItThrowsExceptionIfModelIsNotUsingCrudTrait()
49
    {
50
        try {
51
            $this->crudPanel->setModel('\Backpack\CRUD\Tests\config\Models\ModelWithoutCrudTrait');
52
        } catch (\Throwable $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
53
        }
54
        $this->assertEquals(
55
            new \Exception('Please use CrudTrait on the model.', 500),
56
            $e
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $e does not seem to be defined for all execution paths leading up to this point.
Loading history...
57
        );
58
    }
59
}
60