You are here

public function ClassCollectionLoaderTest::testCommentStripping in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/class-loader/Tests/ClassCollectionLoaderTest.php \Symfony\Component\ClassLoader\Tests\ClassCollectionLoaderTest::testCommentStripping()

File

vendor/symfony/class-loader/Tests/ClassCollectionLoaderTest.php, line 235

Class

ClassCollectionLoaderTest

Namespace

Symfony\Component\ClassLoader\Tests

Code

public function testCommentStripping() {
  if (is_file($file = sys_get_temp_dir() . '/bar.php')) {
    unlink($file);
  }
  spl_autoload_register($r = function ($class) {
    if (0 === strpos($class, 'Namespaced') || 0 === strpos($class, 'Pearlike_')) {
      require_once __DIR__ . '/Fixtures/' . str_replace(array(
        '\\',
        '_',
      ), '/', $class) . '.php';
    }
  });
  ClassCollectionLoader::load(array(
    'Namespaced\\WithComments',
    'Pearlike_WithComments',
  ), sys_get_temp_dir(), 'bar', false);
  spl_autoload_unregister($r);
  $this
    ->assertEquals(<<<EOF
namespace Namespaced
{
class WithComments
{
public static \$loaded = true;
}
\$string ='string should not be   modified {\$string}';
\$heredoc = (<<<HD


Heredoc should not be   modified {\$string}


HD
);
\$nowdoc =<<<'ND'


Nowdoc should not be   modified {\$string}


ND
;
}
namespace
{
class Pearlike_WithComments
{
public static \$loaded = true;
}
}
EOF
, str_replace("<?php \n", '', file_get_contents($file)));
  unlink($file);
}