mirror of
https://github.com/flarum/core.git
synced 2025-07-30 21:20:24 +02:00
Cleanup code from #1876
- Extract a method for email address generation - Consistent types - No docblocks for types where superfluous - Tweak console output - Don't inherit from integration test's base class in unit test
This commit is contained in:
@@ -12,14 +12,13 @@
|
||||
namespace Flarum\Tests\unit;
|
||||
|
||||
use Flarum\Install\BaseUrl;
|
||||
use Flarum\Tests\integration\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Zend\Diactoros\Uri;
|
||||
|
||||
class BaseUrlTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider urlProvider
|
||||
* @param $uri
|
||||
* @param $expected
|
||||
*/
|
||||
public function test_base_url_simulating_cli_installer($uri, $expected)
|
||||
{
|
||||
@@ -28,14 +27,23 @@ class BaseUrlTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider urlProvider
|
||||
* @param $uri
|
||||
* @param $expected
|
||||
*/
|
||||
public function test_base_url_simulating_web_installer($uri, $expected)
|
||||
{
|
||||
$request = $this->request('get', $uri);
|
||||
$uri = new Uri($uri);
|
||||
|
||||
$this->assertEquals($expected, BaseUrl::fromUri($request->getUri()));
|
||||
$this->assertEquals($expected, BaseUrl::fromUri($uri));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider emailProvider
|
||||
*/
|
||||
public function test_default_email_generation($uri, $expected)
|
||||
{
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
BaseUrl::fromString($uri)->toEmail('noreply')
|
||||
);
|
||||
}
|
||||
|
||||
public function urlProvider()
|
||||
@@ -56,4 +64,22 @@ class BaseUrlTest extends TestCase
|
||||
['http://sub.flarum.org', 'http://sub.flarum.org'],
|
||||
];
|
||||
}
|
||||
|
||||
public function emailProvider()
|
||||
{
|
||||
return [
|
||||
['flarum.org', 'noreply@flarum.org'],
|
||||
['flarum.org/', 'noreply@flarum.org'],
|
||||
['http://flarum.org', 'noreply@flarum.org'],
|
||||
['http://flarum.org/', 'noreply@flarum.org'],
|
||||
['https://flarum.org', 'noreply@flarum.org'],
|
||||
['http://flarum.org/index.php', 'noreply@flarum.org'],
|
||||
['http://flarum.org/index.php/', 'noreply@flarum.org'],
|
||||
['http://flarum.org/flarum', 'noreply@flarum.org'],
|
||||
['http://flarum.org/flarum/index.php', 'noreply@flarum.org'],
|
||||
['http://flarum.org/flarum/index.php/', 'noreply@flarum.org'],
|
||||
['sub.flarum.org', 'noreply@sub.flarum.org'],
|
||||
['http://sub.flarum.org', 'noreply@sub.flarum.org'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user