|
|
@@ -20,6 +20,7 @@ use ArrayObject;
|
|
|
use Cake\Collection\Collection;
|
|
|
use Cake\Core\Configure;
|
|
|
use Cake\Core\Exception\CakeException;
|
|
|
+use Cake\Database\Type\EnumType;
|
|
|
use Cake\Form\Form;
|
|
|
use Cake\Http\ServerRequest;
|
|
|
use Cake\I18n\Date;
|
|
|
@@ -38,6 +39,7 @@ use InvalidArgumentException;
|
|
|
use ReflectionProperty;
|
|
|
use TestApp\Model\Entity\Article;
|
|
|
use TestApp\Model\Enum\ArticleStatus;
|
|
|
+use TestApp\Model\Enum\ArticleStatusLabel;
|
|
|
use TestApp\Model\Table\ContactsTable;
|
|
|
use TestApp\Model\Table\ValidateUsersTable;
|
|
|
use TestApp\View\Form\StubContext;
|
|
|
@@ -3621,6 +3623,53 @@ class FormHelperTest extends TestCase
|
|
|
'/div',
|
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
+
|
|
|
+ $articlesTable = $this->getTableLocator()->get('Articles');
|
|
|
+ $articlesTable->getSchema()->setColumnType(
|
|
|
+ 'published',
|
|
|
+ EnumType::from(ArticleStatus::class)
|
|
|
+ );
|
|
|
+ $this->Form->create($articlesTable->newEmptyEntity());
|
|
|
+ $result = $this->Form->control('published');
|
|
|
+ $expected = [
|
|
|
+ 'div' => ['class' => 'input select'],
|
|
|
+ 'label' => ['for' => 'published'],
|
|
|
+ 'Published',
|
|
|
+ '/label',
|
|
|
+ 'select' => ['name' => 'published', 'id' => 'published'],
|
|
|
+ ['option' => ['value' => 'Y']],
|
|
|
+ 'PUBLISHED',
|
|
|
+ '/option',
|
|
|
+ ['option' => ['value' => 'N', 'selected' => 'selected']],
|
|
|
+ 'UNPUBLISHED',
|
|
|
+ '/option',
|
|
|
+ '/select',
|
|
|
+ '/div',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+
|
|
|
+ $articlesTable->getSchema()->setColumnType(
|
|
|
+ 'published',
|
|
|
+ EnumType::from(ArticleStatusLabel::class)
|
|
|
+ );
|
|
|
+ $this->Form->create($articlesTable->newEmptyEntity());
|
|
|
+ $result = $this->Form->control('published');
|
|
|
+ $expected = [
|
|
|
+ 'div' => ['class' => 'input select'],
|
|
|
+ 'label' => ['for' => 'published'],
|
|
|
+ 'Published',
|
|
|
+ '/label',
|
|
|
+ 'select' => ['name' => 'published', 'id' => 'published'],
|
|
|
+ ['option' => ['value' => 'Y']],
|
|
|
+ 'Is published',
|
|
|
+ '/option',
|
|
|
+ ['option' => ['value' => 'N', 'selected' => 'selected']],
|
|
|
+ 'Is unpublished',
|
|
|
+ '/option',
|
|
|
+ '/select',
|
|
|
+ '/div',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -4701,6 +4750,28 @@ class FormHelperTest extends TestCase
|
|
|
'/div',
|
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
+
|
|
|
+ $articlesTable = $this->getTableLocator()->get('Articles');
|
|
|
+ $articlesTable->getSchema()->setColumnType(
|
|
|
+ 'published',
|
|
|
+ EnumType::from(ArticleStatus::class)
|
|
|
+ );
|
|
|
+ $this->Form->create($articlesTable->newEmptyEntity());
|
|
|
+ $result = $this->Form->control('published', ['type' => 'radio', 'label' => false,]);
|
|
|
+ $expected = [
|
|
|
+ ['div' => ['class' => 'input radio']],
|
|
|
+ 'input' => ['type' => 'hidden', 'name' => 'published', 'value' => '', 'id' => 'published'],
|
|
|
+ ['label' => ['for' => 'published-y']],
|
|
|
+ ['input' => ['type' => 'radio', 'name' => 'published', 'value' => 'Y', 'id' => 'published-y']],
|
|
|
+ 'PUBLISHED',
|
|
|
+ '/label',
|
|
|
+ ['label' => ['for' => 'published-n']],
|
|
|
+ ['input' => ['type' => 'radio', 'name' => 'published', 'value' => 'N', 'id' => 'published-n', 'checked' => 'checked']],
|
|
|
+ 'UNPUBLISHED',
|
|
|
+ '/label',
|
|
|
+ '/div',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
}
|
|
|
|
|
|
/**
|