@@ -68,7 +68,7 @@ |
||
68 | 68 | $this->assertTrue(is_object($backup)); |
69 | 69 | $this->assertEquals(BackupType::FILES, $backup->type); |
70 | 70 | $this->assertFileExists($backup->getFullPath()); |
71 | - // @unlink($backup->getFullPath()); |
|
71 | + // @unlink($backup->getFullPath()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function testSaveAllOldBackups() |
@@ -47,16 +47,19 @@ discard block |
||
47 | 47 | $this->dumperClass = $dumperClass; |
48 | 48 | $this->configs = Yii::$app->getModule('backup')->configs; |
49 | 49 | |
50 | - if (!is_array($this->configs) || !sizeof($this->configs)) |
|
51 | - throw new InvalidConfigExceptionAlias('Backup module need to be configured with `config array`'); |
|
50 | + if (!is_array($this->configs) || !sizeof($this->configs)) { |
|
51 | + throw new InvalidConfigExceptionAlias('Backup module need to be configured with `config array`'); |
|
52 | + } |
|
52 | 53 | |
53 | 54 | foreach ($this->configs as $config) { |
54 | - if (isset($config['id']) && $config['id'] == $config_id) |
|
55 | - $this->currentConfig = $config; |
|
55 | + if (isset($config['id']) && $config['id'] == $config_id) { |
|
56 | + $this->currentConfig = $config; |
|
57 | + } |
|
56 | 58 | } |
57 | 59 | |
58 | - if (!$this->currentConfig) |
|
59 | - throw new InvalidConfigExceptionAlias("Config `{$config_id}` not found."); |
|
60 | + if (!$this->currentConfig) { |
|
61 | + throw new InvalidConfigExceptionAlias("Config `{$config_id}` not found."); |
|
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | 65 | /** |
@@ -91,17 +94,19 @@ discard block |
||
91 | 94 | */ |
92 | 95 | protected function deleteOldFiles() |
93 | 96 | { |
94 | - if (!isset($this->currentConfig['limit']) || empty($this->currentConfig['limit'])) |
|
95 | - return false; |
|
97 | + if (!isset($this->currentConfig['limit']) || empty($this->currentConfig['limit'])) { |
|
98 | + return false; |
|
99 | + } |
|
96 | 100 | $backups = Backup::find() |
97 | 101 | ->where(['config_id' => $this->currentConfig['id']]) |
98 | 102 | ->orderBy('date DESC') |
99 | 103 | ->offset($this->currentConfig['limit'] - 1) |
100 | 104 | ->all(); |
101 | 105 | |
102 | - if ($backups) |
|
103 | - foreach ($backups as $backup) |
|
106 | + if ($backups) { |
|
107 | + foreach ($backups as $backup) |
|
104 | 108 | $backup->delete(); |
109 | + } |
|
105 | 110 | } |
106 | 111 | |
107 | 112 | /** |