mirror of
https://github.com/flarum/framework.git
synced 2024-12-05 00:43:39 +08:00
bf79f2474c
- 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
86 lines
3.0 KiB
PHP
86 lines
3.0 KiB
PHP
<?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 PHPUnit\Framework\TestCase;
|
|
use Zend\Diactoros\Uri;
|
|
|
|
class BaseUrlTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider urlProvider
|
|
*/
|
|
public function test_base_url_simulating_cli_installer($uri, $expected)
|
|
{
|
|
$this->assertEquals($expected, BaseUrl::fromString($uri));
|
|
}
|
|
|
|
/**
|
|
* @dataProvider urlProvider
|
|
*/
|
|
public function test_base_url_simulating_web_installer($uri, $expected)
|
|
{
|
|
$uri = new Uri($uri);
|
|
|
|
$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()
|
|
{
|
|
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'],
|
|
];
|
|
}
|
|
|
|
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'],
|
|
];
|
|
}
|
|
}
|