Add a few more automated tests

This commit is contained in:
Alexander Skvortsov 2021-04-11 23:00:36 -04:00
parent f13d45f77b
commit 675627ac15
2 changed files with 61 additions and 3 deletions

View File

@ -14,7 +14,5 @@ namespace Flarum\Testing;
use Flarum\Extend;
return [
(new Extend\Settings)->serializeToForum('notARealSetting', 'not.a.real.setting')
];

View File

@ -9,11 +9,29 @@
namespace Flarum\Testing\Tests\integration;
use Flarum\Extend;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
class TestCaseTest extends TestCase
{
/**
* @test
*/
public function admin_user_created_as_part_of_default_state()
{
$this->app();
$this->assertEquals(1, User::query()->count());
$user = User::find(1);
$this->assertEquals('admin', $user->username);
$this->assertEquals('admin@machine.local', $user->email);
$this->assertTrue($user->isAdmin());
}
/**
* @test
*/
@ -27,4 +45,46 @@ class TestCaseTest extends TestCase
$this->assertEquals('world', $settings->get('hello'));
$this->assertEquals('something_other_than_username', $settings->get('display_name_driver'));
}
/**
* @test
*/
public function current_extension_not_applied_by_default()
{
$response = $this->send(
$this->request('GET', '/')
);
$this->assertStringNotContainsString('notARealSetting', $response->getBody()->getContents());
}
/**
* @test
*/
public function current_extension_applied_if_specified()
{
$this->extension('flarum-testing-tests');
$response = $this->send(
$this->request('GET', '/')
);
$this->assertStringContainsString('notARealSetting', $response->getBody()->getContents());
}
/**
* @test
*/
public function can_apply_extenders()
{
$this->extend(
(new Extend\Settings)->serializeToForum('notARealSetting', 'not.a.real.setting')
);
$response = $this->send(
$this->request('GET', '/')
);
$this->assertStringContainsString('notARealSetting', $response->getBody()->getContents());
}
}