|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\Tests\Unit\CrudPanel; |
|
4
|
|
|
|
|
5
|
|
|
use Backpack\CRUD\ViewNamespaces; |
|
6
|
|
|
use Config; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @covers Backpack\CRUD\ViewNamespaces |
|
10
|
|
|
*/ |
|
11
|
|
|
class ViewNamespacesTest extends BaseCrudPanelTest |
|
12
|
|
|
{ |
|
13
|
|
|
public function testAddSingleViewNamespace() |
|
14
|
|
|
{ |
|
15
|
|
|
ViewNamespaces::addFor('fields', 'crud::fields'); |
|
16
|
|
|
ViewNamespaces::addFor('fields', 'pro::fields'); |
|
17
|
|
|
$this->assertCount(2, ViewNamespaces::getFor('fields')); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function testAddMultipleViewNamespace() |
|
21
|
|
|
{ |
|
22
|
|
|
ViewNamespaces::addFor('fields', ['crud::fields', 'pro::fields']); |
|
23
|
|
|
$this->assertCount(2, ViewNamespaces::getFor('fields')); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testGetWithFallbackFromConfigViewNamespace() |
|
27
|
|
|
{ |
|
28
|
|
|
Config::set('backpack.crud.fallback_namespace', ['fields' => ['fallback::fields']]); |
|
29
|
|
|
Config::set('backpack.crud.view_namespaces', ['fields' => ['config::fields']]); |
|
30
|
|
|
ViewNamespaces::addFor('fields', ['crud::fields', 'pro::fields']); |
|
31
|
|
|
$this->assertCount(4, ViewNamespaces::getWithFallbackFor('fields', 'backpack.crud.fallback_namespace.fields')); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testItCanGetTheViewPathsForGivenElement() |
|
35
|
|
|
{ |
|
36
|
|
|
ViewNamespaces::addFor('fields', ['crud::fields', 'pro::fields']); |
|
37
|
|
|
$viewPaths = ViewNamespaces::getViewPathsFor('fields', 'test'); |
|
38
|
|
|
$this->assertCount(2, $viewPaths); |
|
39
|
|
|
$this->assertEquals(['crud::fields.test', 'pro::fields.test'], array_values($viewPaths)); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|