Code Duplication    Length = 37-37 lines in 2 locations

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

Tests/Command/DropDatabaseDoctrineTest.php 1 location

@@ 120-156 (lines=37) @@
117
    /**
118
     * @param array|null $params Connection parameters
119
     */
120
    private function getMockContainer(string $connectionName, array $params = null) : MockObject
121
    {
122
        // Mock the container and everything you'll need here
123
        $mockDoctrine = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')
124
            ->getMock();
125
126
        $mockDoctrine->expects($this->any())
127
            ->method('getDefaultConnectionName')
128
            ->withAnyParameters()
129
            ->willReturn($connectionName);
130
131
        $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection')
132
            ->disableOriginalConstructor()
133
            ->setMethods(['getParams'])
134
            ->getMockForAbstractClass();
135
136
        $mockConnection->expects($this->any())
137
            ->method('getParams')
138
            ->withAnyParameters()
139
            ->willReturn($params);
140
141
        $mockDoctrine->expects($this->any())
142
            ->method('getConnection')
143
            ->withAnyParameters()
144
            ->willReturn($mockConnection);
145
146
        $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')
147
            ->setMethods(['get'])
148
            ->getMock();
149
150
        $mockContainer->expects($this->any())
151
            ->method('get')
152
            ->with('doctrine')
153
            ->willReturn($mockDoctrine);
154
155
        return $mockContainer;
156
    }
157
}
158