Skip to content

Commit 03b7e7e

Browse files
committed
Fix test case
1 parent 8d99b0b commit 03b7e7e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Model/Behavior/InsertBehavior.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function bulkInsert(array $entities)
5757
}
5858

5959
/**
60-
* execute insert select query for saving a record at once
60+
* execute insert select query for saving a record just once
6161
*
6262
* @param Entity $entity insert entity
6363
* @param array|null $conditions search conditions
@@ -67,6 +67,12 @@ public function insertOnce(Entity $entity, array $conditions = null)
6767
{
6868
if ($this->_config['event']['beforeSave']) {
6969
$this->_table->dispatchEvent('Model.beforeSave', compact('entity'));
70+
if ($entity->created) {
71+
$entity->created= $entity->created->toDateString();
72+
}
73+
if ($entity->modified) {
74+
$entity->modified= $entity->modified->toDateString();
75+
}
7076
}
7177

7278
$entity->setVirtual([]);

tests/TestCase/Model/Behavior/InsertBehaviorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ public function testInsertOnceWhenIsNull()
240240

241241
$actual = $this->Articles
242242
->find()
243-
->where($newData)
243+
->where( [
244+
'title' => 'First Article',
245+
'body IS' => null,
246+
'published' => 1
247+
])
244248
->all();
245249

246250
$this->assertCount(1, $actual, 'fail insert once.');

0 commit comments

Comments
 (0)