CodeExporterTest.php 931 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of sebastian/global-state.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace SebastianBergmann\GlobalState;
  11. use PHPUnit\Framework\TestCase;
  12. /**
  13. * @covers \SebastianBergmann\GlobalState\CodeExporter
  14. */
  15. final class CodeExporterTest extends TestCase
  16. {
  17. /**
  18. * @runInSeparateProcess
  19. */
  20. public function testCanExportGlobalVariablesToCode(): void
  21. {
  22. $GLOBALS = ['foo' => 'bar'];
  23. $snapshot = new Snapshot(null, true, false, false, false, false, false, false, false, false);
  24. $exporter = new CodeExporter;
  25. $this->assertEquals(
  26. '$GLOBALS = [];' . \PHP_EOL . '$GLOBALS[\'foo\'] = \'bar\';' . \PHP_EOL,
  27. $exporter->globalVariables($snapshot)
  28. );
  29. }
  30. }