Skip to content

Commit 21a549f

Browse files
Merge branch 'main' of into 6.0
2 parents f4f9231 + 785a351 commit 21a549f

File tree

8 files changed

+72
-14
lines changed

8 files changed

+72
-14
lines changed

src/Backup/Source/Mysqldump.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ class Mysqldump extends SimulatorExecutable implements Simulator, Restorable
200200
*/
201201
private $routines;
202202

203+
/**
204+
* Dump scheduled events
205+
*
206+
* @var bool
207+
*/
208+
private $events;
209+
203210
/**
204211
* Skip triggers
205212
* --skip-triggers
@@ -238,6 +245,7 @@ public function setup(array $conf = [])
238245
$this->noData = Util\Str::toBoolean(Util\Arr::getValue($conf, 'noData', ''), false);
239246
$this->filePerTable = Util\Str::toBoolean(Util\Arr::getValue($conf, 'filePerTable', ''), false);
240247
$this->routines = Util\Str::toBoolean(Util\Arr::getValue($conf, 'routines', ''), false);
248+
$this->events = Util\Str::toBoolean(Util\Arr::getValue($conf, 'events', ''), false);
241249
$this->skipTriggers = Util\Str::toBoolean(Util\Arr::getValue($conf, 'skipTriggers', ''), false);
242250

243251
// this doesn't fail, but it doesn't work, so throw an exception so the user understands
@@ -369,6 +377,7 @@ protected function createExecutable(Target $target) : Executable
369377
->produceFilePerTable($this->filePerTable)
370378
->dumpNoData($this->noData)
371379
->dumpRoutines($this->routines)
380+
->dumpEvents($this->events)
372381
->skipTriggers($this->skipTriggers)
373382
->dumpStructureOnly($this->structureOnly)
374383
->dumpTo($this->getDumpTarget($target));

src/Cli/Executable/Mysqldump.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ class Mysqldump extends Abstraction implements Executable
180180
*/
181181
private $routines = false;
182182

183+
/**
184+
* Dump scheduled events.
185+
* --events
186+
*
187+
* @var bool
188+
*/
189+
private $events = false;
190+
183191
/**
184192
* Skip triggers
185193
* --skip-triggers
@@ -443,6 +451,18 @@ public function dumpRoutines(bool $bool) : Mysqldump
443451
return $this;
444452
}
445453

454+
/**
455+
* Dump scheduled events
456+
*
457+
* @param bool $bool
458+
* @return \phpbu\App\Cli\Executable\Mysqldump
459+
*/
460+
public function dumpEvents(bool $bool) : Mysqldump
461+
{
462+
$this->events = $bool;
463+
return $this;
464+
}
465+
446466
/**
447467
* Skip triggers
448468
*
@@ -505,6 +525,7 @@ protected function createCommandLine() : CommandLine
505525
$cmd->addOptionIfNotEmpty('--set-gtid-purged', $this->gtidPurged);
506526
$cmd->addOptionIfNotEmpty('--ssl-ca', $this->sslCa);
507527
$cmd->addOptionIfNotEmpty('--routines', $this->routines, false);
528+
$cmd->addOptionIfNotEmpty('--events', $this->events, false);
508529
$cmd->addOptionIfNotEmpty('--skip-triggers', $this->skipTriggers, false);
509530

510531
$this->configureSourceData($cmd);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
* @link http://www.phpbu.de/
1515
* @since Class available since Release 6.0.12
1616
*/
17-
class WordpressTest extends TestCase
17+
class WordPressTest extends TestCase
1818
{
1919
/**
2020
* Tests Wordpress::setup
2121
*/
2222
public function testSetup()
2323
{
24-
$arr = new Wordpress();
24+
$arr = new WordPress();
2525
$arr->setup(['file' => PHPBU_TEST_FILES . '/misc/wp-config.php']);
2626

2727
$this->assertTrue(true);
@@ -33,7 +33,7 @@ public function testSetup()
3333
public function testSetupFail()
3434
{
3535
$this->expectException('phpbu\App\Exception');
36-
$arr = new Wordpress();
36+
$arr = new WordPress();
3737
$arr->setup(['file' => 'wp-config.php']);
3838
}
3939

@@ -42,7 +42,7 @@ public function testSetupFail()
4242
*/
4343
public function testGetValue()
4444
{
45-
$arr = new Wordpress();
45+
$arr = new WordPress();
4646
$arr->setup(['file' => PHPBU_TEST_FILES . '/misc/wp-config.php']);
4747

4848
$dbName = $arr->getValue('DB_NAME');
@@ -57,7 +57,7 @@ public function testGetValue()
5757
public function testGetValueFail()
5858
{
5959
$this->expectException('phpbu\App\Exception');
60-
$arr = new Wordpress();
60+
$arr = new WordPress();
6161
$arr->setup(['file' => PHPBU_TEST_FILES . '/misc/wp-config.php']);
6262

6363
$arr->getValue('DB_FAIL');

tests/phpbu/Backup/Source/InfluxdumpTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace phpbu\App\Backup\Source;
33

4+
use Exception;
45
use phpbu\App\Backup\CliMockery;
56
use phpbu\App\BaseMockery;
67
use PHPUnit\Framework\TestCase;
@@ -113,8 +114,8 @@ public function testBackupFail()
113114

114115
try {
115116
$influxd->backup($target, $appResult);
116-
} catch (\Exception $e) {
117-
$this->assertFileNotExists($file);
117+
} catch (Exception $e) {
118+
$this->assertFileDoesNotExist($file);
118119
throw $e;
119120
}
120121
}

tests/phpbu/Backup/Source/LdapdumpTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace phpbu\App\Backup\Source;
33

4+
use Exception;
45
use phpbu\App\Backup\CliMockery;
56
use phpbu\App\BaseMockery;
67
use PHPUnit\Framework\TestCase;
@@ -198,8 +199,8 @@ public function testBackupFail()
198199

199200
try {
200201
$ldap->backup($target, $appResult);
201-
} catch (\Exception $e) {
202-
$this->assertFileNotExists($file);
202+
} catch (Exception $e) {
203+
$this->assertFileDoesNotExist($file);
203204
throw $e;
204205
}
205206
}

tests/phpbu/Backup/Source/MysqldumpTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,20 @@ public function testSkipTriggers()
209209
$this->assertEquals(PHPBU_TEST_BIN . '/mysqldump --skip-triggers --all-databases', $executable->getCommand());
210210
}
211211

212+
/**
213+
* Tests Mysqldump::
214+
*/
215+
public function testEvents()
216+
{
217+
$target = $this->createTargetMock();
218+
$mysqldump = new Mysqldump();
219+
$mysqldump->setup(['pathToMysqldump' => PHPBU_TEST_BIN, 'events' => 'true']);
220+
221+
$executable = $mysqldump->getExecutable($target);
222+
223+
$this->assertEquals(PHPBU_TEST_BIN . '/mysqldump --events --all-databases', $executable->getCommand());
224+
}
225+
212226
/**
213227
* Tests Mysqldump::backup
214228
*/
@@ -324,7 +338,7 @@ public function testBackupFail()
324338
try {
325339
$mysqldump->backup($target, $appResult);
326340
} catch (Exception $e) {
327-
$this->assertFileNotExists($file);
341+
$this->assertFileDoesNotExist($file);
328342
throw $e;
329343
}
330344
}

tests/phpbu/Cli/Executable/MysqldumpTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ public function testNoData()
226226
$this->assertEquals($path . '/mysqldump --all-databases --no-data', $mysqldump->getCommand());
227227
}
228228

229+
/**
230+
* Tests Mysqldump::dumpEvents
231+
*/
232+
public function testEvents()
233+
{
234+
$path = realpath(__DIR__ . '/../../../_files/bin');
235+
$mysqldump = new Mysqldump($path);
236+
$mysqldump->dumpEvents(true);
237+
238+
$this->assertEquals($path . '/mysqldump --events --all-databases', $mysqldump->getCommand());
239+
}
240+
229241
/**
230242
* Tests Mysqldump::getCommand
231243
*/

tests/phpbu/Util/CliTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ public function testRemoveDir()
181181

182182
Cli::removeDir($dirToDelete);
183183

184-
$this->assertFileNotExists($file);
185-
$this->assertFileNotExists($fileInSub);
186-
$this->assertFileNotExists($subDir);
187-
$this->assertFileNotExists($dirToDelete);
184+
$this->assertFileDoesNotExist($file);
185+
$this->assertFileDoesNotExist($fileInSub);
186+
$this->assertFileDoesNotExist($subDir);
187+
$this->assertFileDoesNotExist($dirToDelete);
188188
}
189189

190190
/**

0 commit comments

Comments
 (0)