|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\Tests\Unit\CrudPanel; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Settings |
|
7
|
|
|
*/ |
|
8
|
|
|
class CrudPanelSettingsTest extends \Backpack\CRUD\Tests\config\CrudPanel\BaseCrudPanel |
|
9
|
|
|
{ |
|
10
|
|
|
public function testItCanAddASettingToCrudPanel() |
|
11
|
|
|
{ |
|
12
|
|
|
$this->crudPanel->set('create.test', 'value'); |
|
13
|
|
|
|
|
14
|
|
|
$this->assertEquals('value', $this->crudPanel->get('create.test')); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function testItCanCheckIfASettingExist() |
|
18
|
|
|
{ |
|
19
|
|
|
$this->crudPanel->set('create.test', 'value'); |
|
20
|
|
|
|
|
21
|
|
|
$this->assertTrue($this->crudPanel->has('create.test')); |
|
22
|
|
|
$this->assertFalse($this->crudPanel->has('create.test2')); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function testItCanGetOrSetASetting() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->crudPanel->setting('create.test', 'value'); |
|
28
|
|
|
|
|
29
|
|
|
$this->assertEquals('value', $this->crudPanel->setting('create.test')); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testItCanGetAllSettingOrderedByKey() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->crudPanel->set('create.test', 'value'); |
|
35
|
|
|
$this->crudPanel->set('create.ambat', 'value2'); |
|
36
|
|
|
$this->crudPanel->set('ambar.test', 'value3'); |
|
37
|
|
|
|
|
38
|
|
|
$this->assertEquals([ |
|
39
|
|
|
'ambar.test' => 'value3', |
|
40
|
|
|
'create.test' => 'value', |
|
41
|
|
|
'create.ambat' => 'value2', |
|
42
|
|
|
], $this->crudPanel->settings()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testItCanSetOperationSettings() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->crudPanel->setOperation('create'); |
|
48
|
|
|
|
|
49
|
|
|
$this->crudPanel->setOperationSetting('test', 'value'); |
|
50
|
|
|
$this->crudPanel->setOperationSetting('test', 'value', 'list'); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertEquals('value', $this->crudPanel->get('create.test')); |
|
53
|
|
|
$this->assertEquals('value', $this->crudPanel->get('list.test')); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testitCanCheckIfOperationSettingsExist() |
|
57
|
|
|
{ |
|
58
|
|
|
$this->crudPanel->setOperation('create'); |
|
59
|
|
|
|
|
60
|
|
|
$this->crudPanel->setOperationSetting('test', 'value'); |
|
61
|
|
|
$this->crudPanel->setOperationSetting('test', 'value', 'list'); |
|
62
|
|
|
|
|
63
|
|
|
$this->assertTrue($this->crudPanel->hasOperationSetting('test')); |
|
64
|
|
|
$this->assertTrue($this->crudPanel->hasOperationSetting('test', 'list')); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function testItCanSetOperationSettingsForCurrentOperation() |
|
68
|
|
|
{ |
|
69
|
|
|
$this->crudPanel->setOperation('create'); |
|
70
|
|
|
|
|
71
|
|
|
$this->crudPanel->operationSetting('test', 'value'); |
|
72
|
|
|
|
|
73
|
|
|
$this->assertEquals('value', $this->crudPanel->get('create.test')); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function testItGetsTheOperationListFromSettings() |
|
77
|
|
|
{ |
|
78
|
|
|
$this->crudPanel->set('create.access', 'value'); |
|
79
|
|
|
$this->crudPanel->set('list.access', 'value2'); |
|
80
|
|
|
$this->crudPanel->set('something', 'value'); |
|
81
|
|
|
$this->crudPanel->set('whatever.not', 'value'); |
|
82
|
|
|
|
|
83
|
|
|
$this->assertEquals(['create', 'list'], $this->invokeMethod($this->crudPanel, 'getAvailableOperationsList')); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|