Code Duplication    Length = 24-29 lines in 2 locations

tests/unit/Controllers/API/GenericServiceInvokeControllerTest.php 1 location

@@ 162-190 (lines=29) @@
159
    /**
160
     * @test
161
     */
162
    public function shouldCheckIfAccessIsGranted()
163
    {
164
        $this->expectException(AccessDeniedException::class);
165
166
        /** @var Request $request */
167
        $request = $this->createMock(Request::class);
168
169
        $this->controllerHelper->expects($this->once())->method('denyAccessUnlessGranted')->with(
170
            $this->equalTo('bar'),
171
            $this->identicalTo($request)
172
        )->will($this->returnCallback(
173
            function () {
174
                throw new AccessDeniedException("Lorem ipsum");
175
            }
176
        ));
177
178
        $controller = new GenericServiceInvokeController(
179
            $this->controllerHelper,
180
            $this->argumentCompiler,
181
            $this->container,
182
            [
183
                'service' => 'some_service',
184
                'method' => 'doFoo',
185
                'authorization-attributes' => 'bar'
186
            ]
187
        );
188
189
        $controller->callService($request);
190
    }
191
192
    /**
193
     * @test

tests/unit/Controllers/GenericTemplateRenderControllerTest.php 1 location

@@ 81-104 (lines=24) @@
78
    /**
79
     * @test
80
     */
81
    public function shouldCheckIfAccessIsGranted()
82
    {
83
        $this->expectException(AccessDeniedException::class);
84
85
        /** @var Request $request */
86
        $request = $this->createMock(Request::class);
87
88
        $this->controllerHelper->expects($this->once())->method('denyAccessUnlessGranted')->with(
89
            $this->equalTo('some-attribute'),
90
            $this->equalTo($request)
91
        )->will($this->returnCallback(
92
            function () {
93
                throw new AccessDeniedException('Lorem ipsum!');
94
            }
95
        ));
96
97
        /** @var mixed $controller */
98
        $controller = new GenericTemplateRenderController($this->controllerHelper, $this->argumentCompiler, [
99
            'template' => "@foo/bar/baz.html",
100
            'authorization-attribute' => 'some-attribute',
101
        ]);
102
103
        $controller->renderTemplate($request);
104
    }
105
106
    /**
107
     * @test