ImportfileControllerTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
/* Copyright (C) 2017 Michael Giesler
3
 *
4
 * This file is part of Dembelo.
5
 *
6
 * Dembelo is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Affero General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * Dembelo is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU Affero General Public License 3 for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public License 3
17
 * along with Dembelo. If not, see <http://www.gnu.org/licenses/>.
18
 */
19
namespace AdminBundle\Tests\Controller;
20
21
use AdminBundle\Controller\ImportfileController;
22
use AdminBundle\Service\TwineImport\ImportTwine;
23
use DembeloMain\Model\Repository\ImportfileRepositoryInterface;
24
use Doctrine\Bundle\MongoDBBundle\ManagerRegistry;
25
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
26
27
/**
28
 * Class ImportfileControllerTest
29
 */
30
class ImportfileControllerTest extends WebTestCase
31
{
32
    /**
33
     * @var ImportfileController
34
     */
35
    private $controller;
36
37
    /**
38
     * @var \PHPUnit_Framework_MockObject_MockObject|ImportfileRepositoryInterface
39
     */
40
    private $importfileRepositoryMock;
41
42
    /**
43
     * @var \PHPUnit_Framework_MockObject_MockObject|ImportTwine
44
     */
45
    private $importTwineMock;
46
47
    /**
48
     * @var \PHPUnit_Framework_MockObject_MockObject|ManagerRegistry
49
     */
50
    private $mongoDbMock;
51
52
    /**
53
     * @var string
54
     */
55
    private $configTwineDirectory = '/tmp/phpunit-configTwineDirectory/';
56
57
    /**
58
     * @return void
59
     */
60
    protected function setUp(): void
61
    {
62
        $this->importfileRepositoryMock = $this->createImportfileRepositoryMock();
63
        $this->importTwineMock = $this->createMock(ImportTwine::class);
64
        $this->mongoDbMock = $this->createMock(ManagerRegistry::class);
65
66
        $this->controller = new ImportfileController(
67
            $this->importfileRepositoryMock,
68
            $this->importTwineMock,
69
            $this->mongoDbMock,
70
            $this->configTwineDirectory
71
        );
72
    }
73
74
    /**
75
     * @todo to be replaced by real tests
76
     *
77
     * @return void
78
     */
79
    public function testVoid(): void
80
    {
81
        self::assertTrue(true);
82
    }
83
84
    /**
85
     * @return \PHPUnit_Framework_MockObject_MockObject|ImportfileRepositoryInterface
86
     */
87
    private function createImportfileRepositoryMock(): ImportfileRepositoryInterface
88
    {
89
        $repository = $this->getMockBuilder(ImportfileRepositoryInterface::class)
90
            ->disableOriginalConstructor()
91
            ->setMethods(['findAll', 'save', 'find', 'findBy', 'findOneBy', 'getClassName'])
92
            ->getMock();
93
94
        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...fileRepositoryInterface.
Loading history...
95
    }
96
}
97