bourse stock
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.9 KiB

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ClassLoader\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\ClassLoader\Psr4ClassLoader;
/**
* @group legacy
*/
class Psr4ClassLoaderTest extends 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 [
['Acme\\DemoLib\\Foo'],
['Acme\\DemoLib\\Class_With_Underscores'],
['Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo'],
['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 [
['Acme\\DemoLib\\I_Do_Not_Exist'],
['UnknownVendor\\SomeLib\\I_Do_Not_Exist'],
];
}
}