summaryrefslogtreecommitdiff
path: root/tests/Unit/Models
diff options
context:
space:
mode:
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;
+ }
+}