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