Passed
Push — bugfix/363-refactor-twine-impo... ( 7c1114...530274 )
by Michael
04:42
created

DefaultControllerTest::testTextnodesAction()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 40
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 31
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\Textnode;
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 Doctrine\Bundle\MongoDBBundle\ManagerRegistry;
38
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
39
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
40
use AdminBundle\Controller\DefaultController;
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 WebTestCase
50
{
51
    /**
52
     * @var \PHPUnit_Framework_MockObject_MockObject|ManagerRegistry
53
     */
54
    private $service;
55
56
    /**
57
     * @var DefaultController
58
     */
59
    private $controller;
60
61
    /**
62
     * @var string
63
     */
64
    private $twineDirectory;
65
66
    /**
67
     * @var \PHPUnit_Framework_MockObject_MockObject|EngineInterface
68
     */
69
    private $templatingMock;
70
71
    /**
72
     * @var \PHPUnit_Framework_MockObject_MockObject|UserRepository
73
     */
74
    private $userRepositoryMock;
75
76
    /**
77
     * @var \PHPUnit_Framework_MockObject_MockObject|LicenseeRepository
78
     */
79
    private $licenseeRepositoryMock;
80
81
    /**
82
     * @var \PHPUnit_Framework_MockObject_MockObject|TopicRepository
83
     */
84
    private $topicRepositoryMock;
85
86
    /**
87
     * @var \PHPUnit_Framework_MockObject_MockObject|ImportfileRepositoryInterface
88
     */
89
    private $importfileRepositoryMock;
90
91
    /**
92
     * @var \PHPUnit_Framework_MockObject_MockObject|TextNodeRepository
93
     */
94
    private $textnodeRepositoryMock;
95
96
    /**
97
     * @var \PHPUnit_Framework_MockObject_MockObject|UserPasswordEncoder
98
     */
99
    private $userPasswordEncoderMock;
100
101
    /**
102
     * @var string
103
     */
104
    private $topicImageDirectory;
105
106
    /**
107
     * @var \PHPUnit_Framework_MockObject_MockObject|\Swift_Mailer
108
     */
109
    private $mailerMock;
110
111
    /**
112
     * @return void
113
     */
114
    public function setUp(): void
115
    {
116
        $this->twineDirectory = '/tmp/twineDirectory';
117
        $this->templatingMock = $this->createTemplatingMock();
118
        $this->userRepositoryMock = $this->createUserRepositoryMock();
119
        $this->licenseeRepositoryMock = $this->createLicenseeRepositoryMock();
120
        $this->topicRepositoryMock = $this->createTopicRepositoryMock();
121
        $this->importfileRepositoryMock = $this->createImportfileRepositoryMock();
122
        $this->textnodeRepositoryMock = $this->createTextnodeRepositoryMock();
123
        $this->userPasswordEncoderMock = $this->createUserPasswordEncoderMock();
124
        $this->topicImageDirectory = 'tmp/topicImageDirectory';
125
        $this->mailerMock = $this->createMailerMock();
126
127
        $this->controller = new DefaultController(
128
            $this->templatingMock,
129
            $this->userRepositoryMock,
130
            $this->licenseeRepositoryMock,
131
            $this->topicRepositoryMock,
132
            $this->importfileRepositoryMock,
133
            $this->textnodeRepositoryMock,
134
            $this->userPasswordEncoderMock,
135
            $this->twineDirectory,
136
            $this->topicImageDirectory,
137
            $this->mailerMock
138
        );
139
    }
140
141
    /**
142
     * tests the index action
143
     * @return void
144
     */
145 View Code Duplication
    public function testIndexAction(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
146
    {
147
        $client = static::createClient();
148
        $crawler = $client->request('GET', '/admin/');
149
150
        $this->assertEquals(302, $client->getResponse()->getStatusCode());
151
        $this->assertTrue($crawler->filter('html:contains("login")')->count() > 0);
152
    }
153
154
    /**
155
     * tests controller's userAction with no users in db
156
     * @return void
157
     */
158
    public function testUserAction(): void
159
    {
160
        $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
161
        $postMock = $this->getMockBuilder(ParameterBag::class)->disableOriginalConstructor()->getMock();
162
        $queryMock = $this->getMockBuilder('foobar')->setMethods(array('execute', 'getQuery'))->getMock();
163
        $postArray = array();
164
        $postMock->expects($this->once())
165
            ->method('get')
166
            ->will($this->returnValue($postArray));
167
        $request->query = $postMock;
0 ignored issues
show
Bug introduced by
Accessing query on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
168
169
        $queryMock->expects($this->once())
170
            ->method('getQuery')
171
            ->will($this->returnSelf());
172
173
        $queryMock->expects($this->once())
174
            ->method('execute')
175
            ->will($this->returnValue(array()));
176
177
        $this->userRepositoryMock->expects($this->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

177
        $this->userRepositoryMock->/** @scrutinizer ignore-call */ 
178
                                   expects($this->once())
Loading history...
178
            ->method('createQueryBuilder')
179
            ->will($this->returnValue($queryMock));
180
181
        /* @var $response \Symfony\Component\HttpFoundation\Response */
182
        $response = $this->controller->usersAction($request);
183
        $this->assertInstanceOf(Response::class, $response);
184
        $this->assertJsonStringEqualsJsonString('[]', $response->getContent());
185
        $this->assertEquals('200', $response->getStatusCode());
186
    }
187
188
    /**
189
     * tests controller's userAction with two users in db
190
     * @return void
191
     */
192
    public function testUserActionWithUsers(): void
193
    {
194
        $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
195
        $postMock = $this->getMockBuilder(ParameterBag::class)->disableOriginalConstructor()->getMock();
196
        $queryMock = $this->getMockBuilder('foobar')->setMethods(['execute', 'getQuery'])->getMock();
197
        $postArray = array();
198
        $postMock->expects($this->once())
199
            ->method('get')
200
            ->will($this->returnValue($postArray));
201
        $request->query = $postMock;
0 ignored issues
show
Bug introduced by
Accessing query on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
202
203
        $queryMock->expects($this->once())
204
            ->method('getQuery')
205
            ->will($this->returnSelf());
206
207
        $this->userRepositoryMock->expects($this->once())
208
            ->method('createQueryBuilder')
209
            ->will($this->returnValue($queryMock));
210
211
        $user1 = new User();
212
        $user1->setEmail('email1');
213
        $user1->setId('id1');
214
        $user1->setRoles('ROLE_ADMIN');
215
        $user1->setLicenseeId('lic1');
216
        $user2 = new User();
217
        $user2->setEmail('email2');
218
        $user2->setId('id2');
219
        $user2->setRoles('ROLE_USER');
220
        $user2->setLicenseeId('lic2');
221
222
        $userArray = array(
223
            $user1,
224
            $user2,
225
        );
226
227
        $queryMock->expects($this->once())
228
            ->method('execute')
229
            ->will($this->returnValue($userArray));
230
231
        /* @var $response \Symfony\Component\HttpFoundation\Response */
232
        $response = $this->controller->usersAction($request);
233
        $this->assertInstanceOf(Response::class, $response);
234
        $this->assertJsonStringEqualsJsonString('[{"id":"id1","gender":null,"email":"email1","roles":"ROLE_ADMIN","licenseeId":"lic1","status":null,"source":null,"reason":null,"created":"'.date('Y-m-d H:i:s', 0).'","updated":"'.date('Y-m-d H:i:s', 0).'"},{"id":"id2","email":"email2","roles":"ROLE_USER","licenseeId":"lic2","status":null,"source":null,"reason":null,"gender":null,"created":"'.date('Y-m-d H:i:s', 0).'","updated":"'.date('Y-m-d H:i:s', 0).'"}]', $response->getContent());
235
        $this->assertEquals('200', $response->getStatusCode());
236
    }
237
238
    /**
239
     * tear down method
240
     * @return void
241
     */
242
    public function tearDown(): void
243
    {
244
        $this->service = null;
245
    }
246
247
    /**
248
     * tests the formsaveAction without parameters
249
     * @return void
250
     */
251
    public function testFormsaveActionWithoutParameters(): void
252
    {
253
        $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
254
        $postMock = $this->getMockBuilder(ParameterBag::class)->disableOriginalConstructor()->getMock();
255
        $postArray = array();
256
        $postMock->expects($this->once())
257
            ->method('all')
258
            ->will($this->returnValue($postArray));
259
        $request->request = $postMock;
0 ignored issues
show
Bug introduced by
Accessing request on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
260
261
        /* @var $response \Symfony\Component\HttpFoundation\Response */
262
        $response = $this->controller->formsaveAction($request);
263
        $this->assertInstanceOf(Response::class, $response);
264
        $json = $response->getContent();
265
        $this->assertJson($json);
266
        $json = json_decode($json);
267
        $this->assertTrue($json->error);
268
    }
269
270
    /**
271
     * tests the formsaveAction with wrong parameters
272
     * @return void
273
     */
274 View Code Duplication
    public function testFormsaveActionWithWrongParameters(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
275
    {
276
        $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
277
        $postMock = $this->getMockBuilder(ParameterBag::class)->disableOriginalConstructor()->getMock();
278
        $postArray = array(
279
            'formtype' => 'nonexistant',
280
        );
281
        $postMock->expects($this->once())
282
            ->method('all')
283
            ->will($this->returnValue($postArray));
284
        $request->request = $postMock;
0 ignored issues
show
Bug introduced by
Accessing request on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
285
286
        /* @var $response \Symfony\Component\HttpFoundation\Response */
287
        $response = $this->controller->formsaveAction($request);
288
        $this->assertInstanceOf(Response::class, $response);
289
        $json = $response->getContent();
290
        $this->assertJson($json);
291
        $json = json_decode($json);
292
        $this->assertTrue($json->error);
293
    }
294
295
    /**
296
     * tests the formsaveAction with an existing user
297
     * @return void
298
     */
299
    public function testFormsaveActionExistingUser(): void
300
    {
301
        $user = new User();
302
        $user->setId('someId');
303
        $user->setEmail('[email protected]');
304
        $user->setRoles('ROLE_USER');
305
306
        $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
307
        $postMock = $this->getMockBuilder(ParameterBag::class)->disableOriginalConstructor()->getMock();
308
        $postArray = array(
309
            'formtype' => 'user',
310
            'id' => $user->getId(),
311
        );
312
        $postMock->expects($this->once())
313
            ->method('all')
314
            ->will($this->returnValue($postArray));
315
        $request->request = $postMock;
0 ignored issues
show
Bug introduced by
Accessing request on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
316
317
        $this->userRepositoryMock->expects($this->once())
318
            ->method('find')
319
            ->with($user->getId())
320
            ->will($this->returnValue($user));
321
322
        /* @var $response \Symfony\Component\HttpFoundation\Response */
323
        $response = $this->controller->formsaveAction($request);
324
        $this->assertInstanceOf(Response::class, $response);
325
        $json = $response->getContent();
326
        $this->assertJson($json);
327
        $json = json_decode($json);
328
        $this->assertFalse($json->error);
329
        $this->assertEquals($user->getId(), $json->newId);
330
    }
331
332
    /**
333
     * tests the formsaveAction with a nonexisting user
334
     * @return void
335
     */
336
    public function testFormsaveActionNotExistingUser(): void
337
    {
338
        $user = new User();
339
        $user->setId('someId');
340
        $user->setEmail('[email protected]');
341
        $user->setRoles('ROLE_USER');
342
343
        $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
344
        $postMock = $this->getMockBuilder(ParameterBag::class)->disableOriginalConstructor()->getMock();
345
        $postArray = array(
346
            'formtype' => 'user',
347
            'id' => $user->getId(),
348
        );
349
        $postMock->expects($this->once())
350
            ->method('all')
351
            ->will($this->returnValue($postArray));
352
        $request->request = $postMock;
0 ignored issues
show
Bug introduced by
Accessing request on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
353
354
        $this->userRepositoryMock->expects($this->once())
355
            ->method('find')
356
            ->with($user->getId())
357
            ->will($this->returnValue(null));
358
359
        /* @var $response \Symfony\Component\HttpFoundation\Response */
360
        $response = $this->controller->formsaveAction($request);
361
        $this->assertInstanceOf(Response::class, $response);
362
        $json = $response->getContent();
363
        $this->assertJson($json);
364
        $json = json_decode($json);
365
        $this->assertTrue($json->error);
366
    }
367
368
    /**
369
     * tests the formsaveAction without admin permission
370
     * @return void
371
     */
372 View Code Duplication
    public function testFormsaveActionWithoutAdminPermission(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
373
    {
374
        $client = static::createClient();
375
        $crawler = $client->request('GET', '/admin/save');
376
377
378
        $this->assertEquals(302, $client->getResponse()->getStatusCode());
379
        $this->assertTrue($crawler->filter('html:contains("login")')->count() > 0);
380
    }
381
382
    /**
383
     * tests the formsaveAction with missing id parameter
384
     * @return void
385
     */
386 View Code Duplication
    public function testFormsaveActionWithMissingIdParameter(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
387
    {
388
        $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
389
        $postMock = $this->getMockBuilder(ParameterBag::class)->disableOriginalConstructor()->getMock();
390
        $postArray = array(
391
            'formtype' => 'licensee',
392
            'name' => 'someLNName',
393
        );
394
        $postMock->expects($this->once())
395
            ->method('all')
396
            ->will($this->returnValue($postArray));
397
        $request->request = $postMock;
0 ignored issues
show
Bug introduced by
Accessing request on the interface PHPUnit_Framework_MockObject_MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
398
399
        /* @var $response \Symfony\Component\HttpFoundation\Response */
400
        $response = $this->controller->formsaveAction($request);
401
        $this->assertInstanceOf(Response::class, $response);
402
        $json = $response->getContent();
403
        $this->assertJson($json);
404
        $json = json_decode($json);
405
        $this->assertTrue($json->error);
406
    }
407
408
    /**
409
     * tests licenseeAction with no licensees
410
     * @return void
411
     */
412
    public function testLicenseeActionWithNoLicensees(): void
413
    {
414
        $this->licenseeRepositoryMock->expects($this->once())
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

414
        $this->licenseeRepositoryMock->/** @scrutinizer ignore-call */ 
415
                                       expects($this->once())
Loading history...
415
            ->method('findAll')
416
            ->willReturn([]);
417
418
        /* @var $response \Symfony\Component\HttpFoundation\Response */
419
        $response = $this->controller->licenseesAction();
420
        $this->assertInstanceOf(Response::class, $response);
421
        $this->assertJsonStringEqualsJsonString('[]', $response->getContent());
422
        $this->assertEquals('200', $response->getStatusCode());
423
    }
424
425
    /**
426
     * tests licenseeAction() with one licensee
427
     * @return void
428
     */
429
    public function testLicenseeActionWithOneLicensee(): void
430
    {
431
        $licensee = new Licensee();
432
        $licensee->setName('someName');
433
        $licensee->setId('someId');
434
435
        $this->licenseeRepositoryMock->expects($this->once())
436
            ->method('findAll')
437
            ->willReturn([$licensee]);
438
439
        /* @var $response \Symfony\Component\HttpFoundation\Response */
440
        $response = $this->controller->licenseesAction();
441
        $this->assertInstanceOf(Response::class, $response);
442
        $this->assertJsonStringEqualsJsonString('[{"id":"someId","name":"someName"}]', $response->getContent());
443
        $this->assertEquals('200', $response->getStatusCode());
444
    }
445
446
    /**
447
     * tests textnode action
448
     * @return void
449
     */
450
    public function testTextnodesAction(): void
451
    {
452
        $textnode = new Textnode();
453
        $textnode->setId('someId');
454
        $textnode->setCreated(new \DateTime('2017-01-01 12:00:00'));
0 ignored issues
show
Bug introduced by
new DateTime('2017-01-01 12:00:00') of type DateTime is incompatible with the type string expected by parameter $created of DembeloMain\Document\Textnode::setCreated(). ( Ignorable by Annotation )

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

454
        $textnode->setCreated(/** @scrutinizer ignore-type */ new \DateTime('2017-01-01 12:00:00'));
Loading history...
455
        $textnode->setStatus(1);
456
        $textnode->setAccess(true);
457
        $textnode->setLicenseeId('someLicenseeId');
458
        $textnode->setArbitraryId('someArbitraryId');
459
        $textnode->setTwineId('someTwineId');
460
        $textnode->setMetadata(['key1' => 'val1', 'key2' => 'val2']);
461
462
        $licensee = new Licensee();
463
        $licensee->setId('someLicenseeId');
464
        $licensee->setName('someLicenseeName');
465
466
        $importfile = new Importfile();
467
        $importfile->setId('someImportfileId');
468
        $importfile->setName('someImportfileName');
469
470
        $this->textnodeRepositoryMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on DembeloMain\Model\Reposi...\ODM\TextNodeRepository. 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

470
        $this->textnodeRepositoryMock->/** @scrutinizer ignore-call */ 
471
                                       expects($this->once())
Loading history...
471
            ->method('findAll')
472
            ->willReturn([$textnode]);
473
474
        $this->licenseeRepositoryMock->expects($this->once())
475
            ->method('findAll')
476
            ->willReturn([$licensee]);
477
478
        $this->importfileRepositoryMock->expects($this->once())
479
            ->method('findAll')
480
            ->willReturn([$importfile]);
481
482
        /* @var $response \Symfony\Component\HttpFoundation\Response */
483
        $response = $this->controller->textnodesAction();
484
        $this->assertInstanceOf(Response::class, $response);
485
        $expectedJson = '[{"id":"someId","status":"aktiv","created":"01.01.2017, 12:00:00",';
486
        $expectedJson .= '"access":"ja","licensee":"someLicenseeName","importfile":"unbekannt","beginning":"...",';
487
        $expectedJson .= '"financenode":"ja","arbitraryId":"someArbitraryId","twineId":"someTwineId",';
488
        $expectedJson .= '"metadata":"key1: val1\nkey2: val2\n"}]';
489
        $this->assertJsonStringEqualsJsonString($expectedJson, $response->getContent());
490
    }
491
492
    /**
493
     * @return \PHPUnit_Framework_MockObject_MockObject|LicenseeRepository
494
     */
495
    private function createLicenseeRepositoryMock(): LicenseeRepository
496
    {
497
        $repository = $this->getMockBuilder(LicenseeRepository::class)
498
            ->disableOriginalConstructor()
499
            ->setMethods(['findAll'])
500
            ->getMock();
501
502
        return $repository;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $repository returns the type PHPUnit_Framework_MockObject_MockObject which is incompatible with the type-hinted return DembeloMain\Model\Reposi...\ODM\LicenseeRepository.
Loading history...
503
    }
504
505
    /**
506
     * @return \PHPUnit_Framework_MockObject_MockObject|ImportfileRepository
507
     */
508
    private function createImportfileRepositoryMock(): ImportfileRepository
509
    {
510
        $repository = $this->getMockBuilder(ImportfileRepository::class)
511
            ->disableOriginalConstructor()
512
            ->setMethods(['findAll'])
513
            ->getMock();
514
515
        return $repository;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $repository returns the type PHPUnit_Framework_MockObject_MockObject which is incompatible with the type-hinted return DembeloMain\Model\Reposi...DM\ImportfileRepository.
Loading history...
516
    }
517
518
    /**
519
     * @return \PHPUnit_Framework_MockObject_MockObject|EngineInterface
520
     */
521
    private function createTemplatingMock(): EngineInterface
522
    {
523
        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...
524
    }
525
526
    /**
527
     * @return UserRepository|\PHPUnit_Framework_MockObject_MockObject
528
     */
529
    private function createUserRepositoryMock(): UserRepository
530
    {
531
        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...
532
    }
533
534
    /**
535
     * @return TopicRepository|\PHPUnit_Framework_MockObject_MockObject
536
     */
537
    private function createTopicRepositoryMock(): TopicRepository
538
    {
539
        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...
540
    }
541
542
    /**
543
     * @return TextNodeRepository|\PHPUnit_Framework_MockObject_MockObject
544
     */
545
    private function createTextnodeRepositoryMock(): TextNodeRepository
546
    {
547
        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...
548
    }
549
550
    /**
551
     * @return UserPasswordEncoder|\PHPUnit_Framework_MockObject_MockObject
552
     */
553
    private function createUserPasswordEncoderMock(): UserPasswordEncoder
554
    {
555
        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...
556
    }
557
558
    /**
559
     * @return \Swift_Mailer|\PHPUnit_Framework_MockObject_MockObject
560
     */
561
    private function createMailerMock(): \Swift_Mailer
562
    {
563
        return $this->createMock(\Swift_Mailer::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createMock(Swift_Mailer::class) returns the type PHPUnit_Framework_MockObject_MockObject which is incompatible with the type-hinted return Swift_Mailer.
Loading history...
564
    }
565
}
566