Code Duplication    Length = 37-37 lines in 2 locations

Tests/Command/DropDatabaseDoctrineTest.php 1 location

@@ 147-183 (lines=37) @@
144
    /**
145
     * @param array|null $params Connection parameters
146
     */
147
    private function getMockContainer(string $connectionName, array $params = null) : MockObject
148
    {
149
        // Mock the container and everything you'll need here
150
        $mockDoctrine = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')
151
            ->getMock();
152
153
        $mockDoctrine->expects($this->any())
154
            ->method('getDefaultConnectionName')
155
            ->withAnyParameters()
156
            ->willReturn($connectionName);
157
158
        $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection')
159
            ->disableOriginalConstructor()
160
            ->setMethods(['getParams'])
161
            ->getMockForAbstractClass();
162
163
        $mockConnection->expects($this->any())
164
            ->method('getParams')
165
            ->withAnyParameters()
166
            ->willReturn($params);
167
168
        $mockDoctrine->expects($this->any())
169
            ->method('getConnection')
170
            ->withAnyParameters()
171
            ->willReturn($mockConnection);
172
173
        $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')
174
            ->setMethods(['get'])
175
            ->getMock();
176
177
        $mockContainer->expects($this->any())
178
            ->method('get')
179
            ->with('doctrine')
180
            ->willReturn($mockDoctrine);
181
182
        return $mockContainer;
183
    }
184
}
185

Tests/Command/CreateDatabaseDoctrineTest.php 1 location

@@ 101-137 (lines=37) @@
98
    /**
99
     * @param mixed[]|null $params Connection parameters
100
     */
101
    private function getMockContainer(string $connectionName, array $params = null) : MockObject
102
    {
103
        // Mock the container and everything you'll need here
104
        $mockDoctrine = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')
105
            ->getMock();
106
107
        $mockDoctrine->expects($this->any())
108
            ->method('getDefaultConnectionName')
109
            ->withAnyParameters()
110
            ->willReturn($connectionName);
111
112
        $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection')
113
            ->disableOriginalConstructor()
114
            ->setMethods(['getParams'])
115
            ->getMockForAbstractClass();
116
117
        $mockConnection->expects($this->any())
118
            ->method('getParams')
119
            ->withAnyParameters()
120
            ->willReturn($params);
121
122
        $mockDoctrine->expects($this->any())
123
            ->method('getConnection')
124
            ->withAnyParameters()
125
            ->willReturn($mockConnection);
126
127
        $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')
128
            ->setMethods(['get'])
129
            ->getMock();
130
131
        $mockContainer->expects($this->any())
132
            ->method('get')
133
            ->with('doctrine')
134
            ->willReturn($mockDoctrine);
135
136
        return $mockContainer;
137
    }
138
}
139