2015-09-09 09:28:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Database\Tester\Models\Post;
|
|
|
|
|
|
2020-02-07 08:59:39 +00:00
|
|
|
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
|
|
|
}
|