From 785f2391f3e4771528d58aee1702acbec9eab2af Mon Sep 17 00:00:00 2001 From: James Brooks Date: Mon, 2 Apr 2018 18:21:58 +0100 Subject: [PATCH] Add tests for Taggable model --- app/Models/Taggable.php | 14 ++++++++++++++ tests/Models/TaggableTest.php | 31 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/Models/TaggableTest.php diff --git a/app/Models/Taggable.php b/app/Models/Taggable.php index 4717de28..d8c0c1fb 100644 --- a/app/Models/Taggable.php +++ b/app/Models/Taggable.php @@ -11,6 +11,7 @@ namespace CachetHQ\Cachet\Models; +use AltThree\TestBench\ValidationTrait; use Illuminate\Database\Eloquent\Model; /** @@ -20,6 +21,8 @@ use Illuminate\Database\Eloquent\Model; */ class Taggable extends Model { + use ValidationTrait; + /** * The attributes that should be casted to native types. * @@ -43,6 +46,17 @@ class Taggable extends Model 'taggable_type', ]; + /** + * The validation rules. + * + * @var string[] + */ + public $rules = [ + 'tag_id' => 'required|int', + 'taggable_id' => 'required|int', + 'taggable_type' => 'required|string', + ]; + /** * Get the tag relation. * diff --git a/tests/Models/TaggableTest.php b/tests/Models/TaggableTest.php new file mode 100644 index 00000000..8a5271a3 --- /dev/null +++ b/tests/Models/TaggableTest.php @@ -0,0 +1,31 @@ + + */ +class TaggableTest extends AbstractTestCase +{ + use ValidationTrait; + + public function testValidation() + { + $this->checkRules(new Taggable()); + } +}