mirror of
https://github.com/flarum/core.git
synced 2025-10-13 07:54:25 +02:00
We are still testing the installation logic, but not testing the actual CLI task. I would love to do that, but IMO we first need to find a way to do this fully from the outside, by invoking and talking to the installer through the shell. Because acceptance tests are easier to do when fully decoupled from the application. (After all, they are intended to save us from breaking things when changing code; and we cannot prove that when we change the tests at the same time.) It might be easier to start with acceptance tests for the web installer, though.
92 lines
2.5 KiB
PHP
92 lines
2.5 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\Install;
|
|
|
|
use Flarum\Install\Installation;
|
|
use Flarum\Tests\Test\TestCase;
|
|
use Illuminate\Database\Connectors\ConnectionFactory;
|
|
|
|
class DefaultInstallationTest extends TestCase
|
|
{
|
|
protected $isInstalled = false;
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function allows_forum_installation()
|
|
{
|
|
if (file_exists(base_path('config.php'))) {
|
|
unlink(base_path('config.php'));
|
|
}
|
|
|
|
/** @var Installation $installation */
|
|
$installation = app(Installation::class);
|
|
|
|
$installation
|
|
->debugMode(true)
|
|
->baseUrl('http://flarum.local')
|
|
->databaseConfig($this->getDatabaseConfiguration())
|
|
->adminUser($this->getAdmin())
|
|
->settings($this->getSettings())
|
|
->build()->run();
|
|
|
|
$this->assertFileExists(base_path('config.php'));
|
|
|
|
$admin = $this->getAdmin();
|
|
|
|
$this->assertEquals(
|
|
$this->getDatabase()->table('users')->find(1)->username,
|
|
$admin['username']
|
|
);
|
|
}
|
|
|
|
private function getDatabase()
|
|
{
|
|
$factory = new ConnectionFactory(app());
|
|
|
|
return $factory->make($this->getDatabaseConfiguration());
|
|
}
|
|
|
|
private function getAdmin()
|
|
{
|
|
return [
|
|
'username' => 'admin',
|
|
'password' => 'password',
|
|
'password_confirmation' => 'password',
|
|
'email' => 'admin@example.com',
|
|
];
|
|
}
|
|
|
|
private function getSettings()
|
|
{
|
|
return [
|
|
'allow_post_editing' => 'reply',
|
|
'allow_renaming' => '10',
|
|
'allow_sign_up' => '1',
|
|
'custom_less' => '',
|
|
'default_locale' => 'en',
|
|
'default_route' => '/all',
|
|
'extensions_enabled' => '[]',
|
|
'forum_title' => 'Development Forum',
|
|
'forum_description' => '',
|
|
'mail_driver' => 'log',
|
|
'mail_from' => 'noreply@flarum.dev',
|
|
'theme_colored_header' => '0',
|
|
'theme_dark_mode' => '0',
|
|
'theme_primary_color' => '#4D698E',
|
|
'theme_secondary_color' => '#4D698E',
|
|
'welcome_message' => 'This is beta software and you should not use it in production.',
|
|
'welcome_title' => 'Welcome to Development Forum',
|
|
];
|
|
}
|
|
}
|