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
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/Unit/Models/BaseModelTest.php b/tests/Unit/Models/BaseModelTest.php
index 9af55fa1..963ea64a 100644
--- a/tests/Unit/Models/BaseModelTest.php
+++ b/tests/Unit/Models/BaseModelTest.php
@@ -43,4 +43,26 @@ class BaseModelTest extends TestCase
$this->assertEquals($anotherModel, $newModel);
}
+
+ /**
+ * @covers \Engelsystem\Models\BaseModel::findOrNew
+ */
+ public function testFindOrNew()
+ {
+ /** @var QueryBuilder|MockObject $queryBuilder */
+ $queryBuilder = $this->createMock(QueryBuilder::class);
+ BaseModelImplementation::$queryBuilder = $queryBuilder;
+
+ $anotherModel = new BaseModelImplementation();
+
+ $queryBuilder->expects($this->once())
+ ->method('findOrNew')
+ ->with(31337, ['lorem', 'ipsum'])
+ ->willReturn($anotherModel);
+
+ $model = new BaseModelImplementation();
+ $newModel = $model->findOrNew(31337, ['lorem', 'ipsum']);
+
+ $this->assertEquals($anotherModel, $newModel);
+ }
}