1: <?php
2: require_once(__DIR__."/../../../../TestCase.php");
3:
4: class UrlManagerTest extends TestCase
5: {
6: public function setUp()
7: {
8: putenv("BRANCH_ROOT=");
9: }
10:
11: public function testCreateUrlManager()
12: {
13: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
14: $config = new Azalea\Core\Config\ConfigManager(
15: new Azalea\Core\Config\RepositoryMemoryLoader(array())
16: );
17: $request = Symfony\Component\HttpFoundation\Request::create(
18: 'https://branches.azaleahealth.com/testing/',
19: 'GET',
20: array()
21: );
22:
23: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
24: $this->assertTrue(true);
25: }
26:
27: public function testGetBase()
28: {
29: $config = new Azalea\Core\Config\ConfigManager(
30: new Azalea\Core\Config\RepositoryMemoryLoader(array())
31: );
32:
33:
34: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
35: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01d.azaleahealth.com/testing/', 'GET', array());
36: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
37: $this->assertEquals("https://adev01d.azaleahealth.com/testing/", $url->getBase());
38:
39:
40: putenv("BRANCH_ROOT=testing/hotfix");
41: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
42: $this->assertEquals("https://adev01d.azaleahealth.com/testing/hotfix/", $url->getBase());
43: putenv("BRANCH_ROOT=");
44:
45:
46: $env = new Azalea\Core\Environment\Environment("development", "adev01");
47: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01.azaleahealth.com/testing/', 'GET', array());
48: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
49: $this->assertEquals("https://adev01.azaleahealth.com/testing/", $url->getBase());
50:
51:
52: putenv("BRANCH_ROOT=testing/hotfix");
53: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
54: $this->assertEquals("https://adev01.azaleahealth.com/testing/hotfix/", $url->getBase());
55: putenv("BRANCH_ROOT=");
56:
57:
58: $request = Symfony\Component\HttpFoundation\Request::create(
59: 'https://www.azaleahealth.com/',
60: 'GET',
61: array()
62: );
63:
64: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
65: $this->assertEquals("https://www.azaleahealth.com/", $url->getBase());
66: }
67:
68: public function testGetBaseCommandLine()
69: {
70: $config = new Azalea\Core\Config\ConfigManager(
71: new Azalea\Core\Config\RepositoryMemoryLoader(array())
72: );
73:
74:
75: $request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
76:
77:
78: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
79: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
80: $this->assertEquals("https://adev01d.azaleahealth.com/", $url->getBase());
81:
82: $env = new Azalea\Core\Environment\Environment("development", "adev01");
83: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
84: $this->assertEquals("https://adev01.azaleahealth.com/", $url->getBase());
85:
86:
87: $env = new Azalea\Core\Environment\Environment("production", "aws01");
88: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
89: $this->assertEquals("https://www.azaleahealth.com/", $url->getBase());
90:
91:
92: $env = new Azalea\Core\Environment\Environment("fs", "fs01");
93: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
94: $this->assertEquals("https://fs01.azaleahealth.com/", $url->getBase());
95:
96:
97: $env = new Azalea\Core\Environment\Environment("afs", "afs01");
98: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
99: $this->assertEquals("https://www.azaleahealth.com/", $url->getBase());
100: }
101:
102: public function testGetBranchName()
103: {
104: $config = new Azalea\Core\Config\ConfigManager(
105: new Azalea\Core\Config\RepositoryMemoryLoader(array())
106: );
107:
108:
109: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
110: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01d.azaleahealth.com/testing/', 'GET', array());
111: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
112: $this->assertEquals("testing", $url->getBranchName());
113:
114:
115: putenv("BRANCH_ROOT=testing/hotfix");
116: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
117: $this->assertEquals("testing/hotfix", $url->getBranchName());
118: putenv("BRANCH_ROOT=");
119:
120:
121: $env = new Azalea\Core\Environment\Environment("development", "adev01");
122: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01.azaleahealth.com/testing/', 'GET', array());
123: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
124: $this->assertEquals("testing", $url->getBranchName());
125:
126:
127: putenv("BRANCH_ROOT=testing/hotfix");
128: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
129: $this->assertEquals("testing/hotfix", $url->getBranchName());
130: putenv("BRANCH_ROOT=");
131: }
132:
133: public function testMakeUrl()
134: {
135: $config = new Azalea\Core\Config\ConfigManager(
136: new Azalea\Core\Config\RepositoryMemoryLoader(array())
137: );
138:
139:
140: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
141: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01d.azaleahealth.com/testing/', 'GET', array());
142: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
143: $this->assertEquals("https://adev01d.azaleahealth.com/testing/selenium.html", $url->makeUrl("selenium.html"));
144:
145:
146: $env = new Azalea\Core\Environment\Environment("development", "adev01");
147: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01.azaleahealth.com/testing/', 'GET', array());
148: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
149: $this->assertEquals("https://adev01.azaleahealth.com/testing/selenium.html", $url->makeUrl("selenium.html"));
150:
151:
152: $request = Symfony\Component\HttpFoundation\Request::create(
153: 'https://www.azaleahealth.com/',
154: 'GET',
155: array()
156: );
157:
158: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
159: $this->assertEquals("https://www.azaleahealth.com/selenium.html", $url->makeUrl("selenium.html"));
160: }
161:
162: public function testMakeUrlCommandLine()
163: {
164: $config = new Azalea\Core\Config\ConfigManager(
165: new Azalea\Core\Config\RepositoryMemoryLoader(array())
166: );
167:
168:
169: $request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
170:
171:
172: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
173: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
174: $this->assertEquals("https://adev01d.azaleahealth.com/selenium.html", $url->makeUrl("selenium.html"));
175:
176: $env = new Azalea\Core\Environment\Environment("development", "adev01");
177: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
178: $this->assertEquals("https://adev01.azaleahealth.com/selenium.html", $url->makeUrl("selenium.html"));
179:
180:
181: $env = new Azalea\Core\Environment\Environment("production", "aws01");
182: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
183: $this->assertEquals("https://www.azaleahealth.com/selenium.html", $url->makeUrl("selenium.html"));
184:
185:
186: $env = new Azalea\Core\Environment\Environment("fs", "fs01");
187: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
188: $this->assertEquals("https://fs01.azaleahealth.com/selenium.html", $url->makeUrl("selenium.html"));
189:
190:
191: $env = new Azalea\Core\Environment\Environment("afs", "afs01");
192: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
193: $this->assertEquals("https://www.azaleahealth.com/selenium.html", $url->makeUrl("selenium.html"));
194: }
195:
196: public function testGetHome()
197: {
198: $config = new Azalea\Core\Config\ConfigManager(
199: new Azalea\Core\Config\RepositoryMemoryLoader(array())
200: );
201:
202:
203: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
204: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01d.azaleahealth.com/testing/', 'GET', array());
205: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
206: $this->assertEquals("http://adev01d.azaleahealth.com/testing/", $url->getHome());
207:
208:
209: $env = new Azalea\Core\Environment\Environment("development", "adev01");
210: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01.azaleahealth.com/testing/', 'GET', array());
211: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
212: $this->assertEquals("http://adev01.azaleahealth.com/testing/", $url->getHome());
213:
214:
215: $request = Symfony\Component\HttpFoundation\Request::create(
216: 'https://www.azaleahealth.com/',
217: 'GET',
218: array()
219: );
220:
221: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
222: $this->assertEquals("http://www.azaleahealth.com/", $url->getHome());
223: }
224:
225: public function testGetHomeCommandLine()
226: {
227: $config = new Azalea\Core\Config\ConfigManager(
228: new Azalea\Core\Config\RepositoryMemoryLoader(array())
229: );
230:
231:
232: $request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
233:
234:
235: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
236: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
237: $this->assertEquals("http://adev01d.azaleahealth.com/", $url->getHome());
238:
239: $env = new Azalea\Core\Environment\Environment("development", "adev01");
240: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
241: $this->assertEquals("http://adev01.azaleahealth.com/", $url->getHome());
242:
243:
244: $env = new Azalea\Core\Environment\Environment("production", "aws01");
245: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
246: $this->assertEquals("http://www.azaleahealth.com/", $url->getHome());
247:
248:
249: $env = new Azalea\Core\Environment\Environment("fs", "fs01");
250: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
251: $this->assertEquals("http://fs01.azaleahealth.com/", $url->getHome());
252:
253:
254: $env = new Azalea\Core\Environment\Environment("afs", "afs01");
255: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
256: $this->assertEquals("http://www.azaleahealth.com/", $url->getHome());
257: }
258:
259: public function testGetTemp()
260: {
261: $config = new Azalea\Core\Config\ConfigManager(
262: new Azalea\Core\Config\RepositoryMemoryLoader(array())
263: );
264:
265:
266: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
267: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01d.azaleahealth.com/testing/', 'GET', array());
268: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
269: $this->assertEquals("https://adev01d.azaleahealth.com/tmp/", $url->getTemp());
270: $this->assertEquals("https://adev01d.azaleahealth.com/tmp/abc.pdf", $url->getTemp("abc.pdf"));
271:
272:
273: $env = new Azalea\Core\Environment\Environment("development", "adev01");
274: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01.azaleahealth.com/testing/', 'GET', array());
275: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
276: $this->assertEquals("https://adev01.azaleahealth.com/tmp/", $url->getTemp());
277: $this->assertEquals("https://adev01.azaleahealth.com/tmp/abc.pdf", $url->getTemp("abc.pdf"));
278:
279:
280: $env = new Azalea\Core\Environment\Environment("production", "aws01");
281: $config = new Azalea\Core\Config\ConfigManager(
282: new Azalea\Core\Config\RepositoryMemoryLoader(array(
283: "url" => array(
284: "files" => array(
285: "com" => "https://www.azaleahealth.com/",
286: "net" => "https://www.azaleahealth.net/"
287: )
288: )
289: ))
290: );
291: $request = Symfony\Component\HttpFoundation\Request::create(
292: 'https://www.azaleahealth.com/',
293: 'GET',
294: array()
295: );
296:
297: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
298: $this->assertEquals("https://www.azaleahealth.com/awa/tmp/", $url->getTemp());
299: $this->assertEquals("https://www.azaleahealth.com/awa/tmp/abc.pdf", $url->getTemp("abc.pdf"));
300:
301:
302: $request = Symfony\Component\HttpFoundation\Request::create(
303: 'https://www.azaleahealth.net/',
304: 'GET',
305: array()
306: );
307:
308: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
309: $this->assertEquals("https://www.azaleahealth.net/awa/tmp/", $url->getTemp());
310: $this->assertEquals("https://www.azaleahealth.net/awa/tmp/abc.pdf", $url->getTemp("abc.pdf"));
311: }
312:
313: public function testGetScan()
314: {
315: $config = new Azalea\Core\Config\ConfigManager(
316: new Azalea\Core\Config\RepositoryMemoryLoader(array())
317: );
318:
319:
320: $env = new Azalea\Core\Environment\Environment("development", "adev01d");
321: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01d.azaleahealth.com/testing/', 'GET', array());
322: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
323: $this->assertEquals("https://adev01d.azaleahealth.com/scans/", $url->getScan());
324: $this->assertEquals("https://adev01d.azaleahealth.com/scans/abc.pdf", $url->getScan("abc.pdf"));
325:
326:
327: $env = new Azalea\Core\Environment\Environment("development", "adev01");
328: $request = Symfony\Component\HttpFoundation\Request::create('https://adev01.azaleahealth.com/testing/', 'GET', array());
329: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
330: $this->assertEquals("https://adev01.azaleahealth.com/scans/", $url->getScan());
331: $this->assertEquals("https://adev01.azaleahealth.com/scans/abc.pdf", $url->getScan("abc.pdf"));
332:
333:
334: $env = new Azalea\Core\Environment\Environment("production", "aws01");
335: $config = new Azalea\Core\Config\ConfigManager(
336: new Azalea\Core\Config\RepositoryMemoryLoader(array(
337: "url" => array(
338: "files" => array(
339: "com" => "https://www.azaleahealth.com/",
340: "net" => "https://www.azaleahealth.net/"
341: )
342: )
343: ))
344: );
345: $request = Symfony\Component\HttpFoundation\Request::create(
346: 'https://www.azaleahealth.com/',
347: 'GET',
348: array()
349: );
350:
351: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
352: $this->assertEquals("https://www.azaleahealth.com/awa/scans/", $url->getScan());
353: $this->assertEquals("https://www.azaleahealth.com/awa/scans/abc.pdf", $url->getScan("abc.pdf"));
354:
355:
356: $request = Symfony\Component\HttpFoundation\Request::create(
357: 'https://www.azaleahealth.net/',
358: 'GET',
359: array()
360: );
361:
362: $url = new Azalea\Shared\System\Url\UrlManager($env, $config, $request);
363: $this->assertEquals("https://www.azaleahealth.net/awa/scans/", $url->getScan());
364: $this->assertEquals("https://www.azaleahealth.net/awa/scans/abc.pdf", $url->getScan("abc.pdf"));
365: }
366: }
367:
368: ?>