Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/var-dumper/Tests/Caster/SplCasterTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\VarDumper\Tests\Caster; | |
13 | |
14 use PHPUnit\Framework\TestCase; | |
15 use Symfony\Component\VarDumper\Test\VarDumperTestTrait; | |
16 | |
17 /** | |
18 * @author Grégoire Pineau <lyrixx@lyrixx.info> | |
19 */ | |
20 class SplCasterTest extends TestCase | |
21 { | |
22 use VarDumperTestTrait; | |
23 | |
24 public function getCastFileInfoTests() | |
25 { | |
26 return array( | |
27 array(__FILE__, <<<'EOTXT' | |
28 SplFileInfo { | |
29 %Apath: "%sCaster" | |
30 filename: "SplCasterTest.php" | |
31 basename: "SplCasterTest.php" | |
32 pathname: "%sSplCasterTest.php" | |
33 extension: "php" | |
34 realPath: "%sSplCasterTest.php" | |
35 aTime: %s-%s-%d %d:%d:%d | |
36 mTime: %s-%s-%d %d:%d:%d | |
37 cTime: %s-%s-%d %d:%d:%d | |
38 inode: %d | |
39 size: %d | |
40 perms: 0%d | |
41 owner: %d | |
42 group: %d | |
43 type: "file" | |
44 writable: true | |
45 readable: true | |
46 executable: false | |
47 file: true | |
48 dir: false | |
49 link: false | |
50 %A} | |
51 EOTXT | |
52 ), | |
53 array('https://google.com/about', <<<'EOTXT' | |
54 SplFileInfo { | |
55 %Apath: "https://google.com" | |
56 filename: "about" | |
57 basename: "about" | |
58 pathname: "https://google.com/about" | |
59 extension: "" | |
60 realPath: false | |
61 %A} | |
62 EOTXT | |
63 ), | |
64 ); | |
65 } | |
66 | |
67 /** @dataProvider getCastFileInfoTests */ | |
68 public function testCastFileInfo($file, $dump) | |
69 { | |
70 $this->assertDumpMatchesFormat($dump, new \SplFileInfo($file)); | |
71 } | |
72 | |
73 public function testCastFileObject() | |
74 { | |
75 $var = new \SplFileObject(__FILE__); | |
76 $var->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY); | |
77 $dump = <<<'EOTXT' | |
78 SplFileObject { | |
79 %Apath: "%sCaster" | |
80 filename: "SplCasterTest.php" | |
81 basename: "SplCasterTest.php" | |
82 pathname: "%sSplCasterTest.php" | |
83 extension: "php" | |
84 realPath: "%sSplCasterTest.php" | |
85 aTime: %s-%s-%d %d:%d:%d | |
86 mTime: %s-%s-%d %d:%d:%d | |
87 cTime: %s-%s-%d %d:%d:%d | |
88 inode: %d | |
89 size: %d | |
90 perms: 0%d | |
91 owner: %d | |
92 group: %d | |
93 type: "file" | |
94 writable: true | |
95 readable: true | |
96 executable: false | |
97 file: true | |
98 dir: false | |
99 link: false | |
100 %AcsvControl: array:%d [ | |
101 0 => "," | |
102 1 => """ | |
103 %A] | |
104 flags: DROP_NEW_LINE|SKIP_EMPTY | |
105 maxLineLen: 0 | |
106 fstat: array:26 [ | |
107 "dev" => %d | |
108 "ino" => %d | |
109 "nlink" => %d | |
110 "rdev" => 0 | |
111 "blksize" => %i | |
112 "blocks" => %i | |
113 …20 | |
114 ] | |
115 eof: false | |
116 key: 0 | |
117 } | |
118 EOTXT; | |
119 $this->assertDumpMatchesFormat($dump, $var); | |
120 } | |
121 | |
122 /** | |
123 * @dataProvider provideCastSplDoublyLinkedList | |
124 */ | |
125 public function testCastSplDoublyLinkedList($modeValue, $modeDump) | |
126 { | |
127 $var = new \SplDoublyLinkedList(); | |
128 $var->setIteratorMode($modeValue); | |
129 $dump = <<<EOTXT | |
130 SplDoublyLinkedList { | |
131 %Amode: $modeDump | |
132 dllist: [] | |
133 } | |
134 EOTXT; | |
135 $this->assertDumpMatchesFormat($dump, $var); | |
136 } | |
137 | |
138 public function provideCastSplDoublyLinkedList() | |
139 { | |
140 return array( | |
141 array(\SplDoublyLinkedList::IT_MODE_FIFO, 'IT_MODE_FIFO | IT_MODE_KEEP'), | |
142 array(\SplDoublyLinkedList::IT_MODE_LIFO, 'IT_MODE_LIFO | IT_MODE_KEEP'), | |
143 array(\SplDoublyLinkedList::IT_MODE_FIFO | \SplDoublyLinkedList::IT_MODE_DELETE, 'IT_MODE_FIFO | IT_MODE_DELETE'), | |
144 array(\SplDoublyLinkedList::IT_MODE_LIFO | \SplDoublyLinkedList::IT_MODE_DELETE, 'IT_MODE_LIFO | IT_MODE_DELETE'), | |
145 ); | |
146 } | |
147 } |