From 8a128239d994c278d94904a98ca646eedbe47e4e Mon Sep 17 00:00:00 2001
From: Cristiano Magro <cristiano.magro@vola.it>
Date: Tue, 27 Aug 2019 11:21:39 +0200
Subject: [PATCH] Creo una classe filtro.
---
tests/Vola/UploadFile/FilterExtTest.php | 38 +++++++++++++++++++
src/Vola/UploadFile/FilterExt.class.php | 27 +++++++++++++
src/Vola/UploadFile/Autoloader.php | 1
3 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/src/Vola/UploadFile/Autoloader.php b/src/Vola/UploadFile/Autoloader.php
index 4021e10..d9b025a 100644
--- a/src/Vola/UploadFile/Autoloader.php
+++ b/src/Vola/UploadFile/Autoloader.php
@@ -26,6 +26,7 @@
'FileUpload' => 'FileUpload.class.php',
'SetupUpload' => 'SetupUpload.class.php',
'FilesFilter' => 'FilesFilter.class.php',
+ 'FilterExt' => 'FilterExt.class.php',
'Upload_Exc_Error' => 'Exc/Error.php',
'Upload_Exc_Extension' => 'Exc/Extension.php',
'Upload_Exc_ExtensionNotValid' => 'Exc/ExtensionNotValid.php',
diff --git a/src/Vola/UploadFile/FilterExt.class.php b/src/Vola/UploadFile/FilterExt.class.php
new file mode 100644
index 0000000..a557613
--- /dev/null
+++ b/src/Vola/UploadFile/FilterExt.class.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * User: Cristiano Magro
+ * Date: 09/07/2019
+ */
+
+class FilterExt {
+
+
+ private $titolo;
+ private $extensions;
+
+ public function __construct($titolo = null, $ext = null )
+ {
+ $this->titolo = $titolo;
+ $this->extensions[$ext] = $ext;
+ }
+
+ public function getFilter()
+ {
+ $new = new stdClass();
+ $new->titolo = $this->titolo;
+ $new->extensions = implode(',', $this->extensions);
+
+ return json_encode($new);
+ }
+}
\ No newline at end of file
diff --git a/tests/Vola/UploadFile/FilterExtTest.php b/tests/Vola/UploadFile/FilterExtTest.php
new file mode 100644
index 0000000..3d27155
--- /dev/null
+++ b/tests/Vola/UploadFile/FilterExtTest.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * User: Cristiano Magro
+ * Date: 09/07/2019
+ */
+
+class FilterExtTest extends PHPUnit_Framework_TestCase
+{
+ /** @var FilterExt $object */
+ protected $object;
+
+ /**
+ * Set up fixture, inizializzazione dei test.
+ * Eseguito prima di ogni test
+ */
+ protected function setUp()
+ {
+ $this->object = new FilterExt();
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+
+ }
+
+ public function testCreateNewFilter()
+ {
+ $atteso = '{"titolo":"titolo","extensions":"ext"}';
+ $obj = new FilterExt('titolo', 'ext');
+
+ $this->assertEquals($atteso, $obj->getFilter());
+ }
+
+}
\ No newline at end of file
--
Gitblit v1.8.0