forked from nette/tester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dumper.toPhp.phpt
50 lines (42 loc) · 1.5 KB
/
Dumper.toPhp.phpt
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
<?php
use Tester\Assert,
Tester\Dumper;
require __DIR__ . '/bootstrap.php';
class Test
{
public $x = array(10, NULL);
private $y = 'hello';
protected $z = 30.0;
}
Assert::match( 'NULL', Dumper::toPhp(NULL) );
Assert::match( 'TRUE', Dumper::toPhp(TRUE) );
Assert::match( 'FALSE', Dumper::toPhp(FALSE) );
Assert::match( '0', Dumper::toPhp(0) );
Assert::match( '1', Dumper::toPhp(1) );
Assert::match( '0.0', Dumper::toPhp(0.0) );
Assert::match( '0.1', Dumper::toPhp(0.1) );
Assert::match( "''", Dumper::toPhp('') );
Assert::match( "' '", Dumper::toPhp(' ') );
Assert::match( "'0'", Dumper::toPhp('0') );
Assert::match( '"\\x00"', Dumper::toPhp("\x00") );
Assert::match( "' '", Dumper::toPhp("\t") );
Assert::match( '"\\xff"', Dumper::toPhp("\xFF") );
Assert::match( '"multi\nline"', Dumper::toPhp("multi\nline") );
Assert::match( "'Iñtërnâtiônàlizætiøn'", Dumper::toPhp("I\xc3\xb1t\xc3\xabrn\xc3\xa2ti\xc3\xb4n\xc3\xa0liz\xc3\xa6ti\xc3\xb8n") );
Assert::match( 'array(
1,
\'hello\',
"\r" => array(),
array(1, 2),
array(1 => 1, 2, 3, 4, 5, 6, 7),
)', Dumper::toPhp(array(1, 'hello', "\r" => array(), array(1, 2), array(1 => 1, 2, 3, 4, 5, 6, 7))) );
Assert::match( "/* resource stream */", Dumper::toPhp(fopen(__FILE__, 'r')) );
Assert::match( '(object) array()', Dumper::toPhp((object) NULL) );
Assert::match( "(object) array(
'a' => 'b',
)", Dumper::toPhp((object) array('a' => 'b')) );
Assert::match( "Test::__set_state(array(
'x' => array(10, NULL),
'y' => 'hello',
'z' => 30.0,
))", Dumper::toPhp(new Test) );