Skip to content

Commit

Permalink
Add failing test using ChoiceFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Jun 8, 2022
1 parent e382717 commit 48b9e13
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 13 additions & 1 deletion tests/App/Admin/CategoryAdmin.php
Expand Up @@ -18,6 +18,8 @@
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\DoctrineMongoDBAdminBundle\Filter\ChoiceFilter;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

/**
Expand Down Expand Up @@ -52,7 +54,17 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
{
$filter
->add('id')
->add('name');
->add('name')
->add('type', ChoiceFilter::class, [
'field_type' => ChoiceType::class,
'field_options' => [
'choices' => [
'Type 1' => 'type1',
'Type 2' => 'type2',
],
'expanded' => false,
],
]);
}

protected function configureShowFields(ShowMapper $show): void
Expand Down
15 changes: 14 additions & 1 deletion tests/App/Document/Category.php
Expand Up @@ -32,10 +32,18 @@ class Category
*/
private $name;

public function __construct(string $id = '', string $name = '')
/**
* @ODM\Field(type="string")
*
* @var string
*/
private $type;

public function __construct(string $id = '', string $name = '', string $type = '')
{
$this->id = $id;
$this->name = $name;
$this->type = $type;
}

public function __toString(): string
Expand All @@ -62,4 +70,9 @@ public function setName(string $name): void
{
$this->name = $name;
}

public function getType(): string
{
return $this->type;
}
}

0 comments on commit 48b9e13

Please sign in to comment.