No Description

CodeExporterTest.php 919B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  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. declare(strict_types=1);
  11. namespace SebastianBergmann\GlobalState;
  12. use PHPUnit\Framework\TestCase;
  13. /**
  14. * @covers \SebastianBergmann\GlobalState\CodeExporter
  15. */
  16. class CodeExporterTest extends TestCase
  17. {
  18. /**
  19. * @runInSeparateProcess
  20. */
  21. public function testCanExportGlobalVariablesToCode()
  22. {
  23. $GLOBALS = ['foo' => 'bar'];
  24. $snapshot = new Snapshot(null, true, false, false, false, false, false, false, false, false);
  25. $exporter = new CodeExporter;
  26. $this->assertEquals(
  27. '$GLOBALS = [];' . PHP_EOL . '$GLOBALS[\'foo\'] = \'bar\';' . PHP_EOL,
  28. $exporter->globalVariables($snapshot)
  29. );
  30. }
  31. }