public function ClassCollectionLoaderTest::testCommentStripping

File

drupal/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php, line 203

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 shoult 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);
}