|
|
@@ -1784,7 +1784,6 @@ class TableTest extends TestCase
|
|
|
$this->assertSame($entity, $table->save($entity));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Test that save works with replace saveStrategy and are not deleted once they are not null
|
|
|
*
|
|
|
@@ -2551,6 +2550,7 @@ class TableTest extends TestCase
|
|
|
$table->save($data);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* Tests that only the properties marked as dirty are actually saved
|
|
|
* to the database
|
|
|
@@ -6020,6 +6020,35 @@ class TableTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Tests entity clean()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testEntityClean()
|
|
|
+ {
|
|
|
+ $table = TableRegistry::get('Articles');
|
|
|
+ $validator = $table->validator()->requirePresence('body');
|
|
|
+ $entity = $table->newEntity(['title' => 'mark']);
|
|
|
+
|
|
|
+ $entity->dirty('title', true);
|
|
|
+ $entity->invalid('title', 'albert');
|
|
|
+
|
|
|
+ $this->assertNotEmpty($entity->errors());
|
|
|
+ $this->assertTrue($entity->dirty());
|
|
|
+ $this->assertEquals(['title' => 'albert'], $entity->invalid());
|
|
|
+
|
|
|
+ $entity->title = 'alex';
|
|
|
+ $this->assertSame($entity->getOriginal('title'), 'mark');
|
|
|
+
|
|
|
+ $entity->clean();
|
|
|
+
|
|
|
+ $this->assertEmpty($entity->errors());
|
|
|
+ $this->assertFalse($entity->dirty());
|
|
|
+ $this->assertEquals([], $entity->invalid());
|
|
|
+ $this->assertSame($entity->getOriginal('title'), 'alex');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Tests the loadInto() method
|
|
|
*
|
|
|
* @return void
|