1
0
mirror of https://github.com/flarum/core.git synced 2025-07-30 21:20:24 +02:00

Normalize Base URL during installation

- Fix base url when is appended with a script filename
- Add default base url http://flarum.local when CLI wizard used
- Remove some code duplication
- Add minor improvement to the UX when CLI wizard used
- Add tests
- Extract base url normalisation into its own value object
This commit is contained in:
Stefan Totev
2019-09-23 23:26:51 +01:00
committed by Franz Liedke
parent 09609a9f20
commit 738ca405fe
7 changed files with 168 additions and 19 deletions

View File

@@ -0,0 +1,59 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Tests\unit;
use Flarum\Install\BaseUrl;
use Flarum\Tests\integration\TestCase;
class BaseUrlTest extends TestCase
{
/**
* @dataProvider urlProvider
* @param $uri
* @param $expected
*/
public function test_base_url_simulating_cli_installer($uri, $expected)
{
$this->assertEquals($expected, BaseUrl::fromString($uri));
}
/**
* @dataProvider urlProvider
* @param $uri
* @param $expected
*/
public function test_base_url_simulating_web_installer($uri, $expected)
{
$request = $this->request('get', $uri);
$this->assertEquals($expected, BaseUrl::fromUri($request->getUri()));
}
public function urlProvider()
{
return [
['', ''],
['flarum.org', 'http://flarum.org'],
['flarum.org/', 'http://flarum.org'],
['http://flarum.org', 'http://flarum.org'],
['http://flarum.org/', 'http://flarum.org'],
['https://flarum.org', 'https://flarum.org'],
['http://flarum.org/index.php', 'http://flarum.org'],
['http://flarum.org/index.php/', 'http://flarum.org'],
['http://flarum.org/flarum', 'http://flarum.org/flarum'],
['http://flarum.org/flarum/index.php', 'http://flarum.org/flarum'],
['http://flarum.org/flarum/index.php/', 'http://flarum.org/flarum'],
['sub.flarum.org', 'http://sub.flarum.org'],
['http://sub.flarum.org', 'http://sub.flarum.org'],
];
}
}