HelperFormElementTest.php 1.17 KB
Newer Older
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
<?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 {

    public function testEexplodeParameter() {
        $a = array();
        HelperFormElement::explodeParameter($a);
        $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']];

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

    /**
     * @expectedException \qfq\exceptions\UserException
     *
     */
    public function testExplodeParameterException() {

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

    }

}