]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Util/BasePathTest.php
Merge pull request #13375 from MrPetovan/bug/empty-timeline
[friendica.git] / tests / src / Util / BasePathTest.php
index c31adb079e0d888c94e86c42e354241a02be37f3..844911d32f40854848ac965e693053e3bf648d9e 100644 (file)
@@ -1,4 +1,24 @@
 <?php
+/**
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
 namespace Friendica\Test\src\Util;
 
 use Friendica\Test\MockedTest;
@@ -40,6 +60,14 @@ class BasePathTest extends MockedTest
                                ],
                                'input' => 'config',
                                'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
+                       ],
+                       'no_overwrite_if_invalid' => [
+                               'server' => [
+                                       'DOCUMENT_ROOT' => '/nopopop',
+                                       'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
+                               ],
+                               'input' => '/noatgawe22fafa',
+                               'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
                        ]
                ];
        }
@@ -50,16 +78,19 @@ class BasePathTest extends MockedTest
         */
        public function testDetermineBasePath(array $server, $input, $output)
        {
-               $this->assertEquals($output, BasePath::create($input, $server));
+               $basepath = new BasePath($input, $server);
+               self::assertEquals($output, $basepath->getPath());
        }
 
        /**
         * Test the basepath determination with a complete wrong path
-        * @expectedException \Exception
-        * @expectedExceptionMessageRegExp /(.*) is not a valid basepath/
         */
        public function testFailedBasePath()
        {
-               BasePath::create('/now23452sgfgas', []);
+               $this->expectException(\Exception::class);
+               $this->expectExceptionMessageMatches("/(.*) is not a valid basepath/");
+
+               $basepath = new BasePath('/now23452sgfgas', []);
+               $basepath->getPath();
        }
 }