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;
20 class Psr4ClassLoaderTest extends TestCase
23 * @param string $className
24 * @dataProvider getLoadClassTests
26 public function testLoadClass($className)
28 $loader = new Psr4ClassLoader();
31 __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
33 $loader->loadClass($className);
34 $this->assertTrue(class_exists($className), sprintf('loadClass() should load %s', $className));
40 public function getLoadClassTests()
43 array('Acme\\DemoLib\\Foo'),
44 array('Acme\\DemoLib\\Class_With_Underscores'),
45 array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo'),
46 array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Class_With_Underscores'),
51 * @param string $className
52 * @dataProvider getLoadNonexistentClassTests
54 public function testLoadNonexistentClass($className)
56 $loader = new Psr4ClassLoader();
59 __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
61 $loader->loadClass($className);
62 $this->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className));
68 public function getLoadNonexistentClassTests()
71 array('Acme\\DemoLib\\I_Do_Not_Exist'),
72 array('UnknownVendor\\SomeLib\\I_Do_Not_Exist'),