Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PMA_OptionsPropertyGroup_test.php « options « properties « classes « test - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2566d21c19410526bfa332846d46141e7a90d9c6 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * tests for OptionsPropertyGroup class
 *
 * @package PhpMyAdmin-test
 */

require_once 'libraries/properties/options/OptionsPropertyGroup.class.php';

/**
 * Tests for OptionsPropertyGroup class
 *
 * @package PhpMyAdmin-test
 */
class PMA_OptionsPropertyGroup_Test extends PHPUnit_Framework_TestCase
{
    protected $stub;

    /**
     * Configures global environment.
     *
     * @return void
     */
    protected function setup()
    {
        $this->stub = $this->getMockForAbstractClass('OptionsPropertyGroup');
    }

    /**
     * tearDown for test cases
     *
     * @return void
     */
    public function tearDown()
    {
        unset($this->stub);
    }

    /**
     * Test for OptionsPropertyGroup::addProperty
     *
     * @return void
     */
    public function testAddProperty()
    {
        $properties = new \ReflectionProperty('OptionsPropertyGroup', '_properties');
        $properties->setAccessible(true);

        $properties->setValue($this->stub, array(1, 2, 3));

        $this->assertNull(
            $this->stub->addProperty(2)
        );

        $this->stub->addProperty('2');

        $this->assertEquals(
            array(1, 2, 3, '2'),
            $properties->getValue($this->stub)
        );
    }

    /**
     * Test for OptionsPropertyGroup::removeProperty
     *
     * @return void
     */
    public function testRemoveProperty()
    {
        $properties = new \ReflectionProperty('OptionsPropertyGroup', '_properties');
        $properties->setAccessible(true);

        $properties->setValue($this->stub, array(1, 2, 'test', 3));
        $this->stub->removeProperty('test');

        $this->assertEquals(
            array(
                0 => 1,
                1 => 2,
                3 => 3
            ),
            $properties->getValue($this->stub)
        );
    }

    /**
     * Test for OptionsPropertyGroup::getGroup
     *
     * @return void
     */
    public function testGetGroup()
    {
        $this->assertInstanceOf(
            'OptionsPropertyGroup',
            $this->stub->getGroup()
        );
    }

    /**
     * Test for OptionsPropertyGroup::getProperties
     *
     * @return void
     */
    public function testGetProperties()
    {
        $properties = new \ReflectionProperty('OptionsPropertyGroup', '_properties');
        $properties->setAccessible(true);
        $properties->setValue($this->stub, array(1, 2, 3));

        $this->assertEquals(
            array(1, 2, 3),
            $this->stub->getProperties()
        );
    }

    /**
     * Test for OptionsPropertyGroup::getProperties
     *
     * @return void
     */
    public function testGetNrOfProperties()
    {
        $properties = new \ReflectionProperty('OptionsPropertyGroup', '_properties');
        $properties->setAccessible(true);
        $properties->setValue($this->stub, array(1, 2, 3));

        $this->assertEquals(
            3,
            $this->stub->getNrOfProperties()
        );
    }
}
?>