2 namespace Friendica\Test\src\Util;
4 use Friendica\Test\MockedTest;
5 use Friendica\Util\BasePath;
7 class BasePathTest extends MockedTest
9 public function dataPaths()
14 'input' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
15 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
20 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
24 'DOCUMENT_ROOT' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
27 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
31 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
34 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
38 'DOCUMENT_ROOT' => dirname(__DIR__, 3),
39 'PWD' => dirname(__DIR__, 3),
42 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
44 'no_overwrite_if_invalid' => [
46 'DOCUMENT_ROOT' => '/nopopop',
47 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
49 'input' => '/noatgawe22fafa',
50 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config',
56 * Test the basepath determination
57 * @dataProvider dataPaths
59 public function testDetermineBasePath(array $server, $input, $output)
61 $basepath = new BasePath($input, $server);
62 $this->assertEquals($output, $basepath->getPath());
66 * Test the basepath determination with a complete wrong path
67 * @expectedException \Exception
68 * @expectedExceptionMessageRegExp /(.*) is not a valid basepath/
70 public function testFailedBasePath()
72 $basepath = new BasePath('/now23452sgfgas', []);