示例#1
0
 /**
  * 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('Boat', 'ProductUpdateAll', 'Comment', 'Attachment');
     $model = new Boat();
     $result = $model->saveAll(array(), array('validate' => 'first'));
     $this->assertFalse(empty($result));
     $model = new ProductUpdateAll();
     $result = $model->saveAll();
     $this->assertFalse($result);
 }
示例#2
0
 /**
  * testValidateFirstWithDefaults method
  *
  * @return void
  */
 public function testFirstWithDefaults()
 {
     $this->loadFixtures('Boat', 'Tag', 'Comment', 'User', 'boatsTag');
     $TestModel = new Boat();
     $result = $TestModel->find('first', array('conditions' => array('Boat.id' => 1)));
     $expected = array('Boat' => array('id' => 1, 'user_id' => 1, 'title' => 'First Boat', 'body' => 'First Boat Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23'));
     unset($result['Boat']['updated']);
     $this->assertEquals($expected['Boat'], $result['Boat']);
     $data = array('Boat' => array('id' => 1, 'title' => 'First Boat (modified)'), 'Comment' => array(array('comment' => 'Boat comment', 'user_id' => 1)));
     $result = $TestModel->saveAll($data, array('validate' => 'first'));
     $this->assertTrue($result);
     $result = $TestModel->find('first', array('conditions' => array('Boat.id' => 1)));
     $expected['Boat']['title'] = 'First Boat (modified)';
     unset($result['Boat']['updated']);
     $this->assertEquals($expected['Boat'], $result['Boat']);
 }