1: <?php
2: require_once(__DIR__."/../../../../TestCase.php");
3:
4: class PathManagerTest extends TestCase
5: {
6: public function testCreatePathManager()
7: {
8: $config = $config = new Azalea\Core\Config\Repository(array());
9: $path = new Azalea\Shared\System\Path\PathManager($config, __DIR__."/");
10: $this->assertTrue(true);
11: }
12:
13: public function testBasePath()
14: {
15: $config = $config = new Azalea\Core\Config\Repository(array());
16: $path = new Azalea\Shared\System\Path\PathManager($config, "/path/to/base/");
17: $this->assertEquals("/path/to/base/", $path->getBase());
18:
19: $path = new Azalea\Shared\System\Path\PathManager($config, "/path/to/base");
20: $this->assertEquals("/path/to/base/", $path->getBase());
21: }
22:
23: public function testGet()
24: {
25: $config = new Azalea\Core\Config\ConfigManager(
26: new Azalea\Core\Config\RepositoryMemoryLoader(array(
27: "path" => array(
28: "foo" => "bar",
29: "bar" => "/path/to/foo/",
30: "baz" => "/path/to/foo"
31: )
32: ))
33: );
34: $path = new Azalea\Shared\System\Path\PathManager($config, __DIR__, false);
35:
36: $this->assertEquals(__DIR__."/bar/", $path->get("path.foo"));
37: $this->assertEquals("/path/to/foo/", $path->get("path.bar"));
38: $this->assertEquals("/path/to/foo/", $path->get("path.baz"));
39: }
40:
41: public function testMakePath()
42: {
43: $config = $config = new Azalea\Core\Config\Repository(array());
44: $path = new Azalea\Shared\System\Path\PathManager($config, "/path/to/base/");
45:
46: $this->assertEquals("/path/to/base/", $path->makePath());
47: $this->assertEquals("/path/to/base/test_file.php", $path->makePath("test_file.php"));
48: }
49:
50: public function testGetTemp()
51: {
52: $config = new Azalea\Core\Config\ConfigManager(
53: new Azalea\Core\Config\RepositoryMemoryLoader(array(
54: "path" => array(
55: "temp" => "tmp"
56: )
57: ))
58: );
59: $path = new Azalea\Shared\System\Path\PathManager($config, __DIR__, false);
60:
61: $this->assertEquals(__DIR__."/tmp/", $path->getTemp());
62: $this->assertEquals(__DIR__."/tmp/abc.pdf", $path->getTemp("abc.pdf"));
63: }
64:
65: public function testGetScans()
66: {
67: $config = new Azalea\Core\Config\ConfigManager(
68: new Azalea\Core\Config\RepositoryMemoryLoader(array(
69: "path" => array(
70: "scan" => "scans"
71: )
72: ))
73: );
74: $path = new Azalea\Shared\System\Path\PathManager($config, __DIR__, false);
75:
76: $this->assertEquals(__DIR__."/scans/", $path->getScan());
77: $this->assertEquals(__DIR__."/scans/abc.pdf", $path->getScan("abc.pdf"));
78: }
79: }
80:
81: ?>