-
Notifications
You must be signed in to change notification settings - Fork 709
/
HelperTest.php
78 lines (68 loc) · 2.15 KB
/
HelperTest.php
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
<?php
# MantisBT - a php based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* Mantis Unit Tests
* @package Tests
* MantisBT Core Unit Tests
* @subpackage Helper
* @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*/
# Includes
require_once dirname( dirname( __FILE__ ) ) . '/TestConfig.php';
# MantisBT Core API
require_mantis_core();
/**
* Helper API tests
* @package Tests
* @subpackage String
*/
class Mantis_HelperTest extends PHPUnit_Framework_TestCase {
/**
* Tests helper_array_transpose()
* @dataProvider providerArrayTranspose
* @param mixed $p_in Input array.
* @param mixed $p_out Output array.
* @return void
*/
public function testArrayTranspose( $p_in, $p_out ) {
$this->assertEquals( $p_out, helper_array_transpose( $p_in ) );
}
/**
* Returns test array
* @return array
*/
public function providerArrayTranspose() {
return array(
# simple array
array( array(123,456), array(123,456) ),
# mixed (1st element array, 2nd scalar)
array(
array('a'=>array('k1'=>1,'k2'=>2),'b'=>123),
array('a'=>array('k1'=>1,'k2'=>2),'b'=>123),
),
# bidimentional array
array(
array('a'=>array('k1'=>1,'k2'=>2),'b'=>array('k1'=>3,'k2'=>4)),
array('k1'=>array('a'=>1,'b'=>3),'k2'=>array('a'=>2,'b'=>4))
),
# bidimentional array with arrays as elements' data
array(
array('a'=>array('k1'=>array(1,2,3),'k2'=>2),'b'=>array('k1'=>array(4,5,6),'k2'=>4)),
array('k1'=>array('a'=>array(1,2,3),'b'=>array(4,5,6)),'k2'=>array('a'=>2,'b'=>4))
),
);
}
}