TYPO3 CMS  TYPO3_8-7
DebuggerUtilityTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
17 
21 class DebuggerUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
22 {
26  public function debuggerRewindsInstancesOfIterator()
27  {
29  $objectStorage = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
30  ->setMethods(['dummy'])
31  ->getMock();
32  for ($i = 0; $i < 5; $i++) {
33  $obj = new \stdClass();
34  $obj->property = $i;
35  $objectStorage->attach($obj);
36  }
37  DebuggerUtility::var_dump($objectStorage, null, 8, true, false, true);
38  $this->assertTrue($objectStorage->valid());
39  }
40 
45  {
46  $generator = (function () {
47  yield 1;
48  yield 2;
49  yield 3;
50  })();
51  $result = DebuggerUtility::var_dump($generator, null, 8, true, false, true);
52  $this->assertContains('Generator', $result);
53  }
54 
59  {
60  $testObject = new \stdClass();
61  $testObject->foo = 'bar';
62  $result = DebuggerUtility::var_dump($testObject, null, 8, true, false, true);
63  $this->assertRegExp('/foo.*bar/', $result);
64  }
65 
70  {
71  $result = DebuggerUtility::var_dump(function (...$args) {
72  }, null, 8, true, false, true);
73  $this->assertContains('function (...$args)', $result);
74  }
75 
80  {
81  $testClass = new \stdClass();
82  $testClass->secretData = 'I like cucumber.';
83  $testClass->notSoSecretData = 'I like burger.';
84 
85  $result = DebuggerUtility::var_dump($testClass, null, 8, true, false, true, null, ['secretData']);
86  self::assertNotContains($testClass->secretData, $result);
87  }
88 
93  {
94  $testClass = new \stdClass();
95  $testClass->data = 'I like burger.';
96 
97  $result = DebuggerUtility::var_dump($testClass, null, 8, true, false, true, [\stdClass::class]);
98  self::assertNotContains($testClass->data, $result);
99  }
100 
104  public function varDumpShowsDumpOfDateTime()
105  {
106  $date = \DateTime::createFromFormat('Y-m-d H:i:s', '2018-11-26 09:27:28', new \DateTimeZone('UTC'));
107 
108  $result = DebuggerUtility::var_dump($date, null, 8, true, false, true, [\stdClass::class]);
109  self::assertContains('2018-11-26T09:27:28', $result);
110  }
111 
116  {
117  $date = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2018-11-26 09:27:28', new \DateTimeZone('UTC'));
118 
119  $result = DebuggerUtility::var_dump($date, null, 8, true, false, true, [\stdClass::class]);
120  self::assertContains('2018-11-26T09:27:28', $result);
121  }
122 }
static var_dump($variable, $title=null, $maxDepth=8, $plainText=false, $ansiColors=true, $return=false, $blacklistedClassNames=null, $blacklistedPropertyNames=null)