| composer.json | ●●●●● patch | view | raw | blame | history | |
| src/Vola/UploadFile/Autoloader.php | ●●●●● patch | view | raw | blame | history | |
| src/Vola/UploadFile/Exc/Estension.php | ●●●●● patch | view | raw | blame | history | |
| src/Vola/UploadFile/Exc/ExtensionNotValid.php | ●●●●● patch | view | raw | blame | history | |
| src/Vola/UploadFile/Exc/FileNotExist.php | ●●●●● patch | view | raw | blame | history | |
| src/Vola/UploadFile/FileUp.php | ●●●●● patch | view | raw | blame | history | |
| tests/Vola/UploadFile/FileUpTest.php | ●●●●● patch | view | raw | blame | history |
composer.json
@@ -6,5 +6,8 @@ "name": "Cristiano Magro", "email": "cristiano.magro@vola.it" } ] } ], "require-dev": { "phpunit/phpunit": "^4.8" } } src/Vola/UploadFile/Autoloader.php
@@ -26,6 +26,11 @@ 'FileUpload' => 'FileUpload.class.php', 'SetupUpload' => 'SetupUpload.class.php', 'Upload_Exc_Error' => 'Exc/Error.php', 'Upload_Exc_Extension' => 'Exc/Extension.php', 'Upload_Exc_ExtensionNotValid' => 'Exc/ExtensionNotValid.php', 'Upload_Exc_FileNotExist' => 'Exc/FileNotExist.php', 'Upload_MgrFile' => 'MgrFile.php', 'Upload_FileUp' => 'FileUp.php', ); /** src/Vola/UploadFile/Exc/Estension.php
New file @@ -0,0 +1,14 @@ <?php /** * Eccezioni * @since 0.3.2 */ /** * Eccezione nel caso l'estensione del file non si a tra quelle permesse * @since 0.3.2 */ class Upload_Exc_Extension extends Upload_Exc_Error { } src/Vola/UploadFile/Exc/ExtensionNotValid.php
New file @@ -0,0 +1,14 @@ <?php /** * Eccezioni * @since 0.3.2 */ /** * Eccezione nel caso l'estensione del file non si a tra quelle permesse * @since 0.3.2 */ class Upload_Exc_ExtensionNotValid extends Upload_Exc_Error { } src/Vola/UploadFile/Exc/FileNotExist.php
New file @@ -0,0 +1,14 @@ <?php /** * Eccezioni * @since 0.3.2 */ /** * Eccezione nel caso l'estensione del file non si a tra quelle permesse * @since 0.3.2 */ class Upload_Exc_FileNotExist extends Upload_Exc_Error { } src/Vola/UploadFile/FileUp.php
New file @@ -0,0 +1,68 @@ <?php /** * Created by PhpStorm. * User: Cristiano Magro * Date: 16/01/2018 * Time: 16:57 * @package Plupload * @since v0.3.2 */ /** * Class Upload_FileUp manipolazione dettagli file caricato dagestire. * * Si tratta di un wrapper per gestire il file appena caricato. * */ class Upload_FileUp { const EMPTY_OBJ = "vuoto"; private $request; private $beanFile; public static function create() { $instance = new self(); $instance->request = new stdClass(); $instance->beanFile = new stdClass(); return $instance; } public function __toString() { return $this->toString(); } /** * Creo una stringa della struttura interna per la stampa sul logger. * * @return mixed|string struttura interna per il log */ public function toString() { $text = "Richiesta: " . $this->convertToString($this->request) . PHP_EOL; $text .= "Bean: " . $this->convertToString($this->beanFile); return $text; } /** * Converto la struttura in una stringa per la stamapa. * * Se la struttura e' vuota ritorno "vuota" * @param stdClass $data struttura dati * @return string conversione della struttura */ private function convertToString(stdClass $data) { //effettuo il cast ad array per testare se la classe e' vuota $tmp = (array)$data; if (empty($tmp)) { return self::EMPTY_OBJ; } else { return print_r($data, true); } } } tests/Vola/UploadFile/FileUpTest.php
New file @@ -0,0 +1,38 @@ <?php /** * User: Cristiano Magro * Date: 16/01/2018 * Time: 17:13 */ /** * Implementazione dei test per la classe FileUp * * @author Cristiano Magro * @since 0.3.2 */ class FileUpTest extends PHPUnit_Framework_TestCase { /** @var $object Upload_FileUp */ private $object; /** * Inizializzazione oggetto per i test */ public function setUp() { $this->object = Upload_FileUp::create(); } public function testConvertToStringEmpty() { $text = "" . $this->object; $atteso = "Richiesta: vuoto" . PHP_EOL . "Bean: vuoto"; $this->assertEquals($atteso, $this->object->toString()); $this->assertEquals($atteso, $text); } }