HelperFormElementTest.php 1.75 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php

/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/26/16
 * Time: 2:56 PM
 */

namespace qfq;

use qfq\HelperFormElement;

require_once(__DIR__ . '/../../qfq/helper/HelperFormElement.php');
require_once(__DIR__ . '/../../qfq/Constants.php');

class HelperFormElementTest extends \PHPUnit_Framework_TestCase {

19
20
21
22
23
24
25
26
27
28
29
30
31
32
    public function testExplodeParameter() {
        $a = array();

        HelperFormElement::explodeParameter($a);
        $this->assertEquals(array(), $a, "Both arrays should be equal and empty");

        $a = ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete"];
        $b = ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete", 'work' => 12, 'list' => '1:new,2:edit,3:delete'];

        HelperFormElement::explodeParameter($a);
        $this->assertEquals($b, $a, "Both arrays should be equal");
    }

    public function testExplodeParameterInArrayElements() {
33
        $a = array();
34
        HelperFormElement::explodeParameterInArrayElements($a);
35
36
37
38
39
        $this->assertEquals(array(), $a, "Both arrays should be equal and empty");

        $a = [0 => ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete"]];
        $b = [0 => ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete", 'work' => 12, 'list' => '1:new,2:edit,3:delete']];

40
        HelperFormElement::explodeParameterInArrayElements($a);
41
42
43
        $this->assertEquals($b, $a, "Both arrays should be equal");
    }

44

45
    /**
46
     * @expectedException \qfq\UserException
47
48
     *
     */
49
    public function testExplodeFieldParameterException() {
50
51

        $a = [0 => ['id' => 111, 'name' => 'hello', 'collision' => 'dummy', 'parameter' => "work=12\ncollision=1:new,2:edit,3:delete"]];
52
        HelperFormElement::explodeParameterInArrayElements($a);
53
54
55
56

    }

}