|
17 | 17 | use PHPUnit\Framework\TestCase;
|
18 | 18 | use Sonata\AdminBundle\Admin\AbstractAdmin;
|
19 | 19 | use Sonata\AdminBundle\Admin\Pool;
|
20 |
| -use Sonata\AdminBundle\Mapper\BaseGroupedMapper; |
21 | 20 | use Sonata\AdminBundle\Tests\Fixtures\Mapper\AbstractDummyGroupedMapper;
|
22 | 21 | use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface;
|
23 | 22 | use Symfony\Component\DependencyInjection\Container;
|
|
28 | 27 | final class BaseGroupedMapperTest extends TestCase
|
29 | 28 | {
|
30 | 29 | /**
|
31 |
| - * @var BaseGroupedMapper<object>&MockObject |
| 30 | + * @var AbstractDummyGroupedMapper&MockObject |
32 | 31 | */
|
33 | 32 | protected $baseGroupedMapper;
|
34 | 33 |
|
@@ -120,6 +119,50 @@ public function testTab2(): void
|
120 | 119 | static::assertCount(0, $this->groups);
|
121 | 120 | }
|
122 | 121 |
|
| 122 | + public function testRemoveGroup(): void |
| 123 | + { |
| 124 | + static::assertCount(0, $this->tabs); |
| 125 | + static::assertCount(0, $this->groups); |
| 126 | + |
| 127 | + $this->baseGroupedMapper |
| 128 | + ->tab('fooTab1') |
| 129 | + ->with('fooGroup1') |
| 130 | + ->add('field1', 'name1') |
| 131 | + ->end() |
| 132 | + ->end(); |
| 133 | + |
| 134 | + static::assertCount(1, $this->tabs); |
| 135 | + static::assertCount(1, $this->groups); |
| 136 | + |
| 137 | + $this->baseGroupedMapper->expects(static::once())->method('remove')->with('field1'); |
| 138 | + $this->baseGroupedMapper->removeGroup('fooGroup1', 'fooTab1'); |
| 139 | + |
| 140 | + static::assertCount(1, $this->tabs); |
| 141 | + static::assertCount(0, $this->groups); |
| 142 | + } |
| 143 | + |
| 144 | + public function testRemoveTab(): void |
| 145 | + { |
| 146 | + static::assertCount(0, $this->tabs); |
| 147 | + static::assertCount(0, $this->groups); |
| 148 | + |
| 149 | + $this->baseGroupedMapper |
| 150 | + ->tab('fooTab1') |
| 151 | + ->with('fooGroup1') |
| 152 | + ->add('field1', 'name1') |
| 153 | + ->end() |
| 154 | + ->end(); |
| 155 | + |
| 156 | + static::assertCount(1, $this->tabs); |
| 157 | + static::assertCount(1, $this->groups); |
| 158 | + |
| 159 | + $this->baseGroupedMapper->expects(static::once())->method('remove')->with('field1'); |
| 160 | + $this->baseGroupedMapper->removeTab('fooTab1'); |
| 161 | + |
| 162 | + static::assertCount(0, $this->tabs); |
| 163 | + static::assertCount(0, $this->groups); |
| 164 | + } |
| 165 | + |
123 | 166 | public function testFluidInterface(): void
|
124 | 167 | {
|
125 | 168 | static::assertSame($this->baseGroupedMapper, $this->baseGroupedMapper->tab('fooTab')->with('fooGroup1')->end()->with('fooGroup2')->end()->with('fooGroup3')->end()->end()->tab('barTab')->with('barGroup1')->end()->with('barGroup2')->end()->with('barGroup3')->end()->end());
|
|
0 commit comments