|
|
@@ -3537,19 +3537,23 @@ class TableTest extends \Cake\TestSuite\TestCase {
|
|
|
*/
|
|
|
public function testFindOrCreate() {
|
|
|
$articles = TableRegistry::get('Articles');
|
|
|
+
|
|
|
$article = $articles->findOrCreate(['title' => 'Not there'], function ($article) {
|
|
|
$article->body = 'New body';
|
|
|
});
|
|
|
-
|
|
|
$this->assertFalse($article->isNew());
|
|
|
$this->assertNotNull($article->id);
|
|
|
$this->assertEquals('Not there', $article->title);
|
|
|
$this->assertEquals('New body', $article->body);
|
|
|
|
|
|
+ $article = $articles->findOrCreate(['title' => 'Not there']);
|
|
|
+ $this->assertFalse($article->isNew());
|
|
|
+ $this->assertNotNull($article->id);
|
|
|
+ $this->assertEquals('Not there', $article->title);
|
|
|
+
|
|
|
$article = $articles->findOrCreate(['title' => 'First Article'], function ($article) {
|
|
|
$this->fail('Should not be called for existing entities.');
|
|
|
});
|
|
|
-
|
|
|
$this->assertFalse($article->isNew());
|
|
|
$this->assertNotNull($article->id);
|
|
|
$this->assertEquals('First Article', $article->title);
|