summaryrefslogtreecommitdiff
path: root/tests/Unit/Models
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-31 01:55:05 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-31 03:24:54 +0200
commitac48332166ce28fcb1a2fc130c7f5adbc760e42d (patch)
tree1ff076a6a1c5a35b4ad73477d60cbcb77ebfd922 /tests/Unit/Models
parent9d9aa71eb736885f23c069a75c7a047b06434178 (diff)
Models: Added LogEntry model
Diffstat (limited to 'tests/Unit/Models')
-rw-r--r--tests/Unit/Models/BaseModelTest.php22
-rw-r--r--tests/Unit/Models/Stub/BaseModelImplementation.php27
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/Unit/Models/BaseModelTest.php b/tests/Unit/Models/BaseModelTest.php
new file mode 100644
index 00000000..52cb8c7b
--- /dev/null
+++ b/tests/Unit/Models/BaseModelTest.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Models;
+
+use Engelsystem\Test\Unit\Models\Stub\BaseModelImplementation;
+use PHPUnit\Framework\TestCase;
+
+class BaseModelTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Models\BaseModel::create
+ */
+ public function testCreate()
+ {
+ $model = new BaseModelImplementation();
+ $newModel = $model->create(['foo' => 'bar']);
+
+ $this->assertNotEquals($model, $newModel);
+ $this->assertEquals('bar', $newModel->foo);
+ $this->assertEquals(1, $newModel->saveCount);
+ }
+}
diff --git a/tests/Unit/Models/Stub/BaseModelImplementation.php b/tests/Unit/Models/Stub/BaseModelImplementation.php
new file mode 100644
index 00000000..4aa1ef0b
--- /dev/null
+++ b/tests/Unit/Models/Stub/BaseModelImplementation.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Models\Stub;
+
+use Engelsystem\Models\BaseModel;
+
+/**
+ * @property string foo
+ */
+class BaseModelImplementation extends BaseModel
+{
+ /** @var array */
+ protected $fillable = ['foo'];
+
+ /** @var int */
+ public $saveCount = 0;
+
+ /**
+ * @param array $options
+ * @return bool
+ */
+ public function save(array $options = [])
+ {
+ $this->saveCount++;
+ return true;
+ }
+}