Message: Add coverage, fix method hints

This commit is contained in:
Igor Scheller 2019-12-30 01:44:09 +01:00
parent a78659b2d4
commit 395f6706d6
3 changed files with 15 additions and 7 deletions

View File

@ -75,7 +75,7 @@ class CreateMessagesTable extends Migration
'messages',
function (Blueprint $table) {
$table->increments('id');
$this->references($table, 'users', 'user_id');
$this->referencesUser($table);
$this->references($table, 'users', 'receiver_id');
$table->boolean('read')->default(0);
$table->text('text');

View File

@ -20,15 +20,11 @@ use Illuminate\Support\Carbon;
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read User $receiver
* @method static Builder|Message newModelQuery()
* @method static Builder|Message newQuery()
* @method static Builder|Message query()
* @method static Builder|Message whereCreatedAt($value)
* @method static Builder|Message whereId($value)
* @method static Builder|Message whereRead($value)
* @method static Builder|Message whereReceiverId($value)
* @method static Builder|Message whereSenderId($value)
* @method static Builder|Message whereRead($value)
* @method static Builder|Message whereText($value)
* @method static Builder|Message whereCreatedAt($value)
* @method static Builder|Message whereUpdatedAt($value)
*/
class Message extends BaseModel

View File

@ -76,6 +76,8 @@ class MessageTest extends TestCase
/**
* Tests that loading Messages works.
*
* @covers \Engelsystem\Models\Message::__construct
*
* @return void
*/
public function testLoad(): void
@ -96,6 +98,8 @@ class MessageTest extends TestCase
/**
* Tests that the Messages have the correct senders.
*
* @covers \Engelsystem\Models\Message::user
*
* @return void
*/
public function testSenders(): void
@ -108,6 +112,8 @@ class MessageTest extends TestCase
/**
* Tests that the Messages have the correct receivers.
*
* @covers \Engelsystem\Models\Message::receiver
*
* @return void
*/
public function testReceivers(): void
@ -120,6 +126,8 @@ class MessageTest extends TestCase
/**
* Tests that the Users have the correct sent Messages.
*
* @covers \Engelsystem\Models\User\User::messagesSent
*
* @return void
*/
public function testUserSentMessages(): void
@ -137,6 +145,8 @@ class MessageTest extends TestCase
/**
* Tests that the Users have the correct received Messages.
*
* @covers \Engelsystem\Models\User\User::messagesReceived
*
* @return void
*/
public function testUserReceivedMessages(): void
@ -153,6 +163,8 @@ class MessageTest extends TestCase
/**
* Tests that the user have the correct Messages.
*
* @covers \Engelsystem\Models\User\User::messages
*/
public function testUserMessages(): void
{