Permalink
Show file tree
Hide file tree
28 changes: 28 additions & 0 deletions
28
deb/openmediavault/usr/share/openmediavault/unittests/php/test_openmediavault_functions.php
17 changes: 16 additions & 1 deletion
17
deb/openmediavault/usr/share/php/openmediavault/config/databasebackend.inc
6 changes: 4 additions & 2 deletions
6
deb/openmediavault/usr/share/php/openmediavault/functions.inc
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Cleanup code, add unit tests.
Signed-off-by: Volker Theile <votdev@gmx.de>
- Loading branch information
Showing
4 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...ult/usr/share/openmediavault/unittests/php/test_openmediavault_config_databasebackend.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/usr/bin/phpunit -c/etc/openmediavault | ||
| <?php | ||
| /** | ||
| * This file is part of OpenMediaVault. | ||
| * | ||
| * @license http://www.gnu.org/licenses/gpl.html GPL Version 3 | ||
| * @author Volker Theile <volker.theile@openmediavault.org> | ||
| * @copyright Copyright (c) 2009-2020 Volker Theile | ||
| * | ||
| * OpenMediaVault is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * any later version. | ||
| * | ||
| * OpenMediaVault is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| require_once("openmediavault/autoloader.inc"); | ||
|
|
||
| class test_openmediavault_config_databasebackend extends \PHPUnit\Framework\TestCase { | ||
| private $databaseBackend; | ||
|
|
||
| public function setUp() { | ||
| $this->databaseBackend = new \OMV\Config\DatabaseBackend( | ||
| sprintf("%s/../data/config.xml", getcwd()), | ||
| FALSE); | ||
| $this->databaseBackend->load(); | ||
| } | ||
|
|
||
| public function test_compare_1() { | ||
| $this->assertEquals($this->databaseBackend->compare( | ||
| "//system/time", | ||
| [ | ||
| "timezone" => "Europe/Berlin", | ||
| "ntp" => [ | ||
| "enable" => 0, | ||
| "timeservers" => "pool.ntp.org", | ||
| "clients" => "" | ||
| ] | ||
| ] | ||
| ), 0); | ||
| } | ||
|
|
||
| public function test_compare_2() { | ||
| $this->assertEquals($this->databaseBackend->compare( | ||
| "//system/powermanagement", | ||
| [ | ||
| "cpufreq" => 0, | ||
| "powerbtn" => "nothing" | ||
| ] | ||
| ), -1); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters