Mercurial > hg > cmmr2012-drupal-site
comparison vendor/consolidation/site-alias/tests/SiteAliasFileLoaderTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
26 $this->sut->addSearchLocation($siteAliasFixtures); | 26 $this->sut->addSearchLocation($siteAliasFixtures); |
27 | 27 |
28 // Try to get the dev environment. | 28 // Try to get the dev environment. |
29 $name = SiteAliasName::parse('@wild.dev'); | 29 $name = SiteAliasName::parse('@wild.dev'); |
30 $result = $this->callProtected('loadSingleAliasFile', [$name]); | 30 $result = $this->callProtected('loadSingleAliasFile', [$name]); |
31 $this->assertTrue($result instanceof AliasRecord); | 31 $this->assertTrue($result instanceof SiteAlias); |
32 $this->assertEquals('/path/to/wild', $result->get('root')); | 32 $this->assertEquals('/path/to/wild', $result->get('root')); |
33 $this->assertEquals('bar', $result->get('foo')); | 33 $this->assertEquals('bar', $result->get('foo')); |
34 | 34 |
35 // Try to fetch an environment that does not exist. Since this is | 35 // Try to fetch an environment that does not exist. Since this is |
36 // a wildcard alias, there should | 36 // a wildcard alias, there should |
37 $name = SiteAliasName::parse('@wild.other'); | 37 $name = SiteAliasName::parse('@wild.other'); |
38 $result = $this->callProtected('loadSingleAliasFile', [$name]); | 38 $result = $this->callProtected('loadSingleAliasFile', [$name]); |
39 $this->assertTrue($result instanceof AliasRecord); | 39 $this->assertTrue($result instanceof SiteAlias); |
40 $this->assertEquals('/wild/path/to/wild', $result->get('root')); | 40 $this->assertEquals('/wild/path/to/wild', $result->get('root')); |
41 $this->assertEquals('bar', $result->get('foo')); | 41 $this->assertEquals('bar', $result->get('foo')); |
42 | 42 |
43 } | 43 } |
44 | 44 |
58 | 58 |
59 // Look for a simple alias with no environments defined | 59 // Look for a simple alias with no environments defined |
60 $name = new SiteAliasName('simple'); | 60 $name = new SiteAliasName('simple'); |
61 $this->assertEquals('simple', $name->sitename()); | 61 $this->assertEquals('simple', $name->sitename()); |
62 $result = $this->callProtected('loadSingleAliasFile', [$name]); | 62 $result = $this->callProtected('loadSingleAliasFile', [$name]); |
63 $this->assertTrue($result instanceof AliasRecord); | 63 $this->assertTrue($result instanceof SiteAlias); |
64 $this->assertEquals('/path/to/simple', $result->get('root')); | 64 $this->assertEquals('/path/to/simple', $result->get('root')); |
65 | 65 |
66 // Look for a single alias without an environment specified. | 66 // Look for a single alias without an environment specified. |
67 $name = new SiteAliasName('single'); | 67 $name = new SiteAliasName('single'); |
68 $this->assertEquals('single', $name->sitename()); | 68 $this->assertEquals('single', $name->sitename()); |
69 $result = $this->callProtected('loadSingleAliasFile', [$name]); | 69 $result = $this->callProtected('loadSingleAliasFile', [$name]); |
70 $this->assertTrue($result instanceof AliasRecord); | 70 $this->assertTrue($result instanceof SiteAlias); |
71 $this->assertEquals('/path/to/single', $result->get('root')); | 71 $this->assertEquals('/path/to/single', $result->get('root')); |
72 $this->assertEquals('bar', $result->get('foo')); | 72 $this->assertEquals('bar', $result->get('foo')); |
73 | 73 |
74 // Same test, but with environment explicitly requested. | 74 // Same test, but with environment explicitly requested. |
75 $name = SiteAliasName::parse('@single.alternate'); | 75 $name = SiteAliasName::parse('@single.alternate'); |
76 $result = $this->callProtected('loadSingleAliasFile', [$name]); | 76 $result = $this->callProtected('loadSingleAliasFile', [$name]); |
77 $this->assertTrue($result instanceof AliasRecord); | 77 $this->assertTrue($result instanceof SiteAlias); |
78 $this->assertEquals('/alternate/path/to/single', $result->get('root')); | 78 $this->assertEquals('/alternate/path/to/single', $result->get('root')); |
79 $this->assertEquals('bar', $result->get('foo')); | 79 $this->assertEquals('bar', $result->get('foo')); |
80 | 80 |
81 // Same test, but with location explicitly filtered. | 81 // Same test, but with location explicitly filtered. |
82 $name = SiteAliasName::parse('@other.single.dev'); | 82 $name = SiteAliasName::parse('@other.single.dev'); |
83 $result = $this->callProtected('loadSingleAliasFile', [$name]); | 83 $result = $this->callProtected('loadSingleAliasFile', [$name]); |
84 $this->assertTrue($result instanceof AliasRecord); | 84 $this->assertTrue($result instanceof SiteAlias); |
85 $this->assertEquals('/other/path/to/single', $result->get('root')); | 85 $this->assertEquals('/other/path/to/single', $result->get('root')); |
86 $this->assertEquals('baz', $result->get('foo')); | 86 $this->assertEquals('baz', $result->get('foo')); |
87 | 87 |
88 // Try to fetch an alias that does not exist. | 88 // Try to fetch an alias that does not exist. |
89 $name = SiteAliasName::parse('@missing'); | 89 $name = SiteAliasName::parse('@missing'); |
94 $name = SiteAliasName::parse('@missing.single.alternate'); | 94 $name = SiteAliasName::parse('@missing.single.alternate'); |
95 $result = $this->callProtected('loadSingleAliasFile', [$name]); | 95 $result = $this->callProtected('loadSingleAliasFile', [$name]); |
96 $this->assertFalse($result); | 96 $this->assertFalse($result); |
97 } | 97 } |
98 | 98 |
99 public function testLoadLegacy() | |
100 { | |
101 $this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/legacy'); | |
102 } | |
103 | |
104 public function testLoad() | 99 public function testLoad() |
105 { | 100 { |
106 $this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites'); | 101 $this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites'); |
107 | 102 |
108 // Look for a simple alias with no environments defined | 103 // Look for a simple alias with no environments defined |
109 $name = new SiteAliasName('simple'); | 104 $name = new SiteAliasName('simple'); |
110 $result = $this->sut->load($name); | 105 $result = $this->sut->load($name); |
111 $this->assertTrue($result instanceof AliasRecord); | 106 $this->assertTrue($result instanceof SiteAlias); |
112 $this->assertEquals('/path/to/simple', $result->get('root')); | 107 $this->assertEquals('/path/to/simple', $result->get('root')); |
113 | 108 |
114 // Look for a single alias without an environment specified. | 109 // Look for a single alias without an environment specified. |
115 $name = new SiteAliasName('single'); | 110 $name = new SiteAliasName('single'); |
116 $result = $this->sut->load($name); | 111 $result = $this->sut->load($name); |
117 $this->assertTrue($result instanceof AliasRecord); | 112 $this->assertTrue($result instanceof SiteAlias); |
118 $this->assertEquals('/path/to/single', $result->get('root')); | 113 $this->assertEquals('/path/to/single', $result->get('root')); |
119 $this->assertEquals('bar', $result->get('foo')); | 114 $this->assertEquals('bar', $result->get('foo')); |
120 | 115 |
121 // Same test, but with environment explicitly requested. | 116 // Same test, but with environment explicitly requested. |
122 $name = new SiteAliasName('single', 'alternate'); | 117 $name = new SiteAliasName('single', 'alternate'); |
123 $result = $this->sut->load($name); | 118 $result = $this->sut->load($name); |
124 $this->assertTrue($result instanceof AliasRecord); | 119 $this->assertTrue($result instanceof SiteAlias); |
125 $this->assertEquals('/alternate/path/to/single', $result->get('root')); | 120 $this->assertEquals('/alternate/path/to/single', $result->get('root')); |
126 $this->assertEquals('bar', $result->get('foo')); | 121 $this->assertEquals('bar', $result->get('foo')); |
127 | 122 |
128 // Try to fetch an alias that does not exist. | 123 // Try to fetch an alias that does not exist. |
129 $name = new SiteAliasName('missing'); | 124 $name = new SiteAliasName('missing'); |