Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/PHPUnit/Unit')
-rw-r--r--tests/PHPUnit/Unit/SettingsServerTest.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/SettingsServerTest.php b/tests/PHPUnit/Unit/SettingsServerTest.php
new file mode 100644
index 0000000000..0c74e7a921
--- /dev/null
+++ b/tests/PHPUnit/Unit/SettingsServerTest.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Tests\Unit;
+
+use Piwik\SettingsServer;
+
+/**
+ * @group Core
+ * @group SettingsServer
+ */
+class SettingsServerTest extends \PHPUnit\Framework\TestCase
+{
+ /**
+ * Dataprovider for testGetMegaBytesFromShorthandByte
+ */
+ public function getShorthandByteTestData()
+ {
+ return [
+ ['8M', 8],
+ ['10 m', 10],
+ ['2g', 2048],
+ ['1K', 1/1024],
+ ['1048576', 1],
+ ['garbl', false],
+ ['17sdfsdf', false],
+ ];
+ }
+
+ /**
+ * @dataProvider getShorthandByteTestData
+ */
+ public function testGetMegaBytesFromShorthandByte($data, $expected)
+ {
+ $class = new \ReflectionClass(SettingsServer::class);
+ $method = $class->getMethod('getMegaBytesFromShorthandByte');
+ $method->setAccessible(true);
+ $output = $method->invoke($class, $data);
+
+ $this->assertEquals($expected, $output);
+ }
+} \ No newline at end of file