|
14 | 14 | namespace DatabaseBackup\TestSuite; |
15 | 15 |
|
16 | 16 | use Cake\Core\Configure; |
17 | | -use Cake\Database\Connection; |
18 | 17 | use Cake\Event\EventList; |
19 | 18 | use DatabaseBackup\TestSuite\TestCase; |
20 | | -use ErrorException; |
21 | 19 |
|
22 | 20 | /** |
23 | 21 | * DriverTestCase class. |
@@ -100,31 +98,6 @@ final protected function getAllRecords() |
100 | 98 | return $records; |
101 | 99 | } |
102 | 100 |
|
103 | | - /** |
104 | | - * Internal method to mock a driver |
105 | | - * @param array $methods The list of methods to mock |
106 | | - * @return \DatabaseBackup\Driver\Driver|\PHPUnit_Framework_MockObject_MockObject |
107 | | - * @since 2.6.1 |
108 | | - * @uses $Driver |
109 | | - */ |
110 | | - final protected function getMockForDriver(array $methods) |
111 | | - { |
112 | | - return $this->getMockBuilder(get_class($this->Driver)) |
113 | | - ->setMethods($methods) |
114 | | - ->setConstructorArgs([$this->getConnection()]) |
115 | | - ->getMock(); |
116 | | - } |
117 | | - |
118 | | - /** |
119 | | - * Test for `__construct()` method |
120 | | - * @return void |
121 | | - * @test |
122 | | - */ |
123 | | - public function testConstruct() |
124 | | - { |
125 | | - $this->assertInstanceof(Connection::class, $this->getProperty($this->Driver, 'connection')); |
126 | | - } |
127 | | - |
128 | 101 | /** |
129 | 102 | * Test for `export()` method |
130 | 103 | * @return void |
@@ -227,50 +200,6 @@ public function testExportExecutableWithCompression() |
227 | 200 | } |
228 | 201 | } |
229 | 202 |
|
230 | | - /** |
231 | | - * Test for `export()` method on failure |
232 | | - * @return void |
233 | | - * @since 2.6.2 |
234 | | - * @test |
235 | | - */ |
236 | | - public function testExportOnFailure() |
237 | | - { |
238 | | - $this->expectException(ErrorException::class); |
239 | | - $this->expectExceptionMessageRegExp('/^Failed with exit code `\d`$/'); |
240 | | - //Sets a no existing database |
241 | | - $config = ['database' => 'noExisting'] + $this->Driver->getConfig(); |
242 | | - $this->setProperty($this->Driver, 'connection', new Connection($config)); |
243 | | - $this->Driver->export($this->getAbsolutePath('example.sql')); |
244 | | - } |
245 | | - |
246 | | - /** |
247 | | - * Test for `export()` method. Export is stopped because the |
248 | | - * `beforeExport()` method returns `false` |
249 | | - * @return void |
250 | | - * @test |
251 | | - */ |
252 | | - public function testExportStoppedByBeforeExport() |
253 | | - { |
254 | | - $backup = $this->getAbsolutePath('example.sql'); |
255 | | - $Driver = $this->getMockForDriver(['beforeExport']); |
256 | | - $Driver->method('beforeExport')->will($this->returnValue(false)); |
257 | | - $this->assertFalse($Driver->export($backup)); |
258 | | - $this->assertFileNotExists($backup); |
259 | | - } |
260 | | - |
261 | | - /** |
262 | | - * Test for `getConfig()` method |
263 | | - * @return void |
264 | | - * @test |
265 | | - */ |
266 | | - public function testGetConfig() |
267 | | - { |
268 | | - $this->assertNotEmpty($this->Driver->getConfig()); |
269 | | - $this->assertIsArray($this->Driver->getConfig()); |
270 | | - $this->assertNotEmpty($this->Driver->getConfig('name')); |
271 | | - $this->assertNull($this->Driver->getConfig('noExistingKey')); |
272 | | - } |
273 | | - |
274 | 203 | /** |
275 | 204 | * Test for `import()` method |
276 | 205 | * @return void |
@@ -318,39 +247,4 @@ public function testImportExecutableWithCompression() |
318 | 247 | $this->assertEquals($expected, $result); |
319 | 248 | } |
320 | 249 | } |
321 | | - |
322 | | - /** |
323 | | - * Test for `import()` method on failure |
324 | | - * @return void |
325 | | - * @since 2.6.2 |
326 | | - * @test |
327 | | - */ |
328 | | - public function testImportOnFailure() |
329 | | - { |
330 | | - $backup = $this->getAbsolutePath('example.sql'); |
331 | | - |
332 | | - $this->expectException(ErrorException::class); |
333 | | - $this->expectExceptionMessageRegExp('/^Failed with exit code `\d`$/'); |
334 | | - $this->Driver->export($backup); |
335 | | - |
336 | | - //Sets a no existing database |
337 | | - $config = ['database' => 'noExisting'] + $this->Driver->getConfig(); |
338 | | - $this->setProperty($this->Driver, 'connection', new Connection($config)); |
339 | | - $this->Driver->import($backup); |
340 | | - } |
341 | | - |
342 | | - /** |
343 | | - * Test for `import()` method. Import is stopped because the |
344 | | - * `beforeImport()` method returns `false` |
345 | | - * @return void |
346 | | - * @test |
347 | | - */ |
348 | | - public function testImportStoppedByBeforeExport() |
349 | | - { |
350 | | - $backup = $this->getAbsolutePath('example.sql'); |
351 | | - $Driver = $this->getMockForDriver(['beforeImport']); |
352 | | - $Driver->method('beforeImport')->will($this->returnValue(false)); |
353 | | - $this->assertTrue($Driver->export($backup)); |
354 | | - $this->assertFalse($Driver->import($backup)); |
355 | | - } |
356 | 250 | } |
0 commit comments