‪TYPO3CMS  10.4
DebuggerUtilityTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪DebuggerUtilityTest extends UnitTestCase
26 {
31  {
33  $objectStorage = $this->getMockBuilder(ObjectStorage::class)
34  ->setMethods(['dummy'])
35  ->getMock();
36  for ($i = 0; $i < 5; $i++) {
37  $obj = new \stdClass();
38  $obj->property = $i;
39  $objectStorage->attach($obj);
40  }
41  ‪DebuggerUtility::var_dump($objectStorage, null, 8, true, false, true);
42  self::assertTrue($objectStorage->valid());
43  }
44 
49  {
50  $generator = (function () {
51  yield 1;
52  yield 2;
53  yield 3;
54  })();
55  $result = ‪DebuggerUtility::var_dump($generator, null, 8, true, false, true);
56  self::assertStringContainsString('Generator', $result);
57  }
58 
63  {
64  $testObject = new \stdClass();
65  $testObject->foo = 'bar';
66  $result = ‪DebuggerUtility::var_dump($testObject, null, 8, true, false, true);
67  // @todo remove condition and else branch as soon as phpunit v8 goes out of support
68  if (method_exists($this, 'assertMatchesRegularExpression')) {
69  self::assertMatchesRegularExpression('/foo.*bar/', $result);
70  } else {
71  self::assertRegExp('/foo.*bar/', $result);
72  }
73  }
74 
79  {
80  $result = ‪DebuggerUtility::var_dump(function (...‪$args) {
81  }, null, 8, true, false, true);
82  self::assertStringContainsString('function (...$args)', $result);
83  }
84 
89  {
90  $testClass = new \stdClass();
91  $testClass->secretData = 'I like cucumber.';
92  $testClass->notSoSecretData = 'I like burger.';
93 
94  $result = ‪DebuggerUtility::var_dump($testClass, null, 8, true, false, true, null, ['secretData']);
95  self::assertStringNotContainsString($testClass->secretData, $result);
96  }
97 
102  {
103  $testClass = new \stdClass();
104  $testClass->data = 'I like burger.';
105 
106  $result = ‪DebuggerUtility::var_dump($testClass, null, 8, true, false, true, [\stdClass::class]);
107  self::assertStringNotContainsString($testClass->data, $result);
108  }
109 
114  {
115  $date = \DateTime::createFromFormat('Y-m-d H:i:s', '2018-11-26 09:27:28', new \DateTimeZone('UTC'));
116 
117  $result = ‪DebuggerUtility::var_dump($date, null, 8, true, false, true, [\stdClass::class]);
118  self::assertStringContainsString('2018-11-26T09:27:28', $result);
119  }
120 
125  {
126  $date = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2018-11-26 09:27:28', new \DateTimeZone('UTC'));
127 
128  $result = ‪DebuggerUtility::var_dump($date, null, 8, true, false, true, [\stdClass::class]);
129  self::assertStringContainsString('2018-11-26T09:27:28', $result);
130  }
131 }
‪TYPO3\CMS\Extbase\Tests\Unit\Utility\DebuggerUtilityTest\varDumpShowsDumpOfDateTime
‪varDumpShowsDumpOfDateTime()
Definition: DebuggerUtilityTest.php:113
‪TYPO3\CMS\Extbase\Tests\Unit\Utility\DebuggerUtilityTest\varDumpShowsPropertiesOfStdClassObjects
‪varDumpShowsPropertiesOfStdClassObjects()
Definition: DebuggerUtilityTest.php:62
‪TYPO3\CMS\Extbase\Tests\Unit\Utility\DebuggerUtilityTest\varDumpShowsDumpOfDateTimeImmutable
‪varDumpShowsDumpOfDateTimeImmutable()
Definition: DebuggerUtilityTest.php:124
‪TYPO3\CMS\Extbase\Tests\Unit\Utility\DebuggerUtilityTest\debuggerRewindsInstancesOfIterator
‪debuggerRewindsInstancesOfIterator()
Definition: DebuggerUtilityTest.php:30
‪TYPO3\CMS\Extbase\Tests\Unit\Utility\DebuggerUtilityTest\varDumpRespectsBlacklistedClasses
‪varDumpRespectsBlacklistedClasses()
Definition: DebuggerUtilityTest.php:101
‪TYPO3\CMS\Extbase\Tests\Unit\Utility\DebuggerUtilityTest\varDumpRespectsBlacklistedProperties
‪varDumpRespectsBlacklistedProperties()
Definition: DebuggerUtilityTest.php:88
‪TYPO3\CMS\Extbase\Tests\Unit\Utility\DebuggerUtilityTest
Definition: DebuggerUtilityTest.php:26
‪TYPO3\CMS\Extbase\Persistence\ObjectStorage
Definition: ObjectStorage.php:28
‪TYPO3\CMS\Extbase\Utility\DebuggerUtility\var_dump
‪static string var_dump( $variable, string $title=null, int $maxDepth=8, bool $plainText=false, bool $ansiColors=true, bool $return=false, array $blacklistedClassNames=null, array $blacklistedPropertyNames=null)
Definition: DebuggerUtility.php:518
‪TYPO3\CMS\Extbase\Tests\Unit\Utility\DebuggerUtilityTest\varDumpHandlesVariadicArguments
‪varDumpHandlesVariadicArguments()
Definition: DebuggerUtilityTest.php:78
‪TYPO3\CMS\Extbase\Tests\Unit\Utility
Definition: DebuggerUtilityTest.php:16
‪TYPO3\CMS\Extbase\Utility\DebuggerUtility
Definition: DebuggerUtility.php:41
‪$args
‪$args
Definition: validateRstFiles.php:214
‪TYPO3\CMS\Extbase\Tests\Unit\Utility\DebuggerUtilityTest\debuggerDoesNotRewindInstancesOfGenerator
‪debuggerDoesNotRewindInstancesOfGenerator()
Definition: DebuggerUtilityTest.php:48