ORIENT/tests/unit/plugins/database/ModelTest.php

34 lines
833 B
PHP
Raw Normal View History

2015-09-09 09:28:47 +00:00
<?php
use Database\Tester\Models\Post;
class ModelTest extends PluginTestCase
2015-09-09 09:28:47 +00:00
{
2019-06-12 16:22:20 +00:00
public function setUp() : void
2015-09-09 09:28:47 +00:00
{
parent::setUp();
include_once base_path().'/tests/fixtures/plugins/database/tester/models/Post.php';
$this->runPluginRefreshCommand('Database.Tester');
}
public function testCreateFirstPost()
{
Post::truncate();
$post = new Post;
$post->title = "First post";
$post->description = "Yay!!";
$post->save();
$this->assertEquals(1, $post->id);
}
public function testGuardedAttribute()
{
2020-01-19 14:26:21 +00:00
$this->expectException(\Illuminate\Database\Eloquent\MassAssignmentException::class);
$this->expectExceptionMessageMatches('/title/');
2015-09-09 09:28:47 +00:00
Post::create(['title' => 'Hi!', 'slug' => 'authenticity']);
}
2017-03-21 20:31:02 +00:00
}