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

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