| | |
| | | <?php |
| | | |
| | | require 'bootstrap.php'; |
| | | |
| | | /** |
| | | * Implementazione dei test per la classe SetupUpload |
| | | * |
| | |
| | | $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(){ |
| | | public function testDefaultValue() { |
| | | $this->assertEquals(1, $this->object->getNumMaxFiles()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Gestione di valori non adeguati |
| | | * @since 0.3.1 |
| | | * @expectedException UploadFile_Exc |
| | | * @expectedException Upload_Exc_Error |
| | | * @dataProvider getNumMaxFilesException |
| | | */ |
| | | public function testNotValidNumMaxFilesGetException($num){ |
| | | public function testNotValidNumMaxFilesGetException($num) { |
| | | $this->object->setNumMaxFiles($num); |
| | | } |
| | | |
| | | public function getNumMaxFilesException () { |
| | | |
| | | public function getNumMaxFilesException() { |
| | | return array( |
| | | array(''), |
| | | array(0), |
| | |
| | | * @since 0.3.1 |
| | | * @dataProvider getSomeMaxFiles |
| | | */ |
| | | public function testSomeValidMaxFiles($num){ |
| | | public function testSomeValidMaxFiles($num) { |
| | | $this->object->setNumMaxFiles($num); |
| | | $this->assertEquals($num, $this->object->getNumMaxFiles()); |
| | | } |
| | | |
| | | public function getSomeMaxFiles () { |
| | | |
| | | public function getSomeMaxFiles() { |
| | | return array( |
| | | array(2), |
| | | array(020), |
| | |
| | | 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()); |
| | | } |
| | | |
| | | } |