Skip to content

Commit

Permalink
Expand coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jun 1, 2024
1 parent 0b80668 commit f20e02a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion tests/TestCase/Command/TemplateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');

Expand All @@ -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
*
Expand Down Expand Up @@ -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));
Expand All @@ -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
*
Expand Down
Empty file.
Empty file.
Empty file.

0 comments on commit f20e02a

Please sign in to comment.