DefaultControllerTest::createFilesystemMock()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
/* Copyright (C) 2015 Michael Giesler
4
 *
5
 * This file is part of Dembelo.
6
 *
7
 * Dembelo is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * Dembelo is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License 3 for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License 3
18
 * along with Dembelo. If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
/**
22
 * @package AdminBundle
23
 */
24
25
namespace AdminBundle\Tests\Controller;
26
27
use DembeloMain\Document\Importfile;
28
use DembeloMain\Document\Licensee;
29
use DembeloMain\Document\Topic;
30
use DembeloMain\Document\User;
31
use DembeloMain\Model\Repository\Doctrine\ODM\ImportfileRepository;
32
use DembeloMain\Model\Repository\Doctrine\ODM\LicenseeRepository;
33
use DembeloMain\Model\Repository\Doctrine\ODM\TextNodeRepository;
34
use DembeloMain\Model\Repository\Doctrine\ODM\TopicRepository;
35
use DembeloMain\Model\Repository\Doctrine\ODM\UserRepository;
36
use DembeloMain\Model\Repository\ImportfileRepositoryInterface;
37
use PHPUnit\Framework\TestCase;
38
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
39
use AdminBundle\Controller\DefaultController;
40
use Symfony\Component\Filesystem\Filesystem;
41
use Symfony\Component\HttpFoundation\Request;
42
use Symfony\Component\HttpFoundation\ParameterBag;
43
use Symfony\Component\HttpFoundation\Response;
44
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoder;
45
46
/**
47
 * Class DefaultControllerTest
48
 */
49
class DefaultControllerTest extends TestCase
50
{
51
    /**
52
     * @var DefaultController
53
     */
54
    private $controller;
55
56
    /**
57
     * @var string
58
     */
59
    private $twineDirectory;
60
61
    /**
62
     * @var \PHPUnit_Framework_MockObject_MockObject|EngineInterface
63
     */
64
    private $templatingMock;
65
66
    /**
67
     * @var \PHPUnit_Framework_MockObject_MockObject|UserRepository
68
     */
69
    private $userRepositoryMock;
70
71
    /**
72
     * @var \PHPUnit_Framework_MockObject_MockObject|LicenseeRepository
73
     */
74
    private $licenseeRepositoryMock;
75
76
    /**
77
     * @var \PHPUnit_Framework_MockObject_MockObject|TopicRepository
78
     */
79
    private $topicRepositoryMock;
80
81
    /**
82
     * @var \PHPUnit_Framework_MockObject_MockObject|ImportfileRepositoryInterface
83
     */
84
    private $importfileRepositoryMock;
85
86
    /**
87
     * @var \PHPUnit_Framework_MockObject_MockObject|TextNodeRepository
88
     */
89
    private $textnodeRepositoryMock;
90
91
    /**
92
     * @var \PHPUnit_Framework_MockObject_MockObject|UserPasswordEncoder
93
     */
94
    private $userPasswordEncoderMock;
95
96
    /**
97
     * @var string
98
     */
99
    private $topicImageDirectory;
100
101
    /**
102
     * @var \PHPUnit_Framework_MockObject_MockObject|Filesystem
103
     */
104
    private $filesystemMock;
105
106
    /**
107
     * @return void
108
     */
109
    public function setUp(): void
110
    {
111
        $this->twineDirectory = '/tmp/twineDirectory';
112
        $this->templatingMock = $this->createTemplatingMock();
113
        $this->userRepositoryMock = $this->createUserRepositoryMock();
114
        $this->licenseeRepositoryMock = $this->createLicenseeRepositoryMock();
115
        $this->topicRepositoryMock = $this->createTopicRepositoryMock();
116
        $this->importfileRepositoryMock = $this->createImportfileRepositoryMock();
117
        $this->textnodeRepositoryMock = $this->createTextnodeRepositoryMock();
118
        $this->userPasswordEncoderMock = $this->createUserPasswordEncoderMock();
119
        $this->topicImageDirectory = '/tmp/topicImageDirectory';
120
        $this->filesystemMock = $this->createFilesystemMock();
121
122
        $this->controller = new DefaultController(
123
            $this->templatingMock,
124
            $this->userRepositoryMock,
125
            $this->licenseeRepositoryMock,
126
            $this->topicRepositoryMock,
127
            $this->importfileRepositoryMock,
128
            $this->userPasswordEncoderMock,
129
            $this->twineDirectory,
130
            $this->topicImageDirectory,
131
            $this->filesystemMock
132
        );
133
    }
134
135
    /**
136
     * tests the index action
137
     * @return void
138
     */
139
    public function testIndexAction()
140
    {
141
        $this->templatingMock->expects(self::once())
142
            ->method('renderResponse')
143
            ->willReturnCallback(function (string $template, array $arguments): Response {
144
                self::assertEquals('AdminBundle::index.html.twig', $template);
145
                self::assertArrayHasKey('mainMenuData', $arguments);
146
147
                return new Response();
148
            });
149
        self::assertInstanceOf(Response::class, $this->controller->indexAction());
150
    }
151
152
    /**
153
     * @return void
154
     */
155
    public function testFormsaveActionForInvalidFormType(): void
156
    {
157
        $params = [
158
            'formtype' => 'invalid',
159
            'id' => 'someId',
160
        ];
161
        $requestMock = $this->createRequestMock($params);
0 ignored issues
show
Bug introduced by
$params of type array<string,string> is incompatible with the type Symfony\Component\HttpFo...k_MockObject_MockObject expected by parameter $params of AdminBundle\Tests\Contro...st::createRequestMock(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

161
        $requestMock = $this->createRequestMock(/** @scrutinizer ignore-type */ $params);
Loading history...
162
        $result = $this->controller->formsaveAction($requestMock);
163
        self::assertInstanceOf(Response::class, $result);
164
        $json = $result->getContent();
165
        self::assertJsonStringEqualsJsonString(
166
            '{"error":true}',
167
            $json
168
        );
169
    }
170
171
    /**
172
     * @return void
173
     */
174
    public function testFormsaveActionForMissingId(): void
175
    {
176
        $params = [
177
            'formtype' => 'user',
178
        ];
179
        $requestMock = $this->createRequestMock($params);
0 ignored issues
show
Bug introduced by
$params of type array<string,string> is incompatible with the type Symfony\Component\HttpFo...k_MockObject_MockObject expected by parameter $params of AdminBundle\Tests\Contro...st::createRequestMock(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

179
        $requestMock = $this->createRequestMock(/** @scrutinizer ignore-type */ $params);
Loading history...
180
        $result = $this->controller->formsaveAction($requestMock);
181
        self::assertInstanceOf(Response::class, $result);
182
        $json = $result->getContent();
183
        self::assertJsonStringEqualsJsonString(
184
            '{"error":true}',
185
            $json
186
        );
187
    }
188
189
    /**
190
     * @return void
191
     */
192
    public function testFormsaveActionForNewUser(): void
193
    {
194
        $params = [
195
            'formtype' => 'user',
196
            'id' => 'new',
197
            'email' => 'someEmail',
198
            'password' => 'somePassword',
199
        ];
200
        $requestMock = $this->createRequestMock($params);
0 ignored issues
show
Bug introduced by
$params of type array<string,string> is incompatible with the type Symfony\Component\HttpFo...k_MockObject_MockObject expected by parameter $params of AdminBundle\Tests\Contro...st::createRequestMock(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

200
        $requestMock = $this->createRequestMock(/** @scrutinizer ignore-type */ $params);
Loading history...
201
202
        $this->userRepositoryMock->expects(self::once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on DembeloMain\Model\Reposi...rine\ODM\UserRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

202
        $this->userRepositoryMock->/** @scrutinizer ignore-call */ 
203
                                   expects(self::once())
Loading history...
Deprecated Code introduced by
The function DembeloMain\Model\Reposi...serRepository::__call() has been deprecated: method was deprecated in 1.2 and will be removed in 2.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

202
        /** @scrutinizer ignore-deprecated */ $this->userRepositoryMock->expects(self::once())

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
203
            ->method('getClassName')
204
            ->willReturn(User::class);
205
        $this->userRepositoryMock->expects(self::once())
0 ignored issues
show
Deprecated Code introduced by
The function DembeloMain\Model\Reposi...serRepository::__call() has been deprecated: method was deprecated in 1.2 and will be removed in 2.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

205
        /** @scrutinizer ignore-deprecated */ $this->userRepositoryMock->expects(self::once())

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
206
            ->method('save')
207
            ->willReturnCallback(function (User $user) {
208
                self::assertEquals('someEmail', $user->getEmail());
209
                self::assertEquals('somePasswordEncoded', $user->getPassword());
210
                $user->setId('someId');
211
            });
212
        $this->userPasswordEncoderMock->expects(self::once())
213
            ->method('encodePassword')
214
            ->with(self::anything(), 'somePassword')
215
            ->willReturn('somePasswordEncoded');
216
217
        $result = $this->controller->formsaveAction($requestMock);
218
219
        self::assertInstanceOf(Response::class, $result);
220
        $json = $result->getContent();
221
        self::assertJsonStringEqualsJsonString(
222
            '{"error":false,"newId":"someId"}',
223
            $json
224
        );
225
    }
226
227
    /**
228
     * @return void
229
     */
230
    public function testFormsaveActionForExistingTopic(): void
231
    {
232
        $params = [
233
            'formtype' => 'topic',
234
            'id' => 'someId',
235
            'imageFileName' => 'someImageFileName',
236
            'originalImageName' => 'someOriginalImageFileName',
237
        ];
238
        $requestMock = $this->createRequestMock($params);
0 ignored issues
show
Bug introduced by
$params of type array<string,string> is incompatible with the type Symfony\Component\HttpFo...k_MockObject_MockObject expected by parameter $params of AdminBundle\Tests\Contro...st::createRequestMock(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

238
        $requestMock = $this->createRequestMock(/** @scrutinizer ignore-type */ $params);
Loading history...
239
240
        $topicMock = $this->createMock(Topic::class);
241
        $topicMock->expects(self::any())
242
            ->method('getId')
243
            ->willReturn('someId');
244
245
        $this->topicRepositoryMock->expects(self::never())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on DembeloMain\Model\Reposi...ine\ODM\TopicRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

245
        $this->topicRepositoryMock->/** @scrutinizer ignore-call */ 
246
                                    expects(self::never())
Loading history...
Deprecated Code introduced by
The function DembeloMain\Model\Reposi...picRepository::__call() has been deprecated: method was deprecated in 1.2 and will be removed in 2.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

245
        /** @scrutinizer ignore-deprecated */ $this->topicRepositoryMock->expects(self::never())

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
246
            ->method('getClassName');
247
        $this->topicRepositoryMock->expects(self::once())
0 ignored issues
show
Deprecated Code introduced by
The function DembeloMain\Model\Reposi...picRepository::__call() has been deprecated: method was deprecated in 1.2 and will be removed in 2.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

247
        /** @scrutinizer ignore-deprecated */ $this->topicRepositoryMock->expects(self::once())

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
248
            ->method('find')
249
            ->with('someId')
250
            ->willReturn($topicMock);
251
        $this->topicRepositoryMock->expects(self::exactly(2))
0 ignored issues
show
Deprecated Code introduced by
The function DembeloMain\Model\Reposi...picRepository::__call() has been deprecated: method was deprecated in 1.2 and will be removed in 2.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

251
        /** @scrutinizer ignore-deprecated */ $this->topicRepositoryMock->expects(self::exactly(2))

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
252
            ->method('save')
253
            ->with($topicMock);
254
        $this->userPasswordEncoderMock->expects(self::never())
255
            ->method('encodePassword');
256
257
        $targetFileName = $this->topicImageDirectory.'someId/someOriginalImageFileName';
258
        $this->filesystemMock->expects(self::once())
259
            ->method('rename')
260
            ->with(self::anything(), $targetFileName);
261
262
        $result = $this->controller->formsaveAction($requestMock);
263
264
        self::assertInstanceOf(Response::class, $result);
265
        $json = $result->getContent();
266
        self::assertJsonStringEqualsJsonString(
267
            '{"error":false,"newId":"someId"}',
268
            $json
269
        );
270
    }
271
272
    /**
273
     * @return void
274
     */
275
    public function testFormsaveActionForExistingLicensee(): void
276
    {
277
        $params = [
278
            'formtype' => 'licensee',
279
            'id' => 'someId',
280
        ];
281
        $requestMock = $this->createRequestMock($params);
0 ignored issues
show
Bug introduced by
$params of type array<string,string> is incompatible with the type Symfony\Component\HttpFo...k_MockObject_MockObject expected by parameter $params of AdminBundle\Tests\Contro...st::createRequestMock(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

281
        $requestMock = $this->createRequestMock(/** @scrutinizer ignore-type */ $params);
Loading history...
282
283
        $licenseeMock = $this->createMock(Licensee::class);
284
        $licenseeMock->expects(self::any())
285
            ->method('getId')
286
            ->willReturn('someId');
287
288
        $this->licenseeRepositoryMock->expects(self::never())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on DembeloMain\Model\Reposi...\ODM\LicenseeRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

288
        $this->licenseeRepositoryMock->/** @scrutinizer ignore-call */ 
289
                                       expects(self::never())
Loading history...
Deprecated Code introduced by
The function DembeloMain\Model\Reposi...seeRepository::__call() has been deprecated: method was deprecated in 1.2 and will be removed in 2.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

288
        /** @scrutinizer ignore-deprecated */ $this->licenseeRepositoryMock->expects(self::never())

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
289
            ->method('getClassName');
290
        $this->licenseeRepositoryMock->expects(self::once())
0 ignored issues
show
Deprecated Code introduced by
The function DembeloMain\Model\Reposi...seeRepository::__call() has been deprecated: method was deprecated in 1.2 and will be removed in 2.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

290
        /** @scrutinizer ignore-deprecated */ $this->licenseeRepositoryMock->expects(self::once())

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
291
            ->method('find')
292
            ->with('someId')
293
            ->willReturn($licenseeMock);
294
        $this->licenseeRepositoryMock->expects(self::once())
0 ignored issues
show
Deprecated Code introduced by
The function DembeloMain\Model\Reposi...seeRepository::__call() has been deprecated: method was deprecated in 1.2 and will be removed in 2.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

294
        /** @scrutinizer ignore-deprecated */ $this->licenseeRepositoryMock->expects(self::once())

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
295
            ->method('save')
296
            ->with($licenseeMock);
297
298
        $result = $this->controller->formsaveAction($requestMock);
299
300
        self::assertInstanceOf(Response::class, $result);
301
        $json = $result->getContent();
302
        self::assertJsonStringEqualsJsonString(
303
            '{"error":false,"newId":"someId"}',
304
            $json
305
        );
306
    }
307
308
    /**
309
     * @return void
310
     */
311
    public function testFormsaveActionForExistingImportfile(): void
312
    {
313
        $params = [
314
            'formtype' => 'importfile',
315
            'id' => 'someId',
316
            'filename' => 'someFilename',
317
            'orgname' => 'someOrgName',
318
        ];
319
        $requestMock = $this->createRequestMock($params);
0 ignored issues
show
Bug introduced by
$params of type array<string,string> is incompatible with the type Symfony\Component\HttpFo...k_MockObject_MockObject expected by parameter $params of AdminBundle\Tests\Contro...st::createRequestMock(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

319
        $requestMock = $this->createRequestMock(/** @scrutinizer ignore-type */ $params);
Loading history...
320
321
        $importfileMock = $this->createMock(Importfile::class);
322
        $importfileMock->expects(self::any())
323
            ->method('getId')
324
            ->willReturn('someId');
325
326
        $this->importfileRepositoryMock->expects(self::never())
327
            ->method('getClassName');
328
        $this->importfileRepositoryMock->expects(self::once())
329
            ->method('find')
330
            ->with('someId')
331
            ->willReturn($importfileMock);
332
        $this->importfileRepositoryMock->expects(self::exactly(2))
333
            ->method('save')
334
            ->with($importfileMock);
335
336
        $this->filesystemMock->expects(self::once())
337
            ->method('exists')
338
            ->willReturn(true);
339
340
        $result = $this->controller->formsaveAction($requestMock);
341
342
        self::assertInstanceOf(Response::class, $result);
343
        $json = $result->getContent();
344
        self::assertJsonStringEqualsJsonString(
345
            '{"error":false,"newId":"someId"}',
346
            $json
347
        );
348
    }
349
350
    /**
351
     * @return \PHPUnit_Framework_MockObject_MockObject|LicenseeRepository
352
     */
353
    private function createLicenseeRepositoryMock(): LicenseeRepository
354
    {
355
        return $this->createMock(LicenseeRepository::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createMock...enseeRepository::class) returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return DembeloMain\Model\Reposi...\ODM\LicenseeRepository.
Loading history...
356
    }
357
358
    /**
359
     * @return \PHPUnit_Framework_MockObject_MockObject|ImportfileRepository
360
     */
361
    private function createImportfileRepositoryMock(): ImportfileRepository
362
    {
363
        return $this->createMock(ImportfileRepository::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createMock...tfileRepository::class) returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return DembeloMain\Model\Reposi...DM\ImportfileRepository.
Loading history...
364
    }
365
366
    /**
367
     * @return \PHPUnit_Framework_MockObject_MockObject|EngineInterface
368
     */
369
    private function createTemplatingMock(): EngineInterface
370
    {
371
        return $this->createMock(EngineInterface::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createMock...EngineInterface::class) returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return Symfony\Bundle\Framework...plating\EngineInterface.
Loading history...
372
    }
373
374
    /**
375
     * @return UserRepository|\PHPUnit_Framework_MockObject_MockObject
376
     */
377
    private function createUserRepositoryMock(): UserRepository
378
    {
379
        return $this->createMock(UserRepository::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createMock...\UserRepository::class) returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return DembeloMain\Model\Reposi...rine\ODM\UserRepository.
Loading history...
380
    }
381
382
    /**
383
     * @return TopicRepository|\PHPUnit_Framework_MockObject_MockObject
384
     */
385
    private function createTopicRepositoryMock(): TopicRepository
386
    {
387
        return $this->createMock(TopicRepository::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createMock...TopicRepository::class) returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return DembeloMain\Model\Reposi...ine\ODM\TopicRepository.
Loading history...
388
    }
389
390
    /**
391
     * @return TextNodeRepository|\PHPUnit_Framework_MockObject_MockObject
392
     */
393
    private function createTextnodeRepositoryMock(): TextNodeRepository
394
    {
395
        return $this->createMock(TextNodeRepository::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createMock...tNodeRepository::class) returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return DembeloMain\Model\Reposi...\ODM\TextNodeRepository.
Loading history...
396
    }
397
398
    /**
399
     * @return UserPasswordEncoder|\PHPUnit_Framework_MockObject_MockObject
400
     */
401
    private function createUserPasswordEncoderMock(): UserPasswordEncoder
402
    {
403
        return $this->createMock(UserPasswordEncoder::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createMock...PasswordEncoder::class) returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return Symfony\Component\Securi...der\UserPasswordEncoder.
Loading history...
404
    }
405
406
    /**
407
     * @param \PHPUnit_Framework_MockObject_MockObject|Request $params
408
     *
409
     * @return Request
410
     */
411
    private function createRequestMock($params): Request
412
    {
413
        $parameterBagMock = $this->createMock(ParameterBag::class);
414
        $parameterBagMock->expects(self::any())
415
            ->method('all')
416
            ->willReturn($params);
417
418
        /**
419
         * @var $mock \PHPUnit_Framework_MockObject_MockObject|Request
420
         */
421
        $mock = $this->createMock(Request::class);
422
        $mock->request = $parameterBagMock;
0 ignored issues
show
Documentation Bug introduced by
It seems like $parameterBagMock of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Symfony\Component\HttpFoundation\ParameterBag of property $request.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
423
424
        return $mock;
425
    }
426
427
    /**
428
     * @return \PHPUnit_Framework_MockObject_MockObject|Filesystem
429
     */
430
    private function createFilesystemMock(): Filesystem
431
    {
432
        return $this->createMock(Filesystem::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createMock...stem\Filesystem::class) returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return Symfony\Component\Filesystem\Filesystem.
Loading history...
433
    }
434
}
435