1 | <?php |
||
22 | class FilesystemPublisherTest extends SapphireTest |
||
23 | { |
||
24 | protected $usesDatabase = true; |
||
25 | |||
26 | protected function setUp() |
||
27 | { |
||
28 | parent::setUp(); |
||
29 | |||
30 | SiteTree::add_extension(PublishableSiteTree::class); |
||
31 | |||
32 | Config::modify()->set(FilesystemPublisher::class, 'domain_based_caching', false); |
||
33 | Config::modify()->set(Director::class, 'alternate_base_url', 'http://foo/'); |
||
34 | Config::modify()->set(QueuedJobService::class, 'use_shutdown_function', false); |
||
35 | } |
||
36 | |||
37 | protected function tearDown() |
||
38 | { |
||
39 | SiteTree::remove_extension(PublishableSiteTree::class); |
||
40 | |||
41 | parent::tearDown(); |
||
42 | } |
||
43 | |||
44 | public function testUrlToPathWithRelativeUrls() |
||
45 | { |
||
46 | $reflection = new \ReflectionClass(FilesystemPublisher::class); |
||
47 | $urlToPath = $reflection->getMethod('URLtoPath'); |
||
48 | $urlToPath->setAccessible(true); |
||
49 | |||
50 | $fsp = FilesystemPublisher::create(); |
||
51 | |||
52 | $this->assertEquals( |
||
53 | 'index', |
||
54 | $urlToPath->invokeArgs($fsp, ['/']) |
||
55 | ); |
||
56 | |||
57 | $this->assertEquals( |
||
58 | 'about-us', |
||
59 | $urlToPath->invokeArgs($fsp, ['about-us']) |
||
60 | ); |
||
61 | |||
62 | $this->assertEquals( |
||
63 | 'parent/child', |
||
64 | $urlToPath->invokeArgs($fsp, ['parent/child']) |
||
65 | ); |
||
66 | } |
||
67 | |||
68 | public function testUrlToPathWithAbsoluteUrls() |
||
94 | |||
95 | public function testUrlToPathWithDomainBasedCaching() |
||
123 | |||
124 | public function testMenu2LinkingMode() |
||
125 | { |
||
126 | $this->logInWithPermission('ADMIN'); |
||
127 | |||
128 | SSViewer::set_themes(null); |
||
|
|||
129 | |||
130 | $reflection = new \ReflectionClass(FilesystemPublisher::class); |
||
131 | $urlToPath = $reflection->getMethod('URLtoPath'); |
||
132 | $urlToPath->setAccessible(true); |
||
133 | |||
134 | $fsp = FilesystemPublisher::create() |
||
135 | ->setDestFolder('cache/testing/'); |
||
136 | |||
137 | $level1 = StaticPublisherTestPage::create(); |
||
138 | $level1->URLSegment = 'test-level-1'; |
||
139 | $level1->write(); |
||
140 | $level1->publishRecursive(); |
||
141 | |||
142 | $level2_1 = StaticPublisherTestPage::create(); |
||
143 | $level2_1->URLSegment = 'test-level-2-1'; |
||
144 | $level2_1->ParentID = $level1->ID; |
||
145 | $level2_1->write(); |
||
146 | $level2_1->publishRecursive(); |
||
147 | |||
148 | $fsp->publishURL($level1->Link(), true); |
||
149 | $fsp->publishURL($level2_1->Link(), true); |
||
150 | $static2_1FilePath = $fsp->getDestPath().$urlToPath->invokeArgs($fsp, [$level2_1->Link()]); |
||
151 | |||
152 | $this->assertFileExists($static2_1FilePath.'.html'); |
||
153 | $this->assertFileExists($static2_1FilePath.'.php'); |
||
154 | $this->assertContains( |
||
155 | 'current', |
||
156 | file_get_contents($static2_1FilePath.'.html') |
||
157 | ); |
||
158 | |||
159 | $level2_2 = StaticPublisherTestPage::create(); |
||
160 | $level2_2->URLSegment = 'test-level-2-2'; |
||
161 | $level2_2->ParentID = $level1->ID; |
||
162 | $level2_2->write(); |
||
163 | $level2_2->publishRecursive(); |
||
164 | |||
165 | $fsp->publishURL($level2_2->Link(), true); |
||
166 | $static2_2FilePath = $fsp->getDestPath().$urlToPath->invokeArgs($fsp, [$level2_2->Link()]); |
||
167 | |||
168 | $this->assertFileExists($static2_2FilePath.'.html'); |
||
169 | $this->assertFileExists($static2_2FilePath.'.php'); |
||
170 | $this->assertContains( |
||
171 | 'linkcurrent', |
||
172 | file_get_contents($static2_2FilePath.'.html') |
||
173 | ); |
||
174 | |||
175 | if (file_exists($fsp->getDestPath())) { |
||
176 | Filesystem::removeFolder($fsp->getDestPath()); |
||
177 | } |
||
178 | } |
||
179 | |||
180 | public function testOnlyHTML() |
||
205 | |||
206 | public function testNoErrorPagesWhenHTMLOnly() |
||
221 | |||
222 | public function testErrorPageWhenPHP() |
||
238 | |||
239 | public function testRedirectorPageWhenPHP() |
||
268 | |||
269 | public function testRedirectorPageWhenHTMLOnly() |
||
297 | } |
||
298 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: