Page MenuHomeDevCentral

AutoloaderTest.php
No OneTemporary

AutoloaderTest.php

<?php
declare(strict_types=1);
namespace Keruald\OmniTools\Tests\Registration;
use Keruald\OmniTools\Registration\Autoloader;
use Keruald\OmniTools\Tests\WithData;
use PHPUnit\Framework\TestCase;
use Acme\MockLib\Foo; // a mock class in a mock namespace to test autoload.
class AutoloaderTest extends TestCase {
use WithData;
public function testRegisterPSR4 () : void {
$class = Foo::class;
$this->assertFalse(
class_exists($class),
"Please reconfigure the test suite not to include the $class class."
);
Autoloader::registerPSR4("Acme\\MockLib\\", $this->getDataPath("MockLib"));
$this->assertTrue(class_exists($class));
$this->assertFalse(class_exists("NotExisting"));
}
public function testGetLibraryPath () : void {
$this->assertStringStartsWith(
dirname(Autoloader::getLibraryPath()), // lib is in <root>/src
__DIR__ // we are in <root>/tests/…
);
}
public function testRegister () : void {
$count = count(spl_autoload_functions());
Autoloader::selfRegister();
$this->assertEquals(++$count, count(spl_autoload_functions()));
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Feb 28, 22:47 (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2435951
Default Alt Text
AutoloaderTest.php (1 KB)

Event Timeline