Skip to content

Commit

Permalink
Test entry options
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Oct 6, 2021
1 parent a58edab commit 25272a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v2

- name: Install
run: composer install --prefer-source
run: composer install

- name: Run PHP CS Fixer
run: php-cs-fixer fix --diff --dry-run
Expand Down
25 changes: 19 additions & 6 deletions tests/Form/CollectionJsTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@

namespace Tienvx\UX\CollectionJs\Tests\Form;

use Symfony\Component\Form\Tests\Extension\Core\Type\CollectionTypeTest;
use Symfony\Component\Form\Tests\Extension\Core\Type\FileTypeTest;
use Symfony\Component\Form\Tests\Extension\Core\Type\TextTypeTest;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Test\TypeTestCase;
use Tienvx\UX\CollectionJs\Form\CollectionJsType;

class CollectionJsTypeTest extends CollectionTypeTest
class CollectionJsTypeTest extends TypeTestCase
{
public const TESTED_TYPE = CollectionJsType::class;

public function testDefaultOptions()
{
$entryOptions = [
'label' => true,
'block_prefix' => 'custom_collection_js_entry',
];
$form = $this->factory
->create(static::TESTED_TYPE, null, [
'entry_type' => FileTypeTest::TESTED_TYPE,
'entry_type' => FileType::class,
'entry_options' => $entryOptions,
])
;
$this->assertSame($entryOptions + [
'block_name' => 'entry',
], $form->getConfig()->getOption('entry_options'));

$view = $form->createView();
$this->assertFalse($view->vars['allow_move_up']);
Expand All @@ -29,12 +37,17 @@ public function testCustomOptions()
{
$form = $this->factory
->create(static::TESTED_TYPE, null, [
'entry_type' => TextTypeTest::TESTED_TYPE,
'entry_type' => TextType::class,
'allow_move_up' => true,
'allow_move_down' => true,
'render_expanded' => true,
])
;
$this->assertSame([
'label' => false,
'block_prefix' => 'collection_js_entry',
'block_name' => 'entry',
], $form->getConfig()->getOption('entry_options'));

$view = $form->createView();
$this->assertTrue($view->vars['allow_move_up']);
Expand Down

0 comments on commit 25272a7

Please sign in to comment.