summaryrefslogtreecommitdiff
path: root/tests/Unit/Models/BaseModelTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Unit/Models/BaseModelTest.php')
-rw-r--r--tests/Unit/Models/BaseModelTest.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/Unit/Models/BaseModelTest.php b/tests/Unit/Models/BaseModelTest.php
index 52cb8c7b..9af55fa1 100644
--- a/tests/Unit/Models/BaseModelTest.php
+++ b/tests/Unit/Models/BaseModelTest.php
@@ -3,6 +3,8 @@
namespace Engelsystem\Test\Unit\Models;
use Engelsystem\Test\Unit\Models\Stub\BaseModelImplementation;
+use Illuminate\Database\Eloquent\Builder as QueryBuilder;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class BaseModelTest extends TestCase
@@ -19,4 +21,26 @@ class BaseModelTest extends TestCase
$this->assertEquals('bar', $newModel->foo);
$this->assertEquals(1, $newModel->saveCount);
}
+
+ /**
+ * @covers \Engelsystem\Models\BaseModel::find
+ */
+ public function testFind()
+ {
+ /** @var QueryBuilder|MockObject $queryBuilder */
+ $queryBuilder = $this->createMock(QueryBuilder::class);
+ BaseModelImplementation::$queryBuilder = $queryBuilder;
+
+ $anotherModel = new BaseModelImplementation();
+
+ $queryBuilder->expects($this->once())
+ ->method('find')
+ ->with(1337, ['foo', 'bar'])
+ ->willReturn($anotherModel);
+
+ $model = new BaseModelImplementation();
+ $newModel = $model->find(1337, ['foo', 'bar']);
+
+ $this->assertEquals($anotherModel, $newModel);
+ }
}