commit | author | age
|
0868e0
|
1 |
<?php |
JK |
2 |
class JSArrayTest extends PHPUnit_Framework_TestCase { |
|
3 |
public function testEmptyString() { |
|
4 |
$result = jsarray::parse(''); |
|
5 |
$this->assertSame(NULL, $result); |
|
6 |
} |
|
7 |
|
|
8 |
public function testEmptyArray() { |
|
9 |
$result = jsarray::parse('[]'); |
|
10 |
$this->assertEquals(array(), $result); |
|
11 |
} |
|
12 |
|
|
13 |
public function testNestedArrays() { |
|
14 |
$array = array( |
|
15 |
array(1, 2, array(), 5, array(6, array(7, 8))), |
|
16 |
array(9), |
|
17 |
'10' |
|
18 |
); |
|
19 |
$array_js = json_encode($array); |
|
20 |
$array_decoded = jsarray::parse($array_js); |
|
21 |
|
|
22 |
$this->assertEquals($array, $array_decoded); |
|
23 |
} |
|
24 |
|
|
25 |
public function testInvalid() { |
|
26 |
$result = jsarray::parse('()'); |
|
27 |
$this->assertSame(FALSE, $result); |
|
28 |
} |
|
29 |
} |