From 7ce97314b0ec74cdce49067d692625740af4a594 Mon Sep 17 00:00:00 2001 From: MGatner Date: Tue, 7 May 2019 13:07:25 -0400 Subject: [PATCH 1/2] Add test for partial Entity insertion --- tests/system/Database/Live/ModelTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/system/Database/Live/ModelTest.php b/tests/system/Database/Live/ModelTest.php index 8e7dd1002aa7..37c26c5f67ca 100644 --- a/tests/system/Database/Live/ModelTest.php +++ b/tests/system/Database/Live/ModelTest.php @@ -1461,6 +1461,29 @@ public function testGetValidationMessagesForReplace() //-------------------------------------------------------------------- + public function testSaveNewEntityWithPartialData() + { + $entity = new class extends Entity + { + protected $id; + protected $name; + protected $email; + protected $country; + protected $deleted; + }; + $testModel = new UserModel(); + + $entity->email = 'jerome@example.com'; + $entity->deleted = 0; + $entity->created_at = new Time('now'); + + $this->expectException('\CodeIgniter\Database\Exceptions\DatabaseException'); + + $this->assertTrue($testModel->save($entity)); + } + + //-------------------------------------------------------------------- + public function testSaveNewEntityWithDateTime() { $entity = new class extends Entity{ From 8a018f854de8a1f76db93b4c154c0f6a0c35c101 Mon Sep 17 00:00:00 2001 From: MGatner Date: Tue, 7 May 2019 13:27:06 -0400 Subject: [PATCH 2/2] Remove exception expectation --- tests/system/Database/Live/ModelTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/system/Database/Live/ModelTest.php b/tests/system/Database/Live/ModelTest.php index 37c26c5f67ca..09f8b3e488f4 100644 --- a/tests/system/Database/Live/ModelTest.php +++ b/tests/system/Database/Live/ModelTest.php @@ -1477,8 +1477,6 @@ public function testSaveNewEntityWithPartialData() $entity->deleted = 0; $entity->created_at = new Time('now'); - $this->expectException('\CodeIgniter\Database\Exceptions\DatabaseException'); - $this->assertTrue($testModel->save($entity)); }