Tests: Added ModelTest class

main
Igor Scheller 5 years ago committed by msquare
parent 90b5c7bd2a
commit f99e0a229f

@ -4,13 +4,9 @@ namespace Engelsystem\Test\Unit\Models;
use Carbon\Carbon;
use Engelsystem\Models\EventConfig;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
class EventConfigTest extends TestCase
class EventConfigTest extends ModelTest
{
use HasDatabase;
/**
* @covers \Engelsystem\Models\EventConfig::setValueAttribute
*/
@ -117,13 +113,4 @@ class EventConfigTest extends TestCase
}
};
}
/**
* Prepare test
*/
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
}
}

@ -3,14 +3,10 @@
namespace Engelsystem\Test\Unit\Models;
use Engelsystem\Models\LogEntry;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
use Psr\Log\LogLevel;
class LogEntryTest extends TestCase
class LogEntryTest extends ModelTest
{
use HasDatabase;
/**
* @covers \Engelsystem\Models\LogEntry::filter
*/
@ -34,13 +30,4 @@ class LogEntryTest extends TestCase
$this->assertCount(3, LogEntry::filter(LogLevel::INFO));
$this->assertCount(1, LogEntry::filter('Oops'));
}
/**
* Prepare test
*/
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
}
}

@ -6,16 +6,12 @@ namespace Engelsystem\Test\Unit\Models;
use Engelsystem\Models\Message;
use Engelsystem\Models\User\User;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
/**
* This class provides tests covering the Message model and its relations.
*/
class MessageTest extends TestCase
class MessageTest extends ModelTest
{
use HasDatabase;
/** @var User */
private $user1;
@ -37,7 +33,6 @@ class MessageTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
$this->user1 = User::create([
'name' => 'user1',

@ -0,0 +1,21 @@
<?php
namespace Engelsystem\Test\Unit\Models;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
abstract class ModelTest extends TestCase
{
use HasDatabase;
/**
* Prepare test
*/
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
}
}

@ -7,16 +7,12 @@ namespace Engelsystem\Test\Unit\Models;
use Engelsystem\Models\News;
use Engelsystem\Models\NewsComment;
use Engelsystem\Models\User\User;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
/**
* This class provides tests for the NewsComments model.
*/
class NewsCommentsTest extends TestCase
class NewsCommentsTest extends ModelTest
{
use HasDatabase;
/** @var User */
private $user;
@ -32,7 +28,6 @@ class NewsCommentsTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
$this->user = User::create([
'name' => 'lorem',

@ -6,16 +6,12 @@ namespace Engelsystem\Test\Unit\Models;
use Engelsystem\Models\News;
use Engelsystem\Models\User\User;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
/**
* This class provides tests for the News model.
*/
class NewsTest extends TestCase
class NewsTest extends ModelTest
{
use HasDatabase;
/** @var array */
private $newsData;
@ -28,7 +24,6 @@ class NewsTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
$this->user = (new User())->create([
'name' => 'lorem',

@ -6,14 +6,10 @@ namespace Engelsystem\Test\Unit\Models;
use Engelsystem\Models\Question;
use Engelsystem\Models\User\User;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
use Illuminate\Support\Str;
class QuestionTest extends TestCase
class QuestionTest extends ModelTest
{
use HasDatabase;
/**
* @var User
*/
@ -30,7 +26,6 @@ class QuestionTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
$this->user1 = User::create(
[

@ -4,14 +4,11 @@ namespace Engelsystem\Test\Unit\Models\Shifts;
use Engelsystem\Models\Shifts\Schedule;
use Engelsystem\Models\Shifts\ScheduleShift;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
use Engelsystem\Test\Unit\Models\ModelTest;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ScheduleShiftTest extends TestCase
class ScheduleShiftTest extends ModelTest
{
use HasDatabase;
/**
* @covers \Engelsystem\Models\Shifts\ScheduleShift::schedule
*/
@ -29,13 +26,4 @@ class ScheduleShiftTest extends TestCase
$this->assertInstanceOf(BelongsTo::class, $scheduleShift->schedule());
$this->assertEquals($schedule->id, $scheduleShift->schedule->id);
}
/**
* Prepare test
*/
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
}
}

@ -4,13 +4,10 @@ namespace Engelsystem\Test\Unit\Models\Shifts;
use Engelsystem\Models\Shifts\Schedule;
use Engelsystem\Models\Shifts\ScheduleShift;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
use Engelsystem\Test\Unit\Models\ModelTest;
class ScheduleTest extends TestCase
class ScheduleTest extends ModelTest
{
use HasDatabase;
/**
* @covers \Engelsystem\Models\Shifts\Schedule::scheduleShifts
*/
@ -25,13 +22,4 @@ class ScheduleTest extends TestCase
$this->assertCount(3, $schedule->scheduleShifts);
}
/**
* Prepare test
*/
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
}
}

@ -13,15 +13,13 @@ use Engelsystem\Models\User\PersonalData;
use Engelsystem\Models\User\Settings;
use Engelsystem\Models\User\State;
use Engelsystem\Models\User\User;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
use Engelsystem\Test\Unit\Models\ModelTest;
use Exception;
use Illuminate\Support\Str;
class UserTest extends TestCase
class UserTest extends ModelTest
{
use ArraySubsetAsserts;
use HasDatabase;
/** @var string[] */
protected $data = [
@ -207,13 +205,4 @@ class UserTest extends TestCase
$this->assertContains($question1->id, $answers);
$this->assertContains($question2->id, $answers);
}
/**
* Prepare test
*/
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
}
}

@ -4,14 +4,11 @@ namespace Engelsystem\Test\Unit\Models\User;
use Engelsystem\Models\BaseModel;
use Engelsystem\Models\User\UsesUserModel;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
use Engelsystem\Test\Unit\Models\ModelTest;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class UsesUserModelTest extends TestCase
class UsesUserModelTest extends ModelTest
{
use HasDatabase;
/**
* @covers \Engelsystem\Models\User\UsesUserModel::user
*/
@ -25,13 +22,4 @@ class UsesUserModelTest extends TestCase
$this->assertInstanceOf(BelongsTo::class, $model->user());
}
/**
* Prepare test
*/
protected function setUp(): void
{
parent::setUp();
$this->initDatabase();
}
}

Loading…
Cancel
Save