Code Duplication    Length = 42-42 lines in 2 locations

Tests/Command/CreateDatabaseDoctrineTest.php 1 location

@@ 89-130 (lines=42) @@
86
     * @param mixed[]|null $params         Connection parameters
87
     * @return \PHPUnit_Framework_MockObject_MockObject
88
     */
89
    private function getMockContainer($connectionName, $params = null)
90
    {
91
        // Mock the container and everything you'll need here
92
        $mockDoctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ConnectionRegistry')
93
            ->getMock();
94
95
        $mockDoctrine->expects($this->any())
96
            ->method('getDefaultConnectionName')
97
            ->withAnyParameters()
98
            ->willReturn($connectionName);
99
100
        $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection')
101
            ->disableOriginalConstructor()
102
            ->setMethods(['getParams'])
103
            ->getMockForAbstractClass();
104
105
        $mockConnection->expects($this->any())
106
            ->method('getParams')
107
            ->withAnyParameters()
108
            ->willReturn($params);
109
110
        $mockDoctrine->expects($this->any())
111
            ->method('getConnection')
112
            ->withAnyParameters()
113
            ->willReturn($mockConnection);
114
115
        $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')
116
            ->setMethods(['get'])
117
            ->getMock();
118
119
        $mockContainer->expects($this->any())
120
            ->method('get')
121
            ->with('doctrine')
122
            ->willReturn($mockDoctrine);
123
124
        return $mockContainer;
125
    }
126
}
127

Tests/Command/DropDatabaseDoctrineTest.php 1 location

@@ 79-120 (lines=42) @@
76
     * @param array|null $params         Connection parameters
77
     * @return \PHPUnit_Framework_MockObject_MockObject
78
     */
79
    private function getMockContainer($connectionName, $params = null)
80
    {
81
        // Mock the container and everything you'll need here
82
        $mockDoctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ConnectionRegistry')
83
            ->getMock();
84
85
        $mockDoctrine->expects($this->any())
86
            ->method('getDefaultConnectionName')
87
            ->withAnyParameters()
88
            ->willReturn($connectionName);
89
90
        $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection')
91
            ->disableOriginalConstructor()
92
            ->setMethods(['getParams'])
93
            ->getMockForAbstractClass();
94
95
        $mockConnection->expects($this->any())
96
            ->method('getParams')
97
            ->withAnyParameters()
98
            ->willReturn($params);
99
100
        $mockDoctrine->expects($this->any())
101
            ->method('getConnection')
102
            ->withAnyParameters()
103
            ->willReturn($mockConnection);
104
105
        $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')
106
            ->setMethods(['get'])
107
            ->getMock();
108
109
        $mockContainer->expects($this->any())
110
            ->method('get')
111
            ->with('doctrine')
112
            ->willReturn($mockDoctrine);
113
114
        return $mockContainer;
115
    }
116
}
117