mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
Extra tests for copyRow on tables with unique fields.
This commit is contained in:
@@ -226,6 +226,11 @@
|
|||||||
$result = $res->fetch();
|
$result = $res->fetch();
|
||||||
$this->assertEquals('email@address.com', $result['user_email']);
|
$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);
|
$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()
|
public function testInsert()
|
||||||
@@ -887,6 +907,16 @@
|
|||||||
$result = $this->db->db_CopyRow('news', null);
|
$result = $this->db->db_CopyRow('news', null);
|
||||||
$this->assertFalse($result);
|
$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()
|
public function testDb_CopyTable()
|
||||||
|
Reference in New Issue
Block a user