-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enum titles under field schema, not liform subarray (#fix Limenius/li…
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tests/Limenius/Liform/Tests/Transformer/ChoiceTransformerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Limenius\Liform\Tests\Liform\Transformer; | ||
|
||
use Symfony\Component\Form\Extension\Core\Type; | ||
use Symfony\Component\Form\Extension\Core\Type\FormType; | ||
use Limenius\Liform\Transformer\CompoundTransformer; | ||
use Limenius\Liform\Transformer; | ||
use Limenius\Liform\Resolver; | ||
use Limenius\Liform\Tests\LiformTestCase; | ||
|
||
/** | ||
* Class: ChoiceTransformerTest | ||
* | ||
* @see TypeTestCase | ||
*/ | ||
class ChoiceTransformerTest extends LiformTestCase | ||
{ | ||
|
||
/** | ||
* testPattern | ||
* | ||
*/ | ||
public function testPattern() | ||
{ | ||
$form = $this->factory->create(FormType::class) | ||
->add( | ||
'firstName', | ||
Type\ChoiceType::class, | ||
[ | ||
'choices' => ['a' => 'A', 'b' => 'B'], | ||
] | ||
); | ||
$resolver = new Resolver(); | ||
$resolver->setTransformer('choice', new Transformer\ChoiceTransformer()); | ||
$transformer = new CompoundTransformer($resolver); | ||
$transformed = $transformer->transform($form); | ||
$this->assertTrue(is_array($transformed)); | ||
$this->assertArrayHasKey('enum_titles', $transformed['properties']['firstName']); | ||
$this->assertEquals(['a', 'b'], $transformed['properties']['firstName']['enum_titles']); | ||
$this->assertArrayHasKey('enum', $transformed['properties']['firstName']); | ||
$this->assertEquals(['A', 'B'], $transformed['properties']['firstName']['enum']); | ||
} | ||
} |