You are here

class Psr4ClassLoaderTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/class-loader/Tests/Psr4ClassLoaderTest.php \Symfony\Component\ClassLoader\Tests\Psr4ClassLoaderTest

Hierarchy

  • class \Symfony\Component\ClassLoader\Tests\Psr4ClassLoaderTest extends \Symfony\Component\ClassLoader\Tests\PHPUnit_Framework_TestCase

Expanded class hierarchy of Psr4ClassLoaderTest

File

vendor/symfony/class-loader/Tests/Psr4ClassLoaderTest.php, line 16

Namespace

Symfony\Component\ClassLoader\Tests
View source
class Psr4ClassLoaderTest extends \PHPUnit_Framework_TestCase {

  /**
   * @param string $className
   * @dataProvider getLoadClassTests
   */
  public function testLoadClass($className) {
    $loader = new Psr4ClassLoader();
    $loader
      ->addPrefix('Acme\\DemoLib', __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'psr-4');
    $loader
      ->loadClass($className);
    $this
      ->assertTrue(class_exists($className), sprintf('loadClass() should load %s', $className));
  }

  /**
   * @return array
   */
  public function getLoadClassTests() {
    return array(
      array(
        'Acme\\DemoLib\\Foo',
      ),
      array(
        'Acme\\DemoLib\\Class_With_Underscores',
      ),
      array(
        'Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo',
      ),
      array(
        'Acme\\DemoLib\\Lets\\Go\\Deeper\\Class_With_Underscores',
      ),
    );
  }

  /**
   * @param string $className
   * @dataProvider getLoadNonexistentClassTests
   */
  public function testLoadNonexistentClass($className) {
    $loader = new Psr4ClassLoader();
    $loader
      ->addPrefix('Acme\\DemoLib', __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'psr-4');
    $loader
      ->loadClass($className);
    $this
      ->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className));
  }

  /**
   * @return array
   */
  public function getLoadNonexistentClassTests() {
    return array(
      array(
        'Acme\\DemoLib\\I_Do_Not_Exist',
      ),
      array(
        'UnknownVendor\\SomeLib\\I_Do_Not_Exist',
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Psr4ClassLoaderTest::getLoadClassTests public function
Psr4ClassLoaderTest::getLoadNonexistentClassTests public function
Psr4ClassLoaderTest::testLoadClass public function @dataProvider getLoadClassTests
Psr4ClassLoaderTest::testLoadNonexistentClass public function @dataProvider getLoadNonexistentClassTests