Skip to content

Commit 6b60878

Browse files
authored
Merge pull request #1 from tattersoftware/tests
Tests
2 parents dce1493 + b74569b commit 6b60878

File tree

6 files changed

+94
-43
lines changed

6 files changed

+94
-43
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

src/Layouts/Default.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/Views/Layouts/Default.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6+
<meta name="description" content="<?= $headerDescription ?? 'Layouts' ?>">
7+
<meta name="author" content="<?= $headerAuthor ?? 'Tatter Software' ?>">
8+
<meta name="theme-color" content="#7952b3">
9+
<title><?= $headerTitle ?? 'Website' ?></title>
10+
11+
<!-- Bootstrap core CSS -->
12+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
13+
14+
<?= $this->renderSection('headerAssets') ?>
15+
16+
</head>
17+
<body>
18+
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
19+
<a class="navbar-brand" href="<?= site_url() ?>">Home</a>
20+
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
21+
<span class="navbar-toggler-icon"></span>
22+
</button>
23+
24+
<div class="collapse navbar-collapse" id="navbars">
25+
26+
<?= $this->renderSection('navbar') ?>
27+
28+
</div>
29+
</nav>
30+
<main role="main" class="container my-5">
31+
32+
<?= $this->renderSection('main') ?>
33+
34+
</main><!-- /.container -->
35+
36+
<!-- Bootstrap bundle JS -->
37+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
38+
39+
<?= $this->renderSection('footerAssets') ?>
40+
41+
</body>
42+
</html>

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)