From cedb4c5f01c1cab484e8d0fffff85fe187d45480 Mon Sep 17 00:00:00 2001
From: Cristiano Magro <cristiano.magro@vola.it>
Date: Tue, 27 Aug 2019 11:21:40 +0200
Subject: [PATCH] Fix title
---
tests/SetupUploadTest.php | 154 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 144 insertions(+), 10 deletions(-)
diff --git a/tests/SetupUploadTest.php b/tests/SetupUploadTest.php
index c014a13..a0ac041 100644
--- a/tests/SetupUploadTest.php
+++ b/tests/SetupUploadTest.php
@@ -1,20 +1,49 @@
<?php
-require 'bootstrap.php';
-
/**
- * Description of FbResponseTest
+ * Implementazione dei test per la classe SetupUpload
*
* @author Cristiano Magro
*/
-class SetupUploadTest extends PHPUnit_Framework_TestCase {
+class SetupUploadTest extends PHPUnit_Framework_TestCase
+{
- public static function setUpBeforeClass() {
+ /**
+ * @var $object SetupUpload
+ */
+ protected $object;
+
+ /**
+ * Set up fixture, inizializzazione dei test.
+ * Eseguito prima di ogni test
+ */
+ protected function setUp()
+ {
+ $this->object = SetupUpload::create();
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
}
- public function test_str2Bytes() {
+ public static function setUpBeforeClass()
+ {
+
+ }
+
+ /**
+ * Conversione di una stringa nel corrispondente valore di byte
+ *
+ * @since 0.3.0
+ */
+ public function test_str2Bytes()
+ {
$this->assertEquals('1', SetupUpload::str2Bytes('1'));
$this->assertEquals('1', SetupUpload::str2Bytes('1b'));
@@ -24,24 +53,129 @@
$this->assertEquals('1024', SetupUpload::str2Bytes('1 Kb'));
$this->assertEquals('1024', SetupUpload::str2Bytes('1 KB'));
-
$this->assertEquals('1024', SetupUpload::str2Bytes('1 kb'));
$this->assertEquals('2048', SetupUpload::str2Bytes('2 Kb'));
$this->assertEquals('1024', SetupUpload::str2Bytes('1 KB'));
$this->assertEquals('2048', SetupUpload::str2Bytes('2 Kb'));
-
$this->assertEquals('1048576', SetupUpload::str2Bytes('1 mB'));
-
$this->assertEquals('0', SetupUpload::str2Bytes('0 B'));
$this->assertEquals('0', SetupUpload::str2Bytes('0 kB'));
$this->assertEquals('0', SetupUpload::str2Bytes('0 mB'));
$this->assertEquals('0', SetupUpload::str2Bytes('0 GB'));
$this->assertEquals('0', SetupUpload::str2Bytes('0 TB'));
- $this->assertEquals('0', SetupUpload::str2Bytes('0 XB'));
+ }
+ /**
+ * Conversione di una stringa nel corrispondente valore di byte, stringhe
+ * non convertibili devono andare in errore
+ *
+ * @since 0.3.1
+ * @expectedException Upload_Exc_Error
+ * @dataProvider getBytesStringNotValid
+ */
+ public function test_str2BytesNonValido($byteString)
+ {
+ SetupUpload::str2Bytes($byteString);
+ }
+ public function getBytesStringNotValid()
+ {
+ return array(
+ array(''),
+ array('b'),
+ array('1 k'),
+ array('1 a'),
+ );
+ }
+
+ /**
+ * La coda non inizializzata prevede un numero minimo di files
+ *
+ * @since 0.3.1
+ */
+ public function testDefaultValue()
+ {
+ $this->assertEquals(1, $this->object->getNumMaxFiles());
+ }
+
+ /**
+ * Gestione di valori non adeguati
+ *
+ * @since 0.3.1
+ * @expectedException Upload_Exc_Error
+ * @dataProvider getNumMaxFilesException
+ */
+ public function testNotValidNumMaxFilesGetException($num)
+ {
+ $this->object->setNumMaxFiles($num);
+ }
+
+ public function getNumMaxFilesException()
+ {
+ return array(
+ array(''),
+ array(0),
+ array(-10),
+ array('a'),
+ );
+ }
+
+ /**
+ * Caselle della coda valide
+ *
+ * @since 0.3.1
+ * @dataProvider getSomeMaxFiles
+ */
+ public function testSomeValidMaxFiles($num)
+ {
+ $this->object->setNumMaxFiles($num);
+ $this->assertEquals($num, $this->object->getNumMaxFiles());
+ }
+
+ public function getSomeMaxFiles()
+ {
+ return array(
+ array(2),
+ array(020),
+ array(100),
+ array(10000),
+ );
+ }
+
+ /**
+ * Impostazioni delle dimensioni massime del totale caricabile
+ *
+ * @since 0.3.1
+ */
+ public function testSetSizeMaxFilesByte()
+ {
+ $this->object->setSizeMaxFilesByte(100);
+ $this->assertEquals(100, $this->object->getSizeMaxFilesByte());
+
+ $this->object->setSizeMaxFilesByte('200');
+ $this->assertEquals(200, $this->object->getSizeMaxFilesByte());
+
+ $this->object->setSizeMaxFilesByte('3 kb');
+ $this->assertEquals(1024 * 3, $this->object->getSizeMaxFilesByte());
+ }
+
+ /**
+ * Impostazioni delle dimensioni massime di un file
+ *
+ * @since 0.3.1
+ */
+ public function testSetSizeLimitFile()
+ {
+ $this->object->setSizeLimitFile(100);
+ $this->assertEquals(100, $this->object->getSizeLimitFile());
+
+ $this->object->setSizeLimitFile('200');
+ $this->assertEquals(200, $this->object->getSizeLimitFile());
+
+ $this->object->setSizeLimitFile('3kb');
+ $this->assertEquals(1024 * 3, $this->object->getSizeLimitFile());
}
}
--
Gitblit v1.8.0