Skip to content

Commit b74569b

Browse files
committed
Add tests
1 parent b56b2f0 commit b74569b

File tree

5 files changed

+52
-1
lines changed

5 files changed

+52
-1
lines changed

src/Config/Layouts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Layouts extends BaseConfig
1111
*
1212
* @var string
1313
*/
14-
public $default = '';
14+
public $default = 'Tatter\Layouts\Views\Layouts\Default';
1515

1616
/**
1717
* Provides a fallback to the default layout
File renamed without changes.

tests/ConfigTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use Tests\Support\TestCase;
4+
5+
/**
6+
* @internal
7+
*/
8+
final class ConfigTest extends TestCase
9+
{
10+
public function testUsesDefaultAsFallback()
11+
{
12+
$result = config('Layouts')->banana;
13+
14+
$this->assertSame('Tatter\Layouts\Views\Layouts\Default', $result);
15+
}
16+
17+
public function testSupportsRegistrars()
18+
{
19+
$result = config('Layouts')->foo;
20+
21+
$this->assertSame('bar', $result);
22+
}
23+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Tests\Support\Config;
4+
5+
class Registrar
6+
{
7+
/**
8+
* Adds a layout to the config to verify it
9+
* supports using Registrars.
10+
*
11+
* @return array<string,string>
12+
*/
13+
public static function Layouts(): array
14+
{
15+
return [
16+
'foo' => 'bar',
17+
];
18+
}
19+
}

tests/_support/TestCase.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Tests\Support;
4+
5+
use CodeIgniter\Test\CIUnitTestCase;
6+
7+
abstract class TestCase extends CIUnitTestCase
8+
{
9+
}

0 commit comments

Comments
 (0)