diff --git a/tests/TestCase/Command/TemplateCommandTest.php b/tests/TestCase/Command/TemplateCommandTest.php index 6ac9b0ec..715b80fe 100644 --- a/tests/TestCase/Command/TemplateCommandTest.php +++ b/tests/TestCase/Command/TemplateCommandTest.php @@ -17,6 +17,7 @@ namespace Bake\Test\TestCase\Command; use Bake\Command\TemplateCommand; +use Bake\Test\App\Model\Enum\ArticleStatus; use Bake\Test\App\Model\Enum\BakeUserStatus; use Bake\Test\App\Model\Table\BakeArticlesTable; use Bake\Test\TestCase\TestCase; @@ -459,6 +460,9 @@ public function testBakeView() */ public function testBakeViewEnum() { + $table = $this->fetchTable('BakeUsers'); + $table->getSchema()->setColumnType('status', EnumType::from(BakeUserStatus::class)); + $this->generatedFile = ROOT . 'templates/BakeUsers/view.php'; $this->exec('bake template bake_users view'); @@ -469,6 +473,26 @@ public function testBakeViewEnum() $this->assertSameAsFile(__FUNCTION__ . '.php', $result); } + /** + * test baking view with enum class + * + * @return void + */ + public function testBakeViewEnumNoLabel() + { + $table = $this->fetchTable('Articles'); + $table->getSchema()->setColumnType('status', EnumType::from(ArticleStatus::class)); + + $this->generatedFile = ROOT . 'templates/Articles/view.php'; + $this->exec('bake template articles view'); + + $this->assertExitCode(CommandInterface::CODE_SUCCESS); + $this->assertFileExists($this->generatedFile); + + $result = file_get_contents($this->generatedFile); + $this->assertSameAsFile(__FUNCTION__ . '.php', $result); + } + /** * Test generating view template with hidden fields * @@ -576,7 +600,7 @@ public function testBakeIndexWithIndexLimit() * * @return void */ - public function testBakeIndexWithEnum() + public function testBakeIndexWithEnumWithLabel() { $table = $this->fetchTable('BakeUsers'); $table->getSchema()->setColumnType('status', EnumType::from(BakeUserStatus::class)); @@ -591,6 +615,26 @@ public function testBakeIndexWithEnum() $this->assertSameAsFile(__FUNCTION__ . '.php', $result); } + /** + * test bake template with index enum types + * + * @return void + */ + public function testBakeIndexWithEnumNoLabel() + { + $table = $this->fetchTable('Articles'); + $table->getSchema()->setColumnType('status', EnumType::from(ArticleStatus::class)); + + $this->generatedFile = ROOT . 'templates/Articles/index.php'; + $this->exec('bake template articles index'); + + $this->assertExitCode(CommandInterface::CODE_SUCCESS); + $this->assertFileExists($this->generatedFile); + + $result = file_get_contents($this->generatedFile); + $this->assertSameAsFile(__FUNCTION__ . '.php', $result); + } + /** * test Bake with plugins * diff --git a/tests/comparisons/Template/testBakeIndexWithEnumNoLabel.php b/tests/comparisons/Template/testBakeIndexWithEnumNoLabel.php new file mode 100644 index 00000000..e69de29b diff --git a/tests/comparisons/Template/testBakeIndexWithEnumWithLabel.php b/tests/comparisons/Template/testBakeIndexWithEnumWithLabel.php new file mode 100644 index 00000000..e69de29b diff --git a/tests/comparisons/Template/testBakeViewEnumNoLabel.php b/tests/comparisons/Template/testBakeViewEnumNoLabel.php new file mode 100644 index 00000000..e69de29b