Classi per la configurazione upload
Cristiano Magro
11 hours ago c577fe041042abfe3203edb1700b0ff0877d776e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
 * User: Cristiano Magro
 * Date: 08/07/2019
 */
 
class FilesFilterTest extends PHPUnit_Framework_TestCase
{
    /** @var FilesFilter $object */
    protected $object;
 
    /**
     * Set up fixture, inizializzazione dei test.
     * Eseguito prima di ogni test
     */
    protected function setUp()
    {
        $this->object = new FilesFilter();
    }
 
    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
 
    }
 
    /**
     * @dataProvider addExtension
     */
    public function testAddExtension($lista, $atteso)
    {
 
        foreach ($lista as $item) {
            $this->object->addExt($item);
        }
 
        $esito = $this->object->toJson();
 
        $this->assertEquals($atteso, $esito);
    }
 
    public function addExtension()
    {
        return [
            [[], '[]'],
            [['fasullo'], '[]'],
            [['gif'], '[{"title":"Image files","extensions":"gif"}]'],
            [['doc'], '[{"title":"Documenti","extensions":"doc"}]'],
            [['DOC'], '[{"title":"Documenti","extensions":"DOC"}]'],
            [['txt'], '[{"title":"Documenti","extensions":"txt"}]'],
            [['DOc', 'gif'], '[{"title":"Documenti","extensions":"DOc"},{"title":"Image files","extensions":"gif"}]'],
            [['txt', 'doc'], '[{"title":"Documenti","extensions":"doc,txt"}]'],
            [['gif', 'fasullo'], '[{"title":"Image files","extensions":"gif"}]'],
        ];
    }
 
 
    public function testDecodeTitolo()
    {
        $atteso = "Documenti";
 
        $this->assertEquals($atteso, $this->object->decodeTitolo('Doc'));
        $this->assertEquals($atteso, $this->object->decodeTitolo('doc'));
    }
 
}