2011-11-27 10:49:42 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Tests for the {@link SS_ClassManifest} class.
|
|
|
|
*
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class ClassLoaderTest extends SapphireTest {
|
|
|
|
|
|
|
|
protected $base;
|
|
|
|
protected $manifest;
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function setUp() {
|
2011-11-27 10:49:42 +01:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->baseManifest1 = dirname(__FILE__) . '/fixtures/classmanifest';
|
|
|
|
$this->baseManifest2 = dirname(__FILE__) . '/fixtures/classmanifest_other';
|
|
|
|
$this->testManifest1 = new SS_ClassManifest($this->baseManifest1, false, true, false);
|
|
|
|
$this->testManifest2 = new SS_ClassManifest($this->baseManifest2, false, true, false);
|
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testExclusive() {
|
2011-11-27 10:49:42 +01:00
|
|
|
$loader = new SS_ClassLoader();
|
|
|
|
|
|
|
|
$loader->pushManifest($this->testManifest1);
|
|
|
|
$this->assertTrue((bool)$loader->getItemPath('ClassA'));
|
|
|
|
$this->assertFalse((bool)$loader->getItemPath('OtherClassA'));
|
|
|
|
|
|
|
|
$loader->pushManifest($this->testManifest2);
|
|
|
|
$this->assertFalse((bool)$loader->getItemPath('ClassA'));
|
|
|
|
$this->assertTrue((bool)$loader->getItemPath('OtherClassA'));
|
|
|
|
|
|
|
|
$loader->popManifest();
|
|
|
|
$loader->pushManifest($this->testManifest2, false);
|
|
|
|
$this->assertTrue((bool)$loader->getItemPath('ClassA'));
|
|
|
|
$this->assertTrue((bool)$loader->getItemPath('OtherClassA'));
|
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testGetItemPath() {
|
2011-11-27 10:49:42 +01:00
|
|
|
$loader = new SS_ClassLoader();
|
|
|
|
|
|
|
|
$loader->pushManifest($this->testManifest1);
|
|
|
|
$this->assertEquals(
|
2012-09-27 03:41:28 +02:00
|
|
|
realpath($this->baseManifest1 . '/module/classes/ClassA.php'),
|
|
|
|
realpath($loader->getItemPath('ClassA'))
|
2011-11-27 10:49:42 +01:00
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
false,
|
|
|
|
$loader->getItemPath('UnknownClass')
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
false,
|
|
|
|
$loader->getItemPath('OtherClassA')
|
|
|
|
);
|
|
|
|
|
|
|
|
$loader->pushManifest($this->testManifest2);
|
|
|
|
$this->assertEquals(
|
|
|
|
false,
|
|
|
|
$loader->getItemPath('ClassA')
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
false,
|
|
|
|
$loader->getItemPath('UnknownClass')
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
2012-09-27 03:41:28 +02:00
|
|
|
realpath($this->baseManifest2 . '/module/classes/OtherClassA.php'),
|
|
|
|
realpath($loader->getItemPath('OtherClassA'))
|
2011-11-27 10:49:42 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|