Code Duplication    Length = 43-45 lines in 2 locations

tests/AdminBundle/Factory/ActionFactoryTest.php 2 locations

@@ 18-60 (lines=43) @@
15
16
class ActionFactoryTest extends AdminTestBase
17
{
18
    public function testCreate()
19
    {
20
        $resourceCollection = $this->getMockWithoutConstructor(ResourceCollection::class);
21
        $eventDispatcher = $this->getMockWithoutConstructor(EventDispatcherInterface::class);
22
23
        $adminConfiguration = $this->getMockWithoutConstructor(AdminConfiguration::class);
24
        $adminConfiguration
25
            ->expects($this->atLeastOnce())
26
            ->method('getParameter')
27
            ->willReturnMap([
28
                ['actions', [
29
                    'list' => [],
30
                ]],
31
                ['entity', 'MyLittleTauntaun'],
32
                ['class', EntityFixture::class],
33
            ])
34
        ;
35
36
        $actionConfiguration = $this->getMockWithoutConstructor(ActionConfiguration::class);
37
        $actionConfiguration
38
            ->expects($this->once())
39
            ->method('getParameter')
40
            ->willReturnMap([
41
                ['class', ActionFixture::class],
42
            ])
43
        ;
44
45
        $configurationFactory = $this->getMockWithoutConstructor(ConfigurationFactory::class);
46
        $configurationFactory
47
            ->expects($this->once())
48
            ->method('createActionConfiguration')
49
            ->with('list',  [], 'tauntaun', $adminConfiguration)
50
            ->willReturn($actionConfiguration)
51
        ;
52
53
        $factory = new ActionFactory(
54
            $resourceCollection,
55
            $eventDispatcher,
56
            $configurationFactory
57
        );
58
59
        $factory->create('list', 'tauntaun', $adminConfiguration);
60
    }
61
62
    public function testCreateWithMissingAction()
63
    {
@@ 89-133 (lines=45) @@
86
        });
87
    }
88
89
    public function testCreateWithWrongActionClass()
90
    {
91
        $resourceCollection = $this->getMockWithoutConstructor(ResourceCollection::class);
92
        $eventDispatcher = $this->getMockWithoutConstructor(EventDispatcherInterface::class);
93
94
        $adminConfiguration = $this->getMockWithoutConstructor(AdminConfiguration::class);
95
        $adminConfiguration
96
            ->expects($this->atLeastOnce())
97
            ->method('getParameter')
98
            ->willReturnMap([
99
                ['actions', [
100
                    'list' => [],
101
                ]],
102
                ['entity', 'MyLittleTauntaun'],
103
                ['class', EntityFixture::class],
104
            ])
105
        ;
106
107
        $actionConfiguration = $this->getMockWithoutConstructor(ActionConfiguration::class);
108
        $actionConfiguration
109
            ->expects($this->once())
110
            ->method('getParameter')
111
            ->willReturnMap([
112
                ['class', EntityFixture::class],
113
            ])
114
        ;
115
116
        $configurationFactory = $this->getMockWithoutConstructor(ConfigurationFactory::class);
117
        $configurationFactory
118
            ->expects($this->once())
119
            ->method('createActionConfiguration')
120
            ->with('list',  [], 'tauntaun', $adminConfiguration)
121
            ->willReturn($actionConfiguration)
122
        ;
123
124
        $factory = new ActionFactory(
125
            $resourceCollection,
126
            $eventDispatcher,
127
            $configurationFactory
128
        );
129
130
        $this->assertExceptionRaised(Exception::class, function () use ($factory, $adminConfiguration) {
131
            $factory->create('list', 'tauntaun', $adminConfiguration);
132
        });
133
    }
134
}
135