CodeExporterTest.php 919 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. }