/** * testValidateFirstWithDefaults method * * return @void */ public function testFirstWithDefaults() { $this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag'); $TestModel = new Article(); $result = $TestModel->find('first', array('conditions' => array('Article.id' => 1))); $expected = array('Article' => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23')); unset($result['Article']['updated']); $this->assertEquals($expected['Article'], $result['Article']); $data = array('Article' => array('id' => 1, 'title' => 'First Article (modified)'), 'Comment' => array(array('comment' => 'Article comment', 'user_id' => 1))); $result = $TestModel->saveAll($data, array('validate' => 'first')); $this->assertTrue($result); $result = $TestModel->find('first', array('conditions' => array('Article.id' => 1))); $expected['Article']['title'] = 'First Article (modified)'; unset($result['Article']['updated']); $this->assertEquals($expected['Article'], $result['Article']); }
/** * test that saveAll behaves like plain save() when supplied empty data * * @link https://cakephp.lighthouseapp.com/projects/42648/tickets/277-test-saveall-with-validation-returns-incorrect-boolean-when-saving-empty-data * @return void */ public function testSaveAllEmptyData() { $this->skipIf($this->db instanceof Sqlserver, 'This test is not compatible with SQL Server.'); $this->loadFixtures('Article', 'ProductUpdateAll', 'Comment', 'Attachment'); $model = new Article(); $result = $model->saveAll(array(), array('validate' => 'first')); $this->assertFalse(empty($result)); $model = new ProductUpdateAll(); $result = $model->saveAll(); $this->assertFalse($result); }
/** * test that saveAll behaves like plain save() when suplied empty data * * @link http://cakephp.lighthouseapp.com/projects/42648/tickets/277-test-saveall-with-validation-returns-incorrect-boolean-when-saving-empty-data * @access public * @return void */ function testSaveAllEmptyData() { $this->loadFixtures('Article', 'ProductUpdateAll', 'Comment', 'Attachment'); $model = new Article(); $result = $model->saveAll(array(), array('validate' => 'first')); $this->assertFalse(empty($result)); $model = new ProductUpdateAll(); $result = $model->saveAll(array()); $this->assertFalse($result); }