From 328da7d08ca0dde2f180b4eb2f8474167d65aed7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 17 Mar 2023 13:41:30 +0900 Subject: [PATCH 1/3] docs: add @property --- src/CI3Compatible/Core/CI_Controller.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CI3Compatible/Core/CI_Controller.php b/src/CI3Compatible/Core/CI_Controller.php index d2cc57c..5729241 100644 --- a/src/CI3Compatible/Core/CI_Controller.php +++ b/src/CI3Compatible/Core/CI_Controller.php @@ -19,6 +19,9 @@ use Kenjis\CI3Compatible\Internal\DebugLog; use Psr\Log\LoggerInterface; +/** + * @property CI_Input $input + */ #[\AllowDynamicProperties] class CI_Controller extends BaseController { From 4c43f45e138720867e97b4e26c7645f4708a6271 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 17 Mar 2023 13:41:59 +0900 Subject: [PATCH 2/3] test: add test for nested view --- tests/App/Views/body.php | 1 + tests/App/Views/layout.php | 5 +++++ tests/CI3Compatible/Core/CI_LoaderTest.php | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/App/Views/body.php create mode 100644 tests/App/Views/layout.php diff --git a/tests/App/Views/body.php b/tests/App/Views/body.php new file mode 100644 index 0000000..89f6246 --- /dev/null +++ b/tests/App/Views/body.php @@ -0,0 +1 @@ +

This is body.

diff --git a/tests/App/Views/layout.php b/tests/App/Views/layout.php new file mode 100644 index 0000000..34cb637 --- /dev/null +++ b/tests/App/Views/layout.php @@ -0,0 +1,5 @@ +

This is layout header.

+load->view('body'); +?> +

This is layout footer.

diff --git a/tests/CI3Compatible/Core/CI_LoaderTest.php b/tests/CI3Compatible/Core/CI_LoaderTest.php index ebe0d45..35f13bd 100644 --- a/tests/CI3Compatible/Core/CI_LoaderTest.php +++ b/tests/CI3Compatible/Core/CI_LoaderTest.php @@ -7,6 +7,8 @@ use App\Libraries\Validation\Field_validation; use App\Models\News_model; use App\Models\Shop\Shop_model; +use CodeIgniter\Config\Factories; +use Config\Paths; use Kenjis\CI3Compatible\Database\CI_DB; use Kenjis\CI3Compatible\Database\CI_DB_forge; use Kenjis\CI3Compatible\Library\CI_Form_validation; @@ -69,6 +71,25 @@ public function test_view_output_return_false(): void ); } + public function test_view_nested(): void + { + $pathConfig = config(Paths::class); + $pathConfig->viewDirectory = __DIR__ . '/../../App/Views/'; + Factories::injectMock('config', 'Paths', $pathConfig); + $this->loader = new CI_Loader(); + $this->controller = new CI_Controller(); + $this->loader->setController($this->controller); + + $output = $this->loader->view('layout', [], true); + + $this->assertStringContainsString( + '

This is layout header.

+

This is body.

+

This is layout footer.

', + $output + ); + } + public function test_model_loads_News_model(): void { $ret = $this->loader->model('news_model'); From c444e73b1c4140f8aca6f9b8176e3a0f91a350be Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 17 Mar 2023 13:52:17 +0900 Subject: [PATCH 3/3] chore: add excludePaths --- phpstan.neon | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index b3059dc..7fe4766 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -11,3 +11,5 @@ parameters: scanDirectories: - vendor/codeigniter4/codeigniter4/system/Helpers - src/CI3Compatible/Helper + excludePaths: + - tests/App/Views/*