1
0
mirror of https://github.com/flarum/core.git synced 2025-08-24 17:13:44 +02:00

Tests: Rely on admin user, groups, permissions from test setup script

This commit is contained in:
Franz Liedke
2020-05-20 00:18:00 +02:00
committed by Alexander Skvortsov
parent a47187462d
commit a08fd3e475
27 changed files with 8 additions and 269 deletions

View File

@@ -35,13 +35,8 @@ class ApiControllerTest extends TestCase
{
$this->prepareDatabase([
'users' => [
$this->adminUser(),
$this->normalUser()
],
'groups' => [
$this->adminGroup(),
$this->memberGroup()
],
'discussions' => [
['id' => 1, 'title' => 'Custom Discussion Title', 'created_at' => Carbon::now()->toDateTimeString(), 'user_id' => 2, 'first_post_id' => 0, 'comment_count' => 1, 'is_private' => 0],
['id' => 2, 'title' => 'Custom Discussion Title', 'created_at' => Carbon::now()->toDateTimeString(), 'user_id' => 3, 'first_post_id' => 0, 'comment_count' => 1, 'is_private' => 0],

View File

@@ -31,7 +31,6 @@ class ApiSerializerTest extends TestCase
{
$this->prepareDatabase([
'users' => [
$this->adminUser(),
$this->normalUser()
],
'discussions' => [

View File

@@ -24,15 +24,6 @@ class EventTest extends TestCase
protected function buildGroup()
{
$this->prepareDatabase([
'groups' => [
$this->adminGroup(),
],
'users' => [
$this->adminUser(),
],
]);
$bus = $this->app()->getContainer()->make(Dispatcher::class);
return $bus->dispatch(

View File

@@ -23,28 +23,11 @@ class MailTest extends TestCase
{
use RetrievesAuthorizedUsers;
protected function prepDb()
{
$this->prepareDatabase([
'users' => [
$this->adminUser(),
],
'groups' => [
$this->adminGroup(),
],
'group_user' => [
['user_id' => 1, 'group_id' => 1],
],
]);
}
/**
* @test
*/
public function drivers_are_unchanged_by_default()
{
$this->prepDb();
$response = $this->send(
$this->request('GET', '/api/mail/settings', [
'authenticatedAs' => 1,
@@ -76,8 +59,6 @@ class MailTest extends TestCase
->driver('custom', CustomDriver::class)
);
$this->prepDb();
$response = $this->send(
$this->request('GET', '/api/mail/settings', [
'authenticatedAs' => 1,
@@ -100,8 +81,6 @@ class MailTest extends TestCase
->driver('smtp', CustomDriver::class)
);
$this->prepDb();
$response = $this->send(
$this->request('GET', '/api/mail/settings', [
'authenticatedAs' => 1,

View File

@@ -29,7 +29,6 @@ class ModelTest extends TestCase
{
$this->prepareDatabase([
'users' => [
$this->adminUser(),
$this->normalUser(),
],
]);
@@ -245,11 +244,6 @@ class ModelTest extends TestCase
);
$this->prepDB();
$this->prepareDatabase([
'groups' => [
$this->adminGroup()
]
]);
$group = Group::find(1);

View File

@@ -26,7 +26,6 @@ class ModelUrlTest extends TestCase
$userClass = User::class;
$this->prepareDatabase([
'users' => [
$this->adminUser(),
$this->normalUser(),
],
'settings' => [

View File

@@ -37,17 +37,6 @@ class ModelVisibilityTest extends TestCase
],
'users' => [
$this->normalUser(),
],
'groups' => [
$this->guestGroup(),
$this->memberGroup(),
],
'group_user' => [
['user_id' => 2, 'group_id' => 3],
],
'group_permission' => [
['permission' => 'viewDiscussions', 'group_id' => 2],
['permission' => 'viewDiscussions', 'group_id' => 3],
]
]);
}

View File

@@ -32,7 +32,6 @@ class PolicyTest extends TestCase
{
$this->prepareDatabase([
'users' => [
$this->adminUser(),
$this->normalUser(),
],
'discussions' => [

View File

@@ -21,7 +21,6 @@ class SettingsTest extends TestCase
{
$this->prepareDatabase([
'users' => [
$this->adminUser(),
$this->normalUser()
],
'settings' => [

View File

@@ -22,15 +22,6 @@ class ThrottleApiTest extends TestCase
$this->prepareDatabase([
'users' => [
$this->normalUser(),
],
'groups' => [
$this->memberGroup(),
],
'group_user' => [
['user_id' => 2, 'group_id' => 3],
],
'group_permission' => [
['permission' => 'viewDiscussions', 'group_id' => 3],
]
]);
}

View File

@@ -24,17 +24,10 @@ class UserTest extends TestCase
{
$this->prepareDatabase([
'users' => [
$this->adminUser(),
$this->normalUser(),
],
'group_permission' => [
['permission' => 'viewUserList', 'group_id' => 3]
],
'settings' => [
['key' => 'display_name_driver', 'value' => 'custom'],
],
'group_permission' => [
['permission' => 'viewUserList', 'group_id' => 3],
]
]);
}