1
0
mirror of https://github.com/danog/class-finder.git synced 2025-01-22 05:41:37 +01:00
class-finder/test/app1/src/FilesTest.php

80 lines
2.7 KiB
PHP
Raw Normal View History

2018-09-29 13:27:19 -05:00
<?php
namespace TestApp1;
require_once __DIR__ . '/../vendor/autoload.php';
use HaydenPierce\ClassFinder\ClassFinder;
class FilesTest extends \PHPUnit_Framework_TestCase
{
public function setup()
{
// Reset ClassFinder back to normal.
ClassFinder::setAppRoot(null);
}
/**
* @dataProvider classFinderDataProvider
*/
public function testClassFinder($namespace, $expected, $message)
{
try {
ClassFinder::enableExperimentalFilesSupport();
2018-09-29 13:27:19 -05:00
$classes = ClassFinder::getClassesInNamespace($namespace);
} catch (\Exception $e) {
$this->assertFalse(true, 'An exception occurred: ' . $e->getMessage());
$classes = array();
}
$this->assertEquals($expected, $classes, $message);
}
2018-09-29 13:27:19 -05:00
public function classFinderDataProvider()
{
return array(
array(
'TestApp1\FilesClasses',
array(
'TestApp1\FilesClasses\Bam',
'TestApp1\FilesClasses\Wam',
'TestApp1\FilesClasses\Fam',
'TestApp1\FilesClasses\Cam',
'TestApp1\FilesClasses\Lam',
),
'ClassFinder should be able to find 1st party classes included from `files` listed in composer.json.'
2018-10-21 09:14:41 -05:00
),
array(
'TestApp1\FilesClasses\MoreClasses',
array(
'TestApp1\FilesClasses\MoreClasses\Pham',
'TestApp1\FilesClasses\MoreClasses\Slam'
),
'ClassFinder should be able to find 1st party classes included from `files` listed in composer.json.'
),
array(
'HaydenPierce\Files',
array(
'HaydenPierce\Files\z',
'HaydenPierce\Files\z2',
'HaydenPierce\Files\a',
'HaydenPierce\Files\a2',
'HaydenPierce\Files\b',
'HaydenPierce\Files\b2'
),
'ClassFinder should be able to find 3rd party classes included from `files` listed in composer.json of those projects.'
2018-09-29 13:27:19 -05:00
)
);
}
/**
* @expectedException HaydenPierce\ClassFinder\Exception\ClassFinderException
* @expectedExceptionMessageRegExp /Unknown namespace 'TestApp1\\FilesClasses'\./
*/
public function testFilesSupportRequiresEnabling()
{
ClassFinder::disableExperimentalFilesSupport(); // Disabling FilesSupport should cause no files to be found.
$classes = ClassFinder::getClassesInNamespace('TestApp1\FilesClasses');
}
2018-09-29 13:27:19 -05:00
}