forked from Sylius/Sylius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Sylius#7744 from pamil/pull-request/7719
Pass entry options to entry types in ResourceTranslationsType
- Loading branch information
Showing
2 changed files
with
66 additions
and
3 deletions.
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
61 changes: 61 additions & 0 deletions
61
src/Sylius/Bundle/ResourceBundle/Tests/Form/Type/ResourceTranslationsTypeTest.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,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sylius\Bundle\ResourceBundle\Tests\Form\Type; | ||
|
||
use Prophecy\Prophecy\ObjectProphecy; | ||
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceTranslationsType; | ||
use Sylius\Component\Resource\Translation\Provider\TranslationLocaleProviderInterface; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\PreloadedExtension; | ||
use Symfony\Component\Form\Test\TypeTestCase; | ||
|
||
/** | ||
* @author Kamil Kokot <[email protected]> | ||
*/ | ||
final class ResourceTranslationsTypeTest extends TypeTestCase | ||
{ | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getExtensions() | ||
{ | ||
/** @var TranslationLocaleProviderInterface|ObjectProphecy $translationLocaleProvider */ | ||
$translationLocaleProvider = $this->prophesize(TranslationLocaleProviderInterface::class); | ||
$translationLocaleProvider->getDefaultLocaleCode()->willReturn('en_US'); | ||
$translationLocaleProvider->getDefinedLocalesCodes()->willReturn(['en_US', 'pl_PL']); | ||
|
||
$resourceTranslationsType = new ResourceTranslationsType($translationLocaleProvider->reveal()); | ||
|
||
return [ | ||
new PreloadedExtension([$resourceTranslationsType], []), | ||
]; | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_respects_entry_options() | ||
{ | ||
$form = $this->factory->create( | ||
ResourceTranslationsType::class, | ||
null, | ||
['entry_type' => TextType::class, 'entry_options' => ['empty_data' => 'Default']] | ||
); | ||
|
||
// Testing child type because of `$event->getForm()->getParent()->getData()` inside ResourceTranslationsType::submit() | ||
$englishTranslationForm = $form->get('en_US'); | ||
$englishTranslationForm->submit(null); | ||
|
||
$this->assertEquals('Default', $englishTranslationForm->getData()); | ||
} | ||
} |