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

Passed
Push — CrudButton-fixees ( a4c9f3...1a6e15 )
by Pedro
15:19
created

CrudPanelTest::testSetUnknownModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD\Tests\Unit\CrudPanel;
4
5
use Backpack\CRUD\Tests\Unit\Models\TestModel;
6
use Illuminate\Database\Eloquent\Builder;
7
8
/**
9
 * @covers Backpack\CRUD\app\Library\CrudPanel\CrudPanel
10
 */
11
class CrudPanelTest extends BaseCrudPanelTest
12
{
13
    public function testSetModelFromModelClass()
14
    {
15
        $this->crudPanel->setModel(TestModel::class);
16
17
        $this->assertEquals($this->model, $this->crudPanel->model);
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\Unit\Models\TestModel';
25
26
        $this->crudPanel->setModel($modelClassName);
27
28
        $this->assertEquals($this->model, $this->crudPanel->model);
29
        $this->assertInstanceOf($modelClassName, $this->crudPanel->model);
0 ignored issues
show
Bug introduced by
$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

29
        $this->assertInstanceOf(/** @scrutinizer ignore-type */ $modelClassName, $this->crudPanel->model);
Loading history...
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\Unit\Models\ModelWithoutCrudTrait');
51
        } catch (\Throwable $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
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
The variable $e does not seem to be defined for all execution paths leading up to this point.
Loading history...
56
        );
57
    }
58
}
59