Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/var-dumper/Tests/Cloner/VarClonerTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 7a779792577d |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
19 */ | 19 */ |
20 class VarClonerTest extends TestCase | 20 class VarClonerTest extends TestCase |
21 { | 21 { |
22 public function testMaxIntBoundary() | 22 public function testMaxIntBoundary() |
23 { | 23 { |
24 $data = array(PHP_INT_MAX => 123); | 24 $data = [PHP_INT_MAX => 123]; |
25 | 25 |
26 $cloner = new VarCloner(); | 26 $cloner = new VarCloner(); |
27 $clone = $cloner->cloneVar($data); | 27 $clone = $cloner->cloneVar($data); |
28 | 28 |
29 $expected = <<<EOTXT | 29 $expected = <<<EOTXT |
147 } | 147 } |
148 | 148 |
149 public function testLimits() | 149 public function testLimits() |
150 { | 150 { |
151 // Level 0: | 151 // Level 0: |
152 $data = array( | 152 $data = [ |
153 // Level 1: | 153 // Level 1: |
154 array( | 154 [ |
155 // Level 2: | 155 // Level 2: |
156 array( | 156 [ |
157 // Level 3: | 157 // Level 3: |
158 'Level 3 Item 0', | 158 'Level 3 Item 0', |
159 'Level 3 Item 1', | 159 'Level 3 Item 1', |
160 'Level 3 Item 2', | 160 'Level 3 Item 2', |
161 'Level 3 Item 3', | 161 'Level 3 Item 3', |
162 ), | 162 ], |
163 array( | 163 [ |
164 'Level 3 Item 4', | 164 'Level 3 Item 4', |
165 'Level 3 Item 5', | 165 'Level 3 Item 5', |
166 'Level 3 Item 6', | 166 'Level 3 Item 6', |
167 ), | 167 ], |
168 array( | 168 [ |
169 'Level 3 Item 7', | 169 'Level 3 Item 7', |
170 ), | 170 ], |
171 ), | 171 ], |
172 array( | 172 [ |
173 array( | 173 [ |
174 'Level 3 Item 8', | 174 'Level 3 Item 8', |
175 ), | 175 ], |
176 'Level 2 Item 0', | 176 'Level 2 Item 0', |
177 ), | 177 ], |
178 array( | 178 [ |
179 'Level 2 Item 1', | 179 'Level 2 Item 1', |
180 ), | 180 ], |
181 'Level 1 Item 0', | 181 'Level 1 Item 0', |
182 array( | 182 [ |
183 // Test setMaxString: | 183 // Test setMaxString: |
184 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', | 184 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', |
185 'SHORT', | 185 'SHORT', |
186 ), | 186 ], |
187 ); | 187 ]; |
188 | 188 |
189 $cloner = new VarCloner(); | 189 $cloner = new VarCloner(); |
190 $cloner->setMinDepth(2); | 190 $cloner->setMinDepth(2); |
191 $cloner->setMaxItems(5); | 191 $cloner->setMaxItems(5); |
192 $cloner->setMaxString(20); | 192 $cloner->setMaxString(20); |
379 $this->assertStringMatchesFormat(\PHP_VERSION_ID >= 70200 ? str_replace('"1"', '1', $expected) : $expected, ob_get_clean()); | 379 $this->assertStringMatchesFormat(\PHP_VERSION_ID >= 70200 ? str_replace('"1"', '1', $expected) : $expected, ob_get_clean()); |
380 } | 380 } |
381 | 381 |
382 public function testCaster() | 382 public function testCaster() |
383 { | 383 { |
384 $cloner = new VarCloner(array( | 384 $cloner = new VarCloner([ |
385 '*' => function ($obj, $array) { | 385 '*' => function ($obj, $array) { |
386 return array('foo' => 123); | 386 return ['foo' => 123]; |
387 }, | 387 }, |
388 __CLASS__ => function ($obj, $array) { | 388 __CLASS__ => function ($obj, $array) { |
389 ++$array['foo']; | 389 ++$array['foo']; |
390 | 390 |
391 return $array; | 391 return $array; |
392 }, | 392 }, |
393 )); | 393 ]); |
394 $clone = $cloner->cloneVar($this); | 394 $clone = $cloner->cloneVar($this); |
395 | 395 |
396 $expected = <<<EOTXT | 396 $expected = <<<EOTXT |
397 Symfony\Component\VarDumper\Cloner\Data Object | 397 Symfony\Component\VarDumper\Cloner\Data Object |
398 ( | 398 ( |