diff --git a/app/Config/Generators.php b/app/Config/Generators.php index c766d321648b..6566a31e851e 100644 --- a/app/Config/Generators.php +++ b/app/Config/Generators.php @@ -27,6 +27,7 @@ class Generators extends BaseConfig */ public array $views = [ 'make:cell' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php', + 'make:cell_view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php', 'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php', 'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php', 'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php', diff --git a/system/Commands/Generators/CellGenerator.php b/system/Commands/Generators/CellGenerator.php index 38eedae63eb2..e0014e955514 100644 --- a/system/Commands/Generators/CellGenerator.php +++ b/system/Commands/Generators/CellGenerator.php @@ -93,6 +93,7 @@ public function run(array $params) $segments[] = $view; $view = implode('\\', $segments); + $this->name = 'make:cell_view'; $this->template = 'cell_view.tpl.php'; $this->generateView($view, $params); diff --git a/tests/system/Commands/CellGeneratorTest.php b/tests/system/Commands/CellGeneratorTest.php index 41b8bc51f031..e15f4b9f2cef 100644 --- a/tests/system/Commands/CellGeneratorTest.php +++ b/tests/system/Commands/CellGeneratorTest.php @@ -52,14 +52,15 @@ public function testGenerateCell() // Check the class was generated $file = APPPATH . 'Cells/RecentCell.php'; + $this->assertStringContainsString('File created: ' . clean_path($file), $this->getStreamFilterBuffer()); $this->assertFileExists($file); - $contents = $this->getFileContents($file); - $this->assertStringContainsString('class RecentCell extends Cell', $contents); + $this->assertStringContainsString('class RecentCell extends Cell', $this->getFileContents($file)); // Check the view was generated $file = APPPATH . 'Cells/recent_cell.php'; - $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); + $this->assertStringContainsString('File created: ' . clean_path($file), $this->getStreamFilterBuffer()); $this->assertFileExists($file); + $this->assertSame("
\n \n
\n", $this->getFileContents($file)); } public function testGenerateCellSimpleName() @@ -68,13 +69,14 @@ public function testGenerateCellSimpleName() // Check the class was generated $file = APPPATH . 'Cells/Another.php'; + $this->assertStringContainsString('File created: ' . clean_path($file), $this->getStreamFilterBuffer()); $this->assertFileExists($file); - $contents = $this->getFileContents($file); - $this->assertStringContainsString('class Another extends Cell', $contents); + $this->assertStringContainsString('class Another extends Cell', $this->getFileContents($file)); // Check the view was generated $file = APPPATH . 'Cells/another.php'; - $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); + $this->assertStringContainsString('File created: ' . clean_path($file), $this->getStreamFilterBuffer()); $this->assertFileExists($file); + $this->assertSame("
\n \n
\n", $this->getFileContents($file)); } }