3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Test\src\Util;
24 use Friendica\Test\MockedTest;
25 use Friendica\Util\BasePath;
27 class BasePathTest extends MockedTest
29 public function dataPaths()
34 'input' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
35 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
40 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
44 'DOCUMENT_ROOT' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
47 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
51 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
54 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
58 'DOCUMENT_ROOT' => dirname(__DIR__, 3),
59 'PWD' => dirname(__DIR__, 3),
62 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
64 'no_overwrite_if_invalid' => [
66 'DOCUMENT_ROOT' => '/nopopop',
67 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
69 'input' => '/noatgawe22fafa',
70 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
76 * Test the basepath determination
77 * @dataProvider dataPaths
79 public function testDetermineBasePath(array $server, $input, $output)
81 $basepath = new BasePath($input, $server);
82 self::assertEquals($output, $basepath->getPath());
86 * Test the basepath determination with a complete wrong path
88 public function testFailedBasePath()
90 $this->expectException(\Exception::class);
91 $this->expectExceptionMessageMatches("/(.*) is not a valid basepath/");
93 $basepath = new BasePath('/now23452sgfgas', []);