|
@@ 40-52 (lines=13) @@
|
| 37 |
|
$this->assertSame($conn, $registry->getConnection()); |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
public function testGetConnection() |
| 41 |
|
{ |
| 42 |
|
$conn = $this->getMockBuilder('Doctrine\DBAL\Connection')->disableOriginalConstructor()->getMock(); |
| 43 |
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); |
| 44 |
|
$container->expects($this->once()) |
| 45 |
|
->method('get') |
| 46 |
|
->with($this->equalTo('doctrine.dbal.default_connection')) |
| 47 |
|
->will($this->returnValue($conn)); |
| 48 |
|
|
| 49 |
|
$registry = new Registry($container, ['default' => 'doctrine.dbal.default_connection'], [], 'default', 'default'); |
| 50 |
|
|
| 51 |
|
$this->assertSame($conn, $registry->getConnection('default')); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
/** |
| 55 |
|
* @expectedException \InvalidArgumentException |
|
@@ 126-150 (lines=25) @@
|
| 123 |
|
$registry->resetManager('default'); |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
public function testReset() |
| 127 |
|
{ |
| 128 |
|
$conn = $this->getMockBuilder('Doctrine\DBAL\Connection')->disableOriginalConstructor()->getMock(); |
| 129 |
|
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')->disableOriginalConstructor()->getMock(); |
| 130 |
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); |
| 131 |
|
|
| 132 |
|
$container->expects($this->once()) |
| 133 |
|
->method('get') |
| 134 |
|
->with($this->equalTo('doctrine.orm.default_entity_manager')) |
| 135 |
|
->will($this->returnValue($em)); |
| 136 |
|
|
| 137 |
|
$registry = new Registry( |
| 138 |
|
$container, |
| 139 |
|
[ |
| 140 |
|
'default' => $conn, |
| 141 |
|
], |
| 142 |
|
[ |
| 143 |
|
'default' => 'doctrine.orm.default_entity_manager', |
| 144 |
|
], |
| 145 |
|
'default', |
| 146 |
|
'default' |
| 147 |
|
); |
| 148 |
|
|
| 149 |
|
$registry->reset(); |
| 150 |
|
} |
| 151 |
|
} |
| 152 |
|
|