summaryrefslogtreecommitdiff
path: root/tests/Unit/Models/BaseModelTest.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-09-25 17:29:15 +0200
committermsquare <msquare@notrademark.de>2018-10-30 21:13:56 +0100
commitc4867811e26bc32798ba24dd701bc2c35d49b027 (patch)
tree18f89f31c47ec378e5dd11600ae7aba79bcc09e5 /tests/Unit/Models/BaseModelTest.php
parentc9afc27ab9ea62269967df14a80581ed51ba6c71 (diff)
BaseModel: Added findOrNew
Diffstat (limited to 'tests/Unit/Models/BaseModelTest.php')
-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);
+ }
}