Skip to content

Commit

Permalink
Bug - fix symfony batch extension (#49)
Browse files Browse the repository at this point in the history
* Bug - fix symfony batch extension

* - Removed broken test after upgrade from symfony 3.4.25 to 3.4.26
- Downgraded symfony/security version to ^3.4
  • Loading branch information
wlodekj authored and norberttech committed Apr 18, 2019
1 parent 25bbf52 commit 79d8a58
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 34 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"sensio/framework-extra-bundle": "^5.3",
"symfony/twig-bundle": "^3.4",
"doctrine/orm": "^2.5",
"symfony/security-csrf": "^4.2"
"symfony/security-csrf": "^3.4"
},
"require-dev": {
"symfony/class-loader": "^3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public function it_adds_actions_choice_to_form_when_actions_are_defined(

$formBuilder->add('action', ChoiceType::class, [
'choices' => [
0 => 'crud.list.batch.empty_choice',
'path_to_batch_action' => 'batch_action_label'
'crud.list.batch.empty_choice' => 0,
'batch_action_label' => 'path_to_batch_action'
],
'translation_domain' => 'AdminPanelBundle'
])->willReturn();
Expand Down Expand Up @@ -207,8 +207,8 @@ public function it_adds_redirect_uri_to_actions_when_no_redirect_uri_is_defined(

$formBuilder->add('action', ChoiceType::class, [
'choices' => [
0 => 'crud.list.batch.empty_choice',
'path_to_batch_action' => 'batch_action_label'
'crud.list.batch.empty_choice' => 0,
'batch_action_label' => 'path_to_batch_action'
],
'translation_domain' => 'AdminPanelBundle'
])->willReturn();
Expand Down Expand Up @@ -258,8 +258,8 @@ public function it_does_not_add_redirect_uri_to_actions_when_redirect_uri_option

$formBuilder->add('action', ChoiceType::class, [
'choices' => [
0 => 'crud.list.batch.empty_choice',
'path_to_batch_action' => 'batch_action_label'
'crud.list.batch.empty_choice' => 0,
'batch_action_label' => 'path_to_batch_action'
],
'translation_domain' => 'AdminPanelBundle'
])->willReturn();
Expand Down Expand Up @@ -304,8 +304,8 @@ public function it_allows_to_pass_route_name_and_additional_parameters_to_batch_

$formBuilder->add('action', ChoiceType::class, [
'choices' => [
0 => 'crud.list.batch.empty_choice',
'path_to_batch_action' => 'action_name'
'crud.list.batch.empty_choice' => 0,
'action_name' => 'path_to_batch_action'
],
'translation_domain' => 'AdminPanelBundle'
])->willReturn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
namespace spec\AdminPanel\Symfony\AdminBundle\DependencyInjection\Compiler;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Config\Resource\ResourceInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;

class ResourceRepositoryPassSpec extends ObjectBehavior
{
Expand All @@ -18,22 +14,4 @@ public function it_does_nothing_when_there_is_no_resource_extension(ContainerBui
$container->hasExtension('admin_panel_resource_repository')->willReturn(false);
$this->process($container);
}

public function it_loads_resources_config_only_if_resource_repository_extension_exists(
ContainerBuilder $container,
ParameterBag $bag
) {
$container->hasExtension(Argument::type('string'))->willReturn(false);
$container->hasExtension('admin_panel_resource_repository')->willReturn(true);

$container->fileExists(Argument::type('string'))->willReturn(true);

$container->getParameterBag()->willReturn($bag);
$container->setDefinition(
Argument::type('string'),
Argument::type('Symfony\Component\DependencyInjection\Definition')
)->shouldBeCalled();

$this->process($container);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ function (Options $options, $value) use ($self) {
*/
private function buildBatchActions(ColumnTypeInterface $column)
{
$batchActions = ['crud.list.batch.empty_choice'];
$batchActions['crud.list.batch.empty_choice'] = 0;

foreach ($column->getOption('actions') as $name => $action) {
$actionOptions = $this->actionOptionsResolver->resolve($action);

$batchActions[$this->getBatchActionUrl($actionOptions)] =
isset($actionOptions['label']) ? $actionOptions['label'] : $name;
$batchActions[
isset($actionOptions['label']) ? $actionOptions['label'] : $name
] = $this->getBatchActionUrl($actionOptions);
}

return $batchActions;
Expand Down

0 comments on commit 79d8a58

Please sign in to comment.