4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\ClassLoader\Tests;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\ClassLoader\Psr4ClassLoader;
17 class Psr4ClassLoaderTest extends TestCase
20 * @param string $className
21 * @dataProvider getLoadClassTests
23 public function testLoadClass($className)
25 $loader = new Psr4ClassLoader();
28 __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
30 $loader->loadClass($className);
31 $this->assertTrue(class_exists($className), sprintf('loadClass() should load %s', $className));
37 public function getLoadClassTests()
40 array('Acme\\DemoLib\\Foo'),
41 array('Acme\\DemoLib\\Class_With_Underscores'),
42 array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo'),
43 array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Class_With_Underscores'),
48 * @param string $className
49 * @dataProvider getLoadNonexistentClassTests
51 public function testLoadNonexistentClass($className)
53 $loader = new Psr4ClassLoader();
56 __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
58 $loader->loadClass($className);
59 $this->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className));
65 public function getLoadNonexistentClassTests()
68 array('Acme\\DemoLib\\I_Do_Not_Exist'),
69 array('UnknownVendor\\SomeLib\\I_Do_Not_Exist'),