diff vendor/symfony/var-dumper/Tests/Cloner/VarClonerTest.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 129ea1e6d783
line wrap: on
line diff
--- a/vendor/symfony/var-dumper/Tests/Cloner/VarClonerTest.php	Fri Feb 23 15:51:18 2018 +0000
+++ b/vendor/symfony/var-dumper/Tests/Cloner/VarClonerTest.php	Fri Feb 23 15:52:07 2018 +0000
@@ -146,6 +146,174 @@
         $this->assertStringMatchesFormat($expected, print_r($clone, true));
     }
 
+    public function testLimits()
+    {
+        // Level 0:
+        $data = array(
+            // Level 1:
+            array(
+                // Level 2:
+                array(
+                    // Level 3:
+                    'Level 3 Item 0',
+                    'Level 3 Item 1',
+                    'Level 3 Item 2',
+                    'Level 3 Item 3',
+                ),
+                array(
+                    'Level 3 Item 4',
+                    'Level 3 Item 5',
+                    'Level 3 Item 6',
+                ),
+                array(
+                    'Level 3 Item 7',
+                ),
+            ),
+            array(
+                array(
+                    'Level 3 Item 8',
+                ),
+                'Level 2 Item 0',
+            ),
+            array(
+                'Level 2 Item 1',
+            ),
+            'Level 1 Item 0',
+            array(
+                // Test setMaxString:
+                'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+                'SHORT',
+            ),
+        );
+
+        $cloner = new VarCloner();
+        $cloner->setMinDepth(2);
+        $cloner->setMaxItems(5);
+        $cloner->setMaxString(20);
+        $clone = $cloner->cloneVar($data);
+
+        $expected = <<<EOTXT
+Symfony\Component\VarDumper\Cloner\Data Object
+(
+    [data:Symfony\Component\VarDumper\Cloner\Data:private] => Array
+        (
+            [0] => Array
+                (
+                    [0] => Array
+                        (
+                            [2] => 1
+                        )
+
+                )
+
+            [1] => Array
+                (
+                    [0] => Array
+                        (
+                            [2] => 2
+                        )
+
+                    [1] => Array
+                        (
+                            [2] => 3
+                        )
+
+                    [2] => Array
+                        (
+                            [2] => 4
+                        )
+
+                    [3] => Level 1 Item 0
+                    [4] => Array
+                        (
+                            [2] => 5
+                        )
+
+                )
+
+            [2] => Array
+                (
+                    [0] => Array
+                        (
+                            [2] => 6
+                        )
+
+                    [1] => Array
+                        (
+                            [0] => 2
+                            [2] => 7
+                        )
+
+                    [2] => Array
+                        (
+                            [0] => 1
+                            [2] => 0
+                        )
+
+                )
+
+            [3] => Array
+                (
+                    [0] => Array
+                        (
+                            [0] => 1
+                            [2] => 0
+                        )
+
+                    [1] => Level 2 Item 0
+                )
+
+            [4] => Array
+                (
+                    [0] => Level 2 Item 1
+                )
+
+            [5] => Array
+                (
+                    [0] => Symfony\Component\VarDumper\Cloner\Stub Object
+                        (
+                            [type] => 2
+                            [class] => 2
+                            [value] => ABCDEFGHIJKLMNOPQRST
+                            [cut] => 6
+                            [handle] => 0
+                            [refCount] => 0
+                            [position] => 0
+                            [attr] => Array
+                                (
+                                )
+
+                        )
+
+                    [1] => SHORT
+                )
+
+            [6] => Array
+                (
+                    [0] => Level 3 Item 0
+                    [1] => Level 3 Item 1
+                    [2] => Level 3 Item 2
+                    [3] => Level 3 Item 3
+                )
+
+            [7] => Array
+                (
+                    [0] => Level 3 Item 4
+                )
+
+        )
+
+    [position:Symfony\Component\VarDumper\Cloner\Data:private] => 0
+    [key:Symfony\Component\VarDumper\Cloner\Data:private] => 0
+    [maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20
+    [maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1
+    [useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
+)
+
+EOTXT;
+        $this->assertStringMatchesFormat($expected, print_r($clone, true));
+    }
+
     public function testJsonCast()
     {
         if (2 == ini_get('xdebug.overload_var_dump')) {