1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\Tests\Unit\CrudPanel; |
4
|
|
|
|
5
|
|
|
use Backpack\CRUD\Tests\Unit\Models\User; |
6
|
|
|
use Illuminate\Routing\Route; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @covers Backpack\CRUD\app\Library\CrudPanel\Traits\HeadingsAndTitles |
10
|
|
|
* @covers Backpack\CRUD\app\Library\CrudPanel\CrudPanel |
11
|
|
|
*/ |
12
|
|
|
class CrudPanelTitlesAndHeadingsTest extends BaseDBCrudPanelTest |
13
|
|
|
{ |
14
|
|
|
public function testItCanSetAndGetTheTitleFromTheAction() |
15
|
|
|
{ |
16
|
|
|
$this->crudPanel->setTitle('test', 'create'); |
17
|
|
|
$this->assertEquals('test', $this->crudPanel->getTitle('create')); |
|
|
|
|
18
|
|
|
$this->assertEquals($this->crudPanel->get('create.title'), $this->crudPanel->getTitle('create')); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testItCanSetAndGetTheHeadingFromTheAction() |
22
|
|
|
{ |
23
|
|
|
$this->crudPanel->setHeading('test', 'create'); |
24
|
|
|
$this->assertEquals('test', $this->crudPanel->getHeading('create')); |
|
|
|
|
25
|
|
|
$this->assertEquals($this->crudPanel->get('create.heading'), $this->crudPanel->getHeading('create')); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testItCanSetAndGetTheSubheadingFromTheAction() |
29
|
|
|
{ |
30
|
|
|
$this->crudPanel->setSubheading('test', 'create'); |
31
|
|
|
$this->assertEquals('test', $this->crudPanel->getSubheading('create')); |
|
|
|
|
32
|
|
|
$this->assertEquals($this->crudPanel->get('create.subheading'), $this->crudPanel->getSubheading('create')); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testItCanSetAndGetTheSubheading() |
36
|
|
|
{ |
37
|
|
|
$this->crudPanel->setModel(User::class); |
38
|
|
|
$request = request()->create('/admin/users/create', 'POST', ['name' => 'foo']); |
39
|
|
|
$request->setRouteResolver(function () use ($request) { |
40
|
|
|
return (new Route('POST', 'admin/users/create', ['UserCrudController', 'create']))->bind($request); |
41
|
|
|
}); |
42
|
|
|
$this->crudPanel->setRequest($request); |
43
|
|
|
|
44
|
|
|
$this->crudPanel->setOperation('create'); |
45
|
|
|
$this->crudPanel->setSubheading('test'); |
46
|
|
|
$this->assertEquals('test', $this->crudPanel->getSubheading()); |
47
|
|
|
$this->assertEquals($this->crudPanel->get('create.subheading'), $this->crudPanel->getSubheading()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testItCanSetAndGetTheHeading() |
51
|
|
|
{ |
52
|
|
|
$this->crudPanel->setModel(User::class); |
53
|
|
|
$request = request()->create('/admin/users/create', 'POST', ['name' => 'foo']); |
54
|
|
|
$request->setRouteResolver(function () use ($request) { |
55
|
|
|
return (new Route('POST', 'admin/users/create', ['UserCrudController', 'create']))->bind($request); |
56
|
|
|
}); |
57
|
|
|
$this->crudPanel->setRequest($request); |
58
|
|
|
|
59
|
|
|
$this->crudPanel->setOperation('create'); |
60
|
|
|
$this->crudPanel->setHeading('test'); |
61
|
|
|
$this->assertEquals('test', $this->crudPanel->getHeading()); |
62
|
|
|
$this->assertEquals($this->crudPanel->get('create.heading'), $this->crudPanel->getHeading()); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testItCanSetAndGetTheTitle() |
66
|
|
|
{ |
67
|
|
|
$this->crudPanel->setModel(User::class); |
68
|
|
|
$request = request()->create('/admin/users/create', 'POST', ['name' => 'foo']); |
69
|
|
|
$request->setRouteResolver(function () use ($request) { |
70
|
|
|
return (new Route('POST', 'admin/users/create', ['UserCrudController', 'create']))->bind($request); |
71
|
|
|
}); |
72
|
|
|
$this->crudPanel->setRequest($request); |
73
|
|
|
|
74
|
|
|
$this->crudPanel->setOperation('create'); |
75
|
|
|
$this->crudPanel->setTitle('test'); |
76
|
|
|
|
77
|
|
|
$this->assertEquals('test', $this->crudPanel->getTitle()); |
78
|
|
|
$this->assertEquals($this->crudPanel->get('create.title'), $this->crudPanel->getTitle()); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|