|
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
|
|
|
class CrudPanelTest extends BaseCrudPanelTest |
|
9
|
|
|
{ |
|
10
|
|
|
public function testSetModelFromModelClass() |
|
11
|
|
|
{ |
|
12
|
|
|
$this->crudPanel->setModel(TestModel::class); |
|
13
|
|
|
|
|
14
|
|
|
$this->assertEquals($this->model, $this->crudPanel->model); |
|
15
|
|
|
$this->assertInstanceOf(TestModel::class, $this->crudPanel->model); |
|
16
|
|
|
$this->assertInstanceOf(Builder::class, $this->crudPanel->query); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function testSetModelFromModelClassName() |
|
20
|
|
|
{ |
|
21
|
|
|
$modelClassName = '\Backpack\CRUD\Tests\Unit\Models\TestModel'; |
|
22
|
|
|
|
|
23
|
|
|
$this->crudPanel->setModel($modelClassName); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertEquals($this->model, $this->crudPanel->model); |
|
26
|
|
|
$this->assertInstanceOf($modelClassName, $this->crudPanel->model); |
|
|
|
|
|
|
27
|
|
|
$this->assertInstanceOf(Builder::class, $this->crudPanel->query); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function testSetUnknownModel() |
|
31
|
|
|
{ |
|
32
|
|
|
$this->expectException(\Exception::class); |
|
33
|
|
|
|
|
34
|
|
|
$this->crudPanel->setModel('\Foo\Bar'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function testSetUnknownRouteName() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->expectException(\Exception::class); |
|
40
|
|
|
|
|
41
|
|
|
$this->crudPanel->setRouteName('unknown.route.name'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testSync() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->markTestIncomplete(); |
|
47
|
|
|
|
|
48
|
|
|
// TODO: the sync method should not be in the CrudPanel class and should not be exposed in the public API. |
|
49
|
|
|
// it is a utility method and should be refactored. |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|