Code Duplication    Length = 42-42 lines in 2 locations

Tests/Command/CreateDatabaseDoctrineTest.php 1 location

@@ 53-94 (lines=42) @@
50
     * @param null $params Connection parameters
51
     * @return \PHPUnit_Framework_MockObject_MockObject
52
     */
53
    private function getMockContainer($connectionName, $params=null)
54
    {
55
        // Mock the container and everything you'll need here
56
        $mockDoctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ConnectionRegistry')
57
            ->getMock();
58
59
        $mockDoctrine->expects($this->any())
60
            ->method('getDefaultConnectionName')
61
            ->withAnyParameters()
62
            ->willReturn($connectionName)
63
        ;
64
65
66
        $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection')
67
            ->disableOriginalConstructor()
68
            ->setMethods(array('getParams'))
69
            ->getMockForAbstractClass();
70
71
        $mockConnection->expects($this->any())
72
            ->method('getParams')
73
            ->withAnyParameters()
74
            ->willReturn($params);
75
76
        
77
        $mockDoctrine->expects($this->any())
78
            ->method('getConnection')
79
            ->withAnyParameters()
80
            ->willReturn($mockConnection);
81
        ;
82
83
84
        $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')
85
            ->setMethods(array('get'))
86
            ->getMock();
87
88
        $mockContainer->expects($this->any())
89
            ->method('get')
90
            ->with('doctrine')
91
            ->willReturn($mockDoctrine);
92
93
        return $mockContainer;
94
    }
95
}
96

Tests/Command/DropDatabaseDoctrineTest.php 1 location

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