diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-16 12:06:18 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-16 12:06:18 +0200 |
commit | 0734807eef5a6b638b06d57aef6ee59ac78a3456 (patch) | |
tree | 3af73fdc293ab18962078c1a92e07d803009f1f5 /tests/Unit | |
parent | d0abc27c079f058c40a74b89e54bd21ba4aad53e (diff) | |
parent | ac48332166ce28fcb1a2fc130c7f5adbc760e42d (diff) |
Merge remote-tracking branch 'MyIgel/logentry-model'
Diffstat (limited to 'tests/Unit')
-rw-r--r-- | tests/Unit/Logger/LoggerServiceProviderTest.php | 1 | ||||
-rw-r--r-- | tests/Unit/Models/BaseModelTest.php | 22 | ||||
-rw-r--r-- | tests/Unit/Models/Stub/BaseModelImplementation.php | 27 |
3 files changed, 50 insertions, 0 deletions
diff --git a/tests/Unit/Logger/LoggerServiceProviderTest.php b/tests/Unit/Logger/LoggerServiceProviderTest.php index cef95d5b..aef0b7d1 100644 --- a/tests/Unit/Logger/LoggerServiceProviderTest.php +++ b/tests/Unit/Logger/LoggerServiceProviderTest.php @@ -17,6 +17,7 @@ class LoggerServiceProviderTest extends ServiceProviderTest { /** @var PHPUnit_Framework_MockObject_MockObject|EngelsystemLogger $logger */ $logger = $this->getMockBuilder(EngelsystemLogger::class) + ->disableOriginalConstructor() ->getMock(); $app = $this->getApp(['make', 'instance', 'bind']); 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; + } +} |