Skip to content

Commit

Permalink
Review container usage in tests (#1280)
Browse files Browse the repository at this point in the history
  • Loading branch information
deguif authored Sep 29, 2022
1 parent 0379e3f commit 76b7bf1
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions Tests/Form/TypeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Mopa\Bundle\BootstrapBundle\Form\Extension as MopaExtensions;
use Mopa\Bundle\BootstrapBundle\Form\Type as MopaTypes;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormBuilder;
Expand All @@ -28,11 +27,6 @@
*/
class TypeTestCase extends KernelTestCase
{
/**
* @var ContainerInterface
*/
protected $container;

/**
* @var FormFactoryInterface
*/
Expand All @@ -54,7 +48,7 @@ class TypeTestCase extends KernelTestCase
protected function setUp(): void
{
self::bootKernel();
$this->container = self::$kernel->getContainer();

$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->factory = Forms::createFormFactoryBuilder()
->addExtensions($this->getExtensions())
Expand All @@ -76,13 +70,13 @@ protected function getTypeExtensions()
return [
new MopaExtensions\WidgetCollectionFormTypeExtension(
[
'render_collection_item' => $this->container->getParameter(
'render_collection_item' => self::$container->getParameter(
'mopa_bootstrap.form.render_collection_item'
),
'widget_add_btn' => $this->container->getParameter(
'widget_add_btn' => self::$container->getParameter(
'mopa_bootstrap.form.collection.widget_add_btn'
),
'widget_remove_btn' => $this->container->getParameter(
'widget_remove_btn' => self::$container->getParameter(
'mopa_bootstrap.form.collection.widget_remove_btn'
),
]
Expand All @@ -91,62 +85,62 @@ protected function getTypeExtensions()
new MopaExtensions\DateTypeExtension(
[
'date_wrapper_class' => [
'year' => $this->container->getParameter('mopa_bootstrap.form.date_wrapper_class.year'),
'month' => $this->container->getParameter('mopa_bootstrap.form.date_wrapper_class.month'),
'day' => $this->container->getParameter('mopa_bootstrap.form.date_wrapper_class.day'),
'year' => self::$container->getParameter('mopa_bootstrap.form.date_wrapper_class.year'),
'month' => self::$container->getParameter('mopa_bootstrap.form.date_wrapper_class.month'),
'day' => self::$container->getParameter('mopa_bootstrap.form.date_wrapper_class.day'),
],
]
),
new MopaExtensions\ErrorTypeFormTypeExtension(
['error_type' => $this->container->getParameter('mopa_bootstrap.form.error_type')]
['error_type' => self::$container->getParameter('mopa_bootstrap.form.error_type')]
),
new MopaExtensions\HelpFormTypeExtension(
[
'help_label_tooltip' => $this->container->getParameter('mopa_bootstrap.form.help_label.tooltip'),
'help_label_popover' => $this->container->getParameter('mopa_bootstrap.form.help_label.popover'),
'help_block_tooltip' => $this->container->getParameter('mopa_bootstrap.form.help_block.tooltip'),
'help_block_popover' => $this->container->getParameter('mopa_bootstrap.form.help_block.popover'),
'help_widget_popover' => $this->container->getParameter('mopa_bootstrap.form.help_widget.popover'),
'help_label_tooltip' => self::$container->getParameter('mopa_bootstrap.form.help_label.tooltip'),
'help_label_popover' => self::$container->getParameter('mopa_bootstrap.form.help_label.popover'),
'help_block_tooltip' => self::$container->getParameter('mopa_bootstrap.form.help_block.tooltip'),
'help_block_popover' => self::$container->getParameter('mopa_bootstrap.form.help_block.popover'),
'help_widget_popover' => self::$container->getParameter('mopa_bootstrap.form.help_widget.popover'),
]
),
new MopaExtensions\LayoutFormTypeExtension(
[
'layout' => $this->container->getParameter(
'layout' => self::$container->getParameter(
'mopa_bootstrap.form.layout'
),
'horizontal_label_class' => $this->container->getParameter(
'horizontal_label_class' => self::$container->getParameter(
'mopa_bootstrap.form.horizontal_label_class'
),
'horizontal_label_div_class' => $this->container->getParameter(
'horizontal_label_div_class' => self::$container->getParameter(
'mopa_bootstrap.form.horizontal_label_div_class'
),
'horizontal_label_offset_class' => $this->container->getParameter(
'horizontal_label_offset_class' => self::$container->getParameter(
'mopa_bootstrap.form.horizontal_label_offset_class'
),
'horizontal_input_wrapper_class' => $this->container->getParameter(
'horizontal_input_wrapper_class' => self::$container->getParameter(
'mopa_bootstrap.form.horizontal_input_wrapper_class'
),
]
),
new MopaExtensions\IconButtonExtension(),
new MopaExtensions\LegendFormTypeExtension(
[
'render_fieldset' => $this->container->getParameter(
'render_fieldset' => self::$container->getParameter(
'mopa_bootstrap.form.render_fieldset'
),
'show_legend' => $this->container->getParameter(
'show_legend' => self::$container->getParameter(
'mopa_bootstrap.form.show_legend'
),
'show_child_legend' => $this->container->getParameter(
'show_child_legend' => self::$container->getParameter(
'mopa_bootstrap.form.show_child_legend'
),
'legend_tag' => $this->container->getParameter(
'legend_tag' => self::$container->getParameter(
'mopa_bootstrap.form.legend_tag'
),
'render_required_asterisk' => $this->container->getParameter(
'render_required_asterisk' => self::$container->getParameter(
'mopa_bootstrap.form.render_required_asterisk'
),
'render_optional_text' => $this->container->getParameter(
'render_optional_text' => self::$container->getParameter(
'mopa_bootstrap.form.render_optional_text'
),
]
Expand All @@ -155,11 +149,11 @@ protected function getTypeExtensions()
new MopaExtensions\StaticTextExtension(),
new MopaExtensions\TabbedFormTypeExtension(
$this->factory,
['class' => $this->container->getParameter('mopa_bootstrap.form.tabs.class')]
['class' => self::$container->getParameter('mopa_bootstrap.form.tabs.class')]
),
new MopaExtensions\TimeTypeExtension(),
new MopaExtensions\WidgetFormTypeExtension(
['checkbox_label' => $this->container->getParameter('mopa_bootstrap.form.checkbox_label')]
['checkbox_label' => self::$container->getParameter('mopa_bootstrap.form.checkbox_label')]
),
];
}
Expand Down

0 comments on commit 76b7bf1

Please sign in to comment.