8c7ef7978616a9ef0691c2a6520229afdc32eba4
[yaffs-website] / vendor / symfony / class-loader / Tests / Psr4ClassLoaderTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\ClassLoader\Tests;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\ClassLoader\Psr4ClassLoader;
16
17 class Psr4ClassLoaderTest extends TestCase
18 {
19     /**
20      * @param string $className
21      * @dataProvider getLoadClassTests
22      */
23     public function testLoadClass($className)
24     {
25         $loader = new Psr4ClassLoader();
26         $loader->addPrefix(
27             'Acme\\DemoLib',
28             __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
29         );
30         $loader->loadClass($className);
31         $this->assertTrue(class_exists($className), sprintf('loadClass() should load %s', $className));
32     }
33
34     /**
35      * @return array
36      */
37     public function getLoadClassTests()
38     {
39         return array(
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'),
44         );
45     }
46
47     /**
48      * @param string $className
49      * @dataProvider getLoadNonexistentClassTests
50      */
51     public function testLoadNonexistentClass($className)
52     {
53         $loader = new Psr4ClassLoader();
54         $loader->addPrefix(
55             'Acme\\DemoLib',
56             __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4'
57         );
58         $loader->loadClass($className);
59         $this->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className));
60     }
61
62     /**
63      * @return array
64      */
65     public function getLoadNonexistentClassTests()
66     {
67         return array(
68             array('Acme\\DemoLib\\I_Do_Not_Exist'),
69             array('UnknownVendor\\SomeLib\\I_Do_Not_Exist'),
70         );
71     }
72 }