1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-05 05:02:44 +02:00

Extra tests for copyRow on tables with unique fields.

This commit is contained in:
Cameron 2019-02-16 12:52:07 -08:00
parent 76924393b8
commit de6cb22225
2 changed files with 31 additions and 1 deletions

View File

@ -255,7 +255,7 @@
$data = $this->dateObj->terms($input);
$this->assertEquals($expected, $data[2]);
}
}

View File

@ -226,6 +226,11 @@
$result = $res->fetch();
$this->assertEquals('email@address.com', $result['user_email']);
// duplicate unique field 'media_cat_category', should return false/error.
$result = $this->db->db_Query("INSERT INTO ".MPREFIX."core_media_cat(media_cat_owner,media_cat_title,media_cat_category,media_cat_sef,media_cat_diz,media_cat_class,media_cat_image,media_cat_order) SELECT media_cat_owner,media_cat_title,media_cat_category,media_cat_sef,media_cat_diz,media_cat_class,media_cat_image,media_cat_order FROM ".MPREFIX."core_media_cat WHERE media_cat_id = 1");
$err = $this->db->getLastErrorText();
$this->assertFalse($result, $err);
}
@ -335,6 +340,21 @@
);
$this->assertEquals(1,$result);
$qry = "INSERT INTO #core_media_cat(media_cat_owner,media_cat_title,media_cat_sef,media_cat_diz,media_cat_class,media_cat_image,media_cat_order) SELECT media_cat_owner,media_cat_title,media_cat_sef,media_cat_diz,media_cat_class,media_cat_image,media_cat_order FROM #core_media_cat WHERE media_cat_id = 1";
$result = $this->db->db_Select_gen($qry);
$qry = "INSERT INTO #core_media_cat(media_cat_owner,media_cat_title,media_cat_sef,media_cat_diz,media_cat_class,media_cat_image,media_cat_order) SELECT media_cat_owner,media_cat_title,media_cat_sef,media_cat_diz,media_cat_class,media_cat_image,media_cat_order FROM #core_media_cat WHERE media_cat_id = 1";
$result = $this->db->db_Select_gen($qry);
$this->assertFalse($result);
// $error = $this->db->getLastErrorText();
$result = $this->db->db_Query("INSERT INTO ".MPREFIX."core_media_cat(media_cat_owner,media_cat_title,media_cat_category,media_cat_sef,media_cat_diz,media_cat_class,media_cat_image,media_cat_order) SELECT media_cat_owner,media_cat_title,media_cat_category,media_cat_sef,media_cat_diz,media_cat_class,media_cat_image,media_cat_order FROM ".MPREFIX."core_media_cat WHERE media_cat_id = 1");
$err = $this->db->getLastErrorText();
$this->assertFalse($result);
}
public function testInsert()
@ -887,6 +907,16 @@
$result = $this->db->db_CopyRow('news', null);
$this->assertFalse($result);
// test with table that has unique keys.
$result = $this->db->db_CopyRow('core_media_cat', '*', "media_cat_id = 1");
$qry = $this->db->getLastErrorText();
$this->assertGreaterThan(1,$result, $qry);
// test with table that has unique keys. (same row again) - make sure copyRow duplicates it regardless.
$result = $this->db->db_CopyRow('core_media_cat', '*', "media_cat_id = 1");
$qry = $this->db->getLastErrorText();
$this->assertGreaterThan(1,$result, $qry);
}
public function testDb_CopyTable()