Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Config/Generators.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions system/Commands/Generators/CellGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 8 additions & 6 deletions tests/system/Commands/CellGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("<div>\n <!-- Your HTML here -->\n</div>\n", $this->getFileContents($file));
}

public function testGenerateCellSimpleName()
Expand All @@ -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("<div>\n <!-- Your HTML here -->\n</div>\n", $this->getFileContents($file));
}
}