Extends
lithium\test\Unit
Tests that non-prefixed (poorly named or structured) libraries can still be added.
Returns
voidSource
public function testAddNonPrefixedLibrary() {
$tmpDir = realpath(Libraries::get(true, 'resources') . '/tmp');
$this->skipIf(!is_writable($tmpDir), "Can't write to resources directory.");
$fakeDir = $tmpDir . '/fake';
$fake = "<?php class Fake {} ?>";
$fakeFilename = $fakeDir . '/fake.php';
mkdir($fakeDir);
file_put_contents($fakeFilename, $fake);
Libraries::add('bad', array(
'prefix' => false,
'path' => $fakeDir,
'transform' => function($class, $config) { return ''; }
));
Libraries::add('fake', array(
'path' => $fakeDir,
'includePath' => true,
'prefix' => false,
'transform' => function($class, $config) {
return $config['path'] . '/' . Inflector::underscore($class) . '.php';
}
));
$this->assertFalse(class_exists('Fake', false));
$this->assertTrue(class_exists('Fake'));
unlink($fakeFilename);
rmdir($fakeDir);
Libraries::remove('fake');
}