-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5569 from Laravel-Backpack/add-tests
Add miscelaneous tests for various crud functions
- Loading branch information
Showing
4 changed files
with
222 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Backpack\CRUD\Tests\Unit\CrudPanel; | ||
|
||
/** | ||
* @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Settings | ||
*/ | ||
class CrudPanelSettingsTest extends \Backpack\CRUD\Tests\config\CrudPanel\BaseCrudPanel | ||
{ | ||
public function testItCanAddASettingToCrudPanel() | ||
{ | ||
$this->crudPanel->set('create.test', 'value'); | ||
|
||
$this->assertEquals('value', $this->crudPanel->get('create.test')); | ||
} | ||
|
||
public function testItCanCheckIfASettingExist() | ||
{ | ||
$this->crudPanel->set('create.test', 'value'); | ||
|
||
$this->assertTrue($this->crudPanel->has('create.test')); | ||
$this->assertFalse($this->crudPanel->has('create.test2')); | ||
} | ||
|
||
public function testItCanGetOrSetASetting() | ||
{ | ||
$this->crudPanel->setting('create.test', 'value'); | ||
|
||
$this->assertEquals('value', $this->crudPanel->setting('create.test')); | ||
} | ||
|
||
public function testItCanGetAllSettingOrderedByKey() | ||
{ | ||
$this->crudPanel->set('create.test', 'value'); | ||
$this->crudPanel->set('create.ambat', 'value2'); | ||
$this->crudPanel->set('ambar.test', 'value3'); | ||
|
||
$this->assertEquals([ | ||
'ambar.test' => 'value3', | ||
'create.test' => 'value', | ||
'create.ambat' => 'value2', | ||
], $this->crudPanel->settings()); | ||
} | ||
|
||
public function testItCanSetOperationSettings() | ||
{ | ||
$this->crudPanel->setOperation('create'); | ||
|
||
$this->crudPanel->setOperationSetting('test', 'value'); | ||
$this->crudPanel->setOperationSetting('test', 'value', 'list'); | ||
|
||
$this->assertEquals('value', $this->crudPanel->get('create.test')); | ||
$this->assertEquals('value', $this->crudPanel->get('list.test')); | ||
} | ||
|
||
public function itCanCheckIfOperationSettingsExist() | ||
{ | ||
$this->crudPanel->setOperation('create'); | ||
|
||
$this->crudPanel->setOperationSetting('test', 'value'); | ||
$this->crudPanel->setOperationSetting('test', 'value', 'list'); | ||
|
||
$this->assertTrue('value', $this->crudPanel->hasOperationSetting('test')); | ||
$this->assertTrue('value', $this->crudPanel->hasOperationSetting('test', 'list')); | ||
} | ||
|
||
public function testItGetsTheOperationListFromSettings() | ||
{ | ||
$this->crudPanel->set('create.access', 'value'); | ||
$this->crudPanel->set('list.access', 'value2'); | ||
$this->crudPanel->set('something', 'value'); | ||
$this->crudPanel->set('whatever.not', 'value'); | ||
|
||
$this->assertEquals(['create', 'list'], $this->invokeMethod($this->crudPanel, 'getAvailableOperationsList')); | ||
} | ||
} |