Overview

Namespaces

  • None
  • tests
    • unit
      • barebones
        • utilities
      • lib

Classes

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