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:
authorStefan Giehl <stefan@matomo.org>2021-01-01 03:30:49 +0300
committerGitHub <noreply@github.com>2021-01-01 03:30:49 +0300
commit339b5cd33c5f47a2a67730b3bfb9eed210219585 (patch)
tree27cfd92572dc24465238e66bfb59e9dee0cd0e0b /tests/PHPUnit/Unit
parent52c573a0572f079c99bfa3331b8ef4164e199281 (diff)
Don't accept files that are bigger than the upload limit when uploading plugins (#16849)
* Don't accept files that are bigger than the upload limit when uploading plugins * improve / simplify code * adds some tests
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