mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 17:14:42 +02:00
PHP 5.6 fixes for e_db_mysql
- FIX: Don't redefine MYSQL_* constants in e_db_pdo_class.php - FIX: e_db_mysql::rowCount() could try to use mysql_num_rows() to count rows of a non-resource - FIX: e_db_mysql::delete() stores the number of deleted rows in e_db_mysql::$mySQLrows - FIX: e_db_abstractTest::testDb_Query() was fetching in PDO mode but shouldn't have been - FIX: Typos in e_db_abstractTest::testDelete() - MOD: Moved PDO-exclusive testBackup() from e_db_abstractTest to e_db_pdoTest - FIX: e_db_mysqlTest now works in PHP 5.6 if the main e_db instance was in PDO mode but the test class initializes in legacy mode - MOD: e_db_mysqlTest now asserts that PDO mode is not in use - FIX: e_db_mysqlTest::testGetServerInfo() should now actually get a version number - FIX: e_db_mysqlTest::testGetLastErrorNumber() has a different error code compared to PDO - FIX: e_db_mysqlTest::testEscape() should actually get something from mysql_real_escape_string()
This commit is contained in:
@@ -200,8 +200,8 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
||||
$userp = "3, 'Display Name', 'Username', '', 'password-hash', '', 'email@address.com', '', '', 0, ".time().", 0, 0, 0, 0, 0, '127.0.0.1', 0, '', 0, 1, '', '', '0', '', ".time().", ''";
|
||||
$this->db->db_Query("REPLACE INTO ".MPREFIX."user VALUES ({$userp})" );
|
||||
|
||||
$res = $this->db->db_Query("SELECT user_email FROM ".MPREFIX."user WHERE user_id = 3");
|
||||
$result = $res->fetch();
|
||||
$this->db->db_Query("SELECT user_email FROM ".MPREFIX."user WHERE user_id = 3");
|
||||
$result = $this->db->fetch();
|
||||
$this->assertEquals('email@address.com', $result['user_email']);
|
||||
|
||||
// duplicate unique field 'media_cat_category', should return false/error.
|
||||
@@ -656,7 +656,7 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
||||
// Check if the returned value is equal to the number of affected records
|
||||
$expected = $actual;
|
||||
$actual = $this->db->rowCount();
|
||||
$this->assertEquals($expected, $actual, "Number of deleted records is wrong ({$expected} != {$actual}");
|
||||
$this->assertEquals($expected, $actual, "Number of deleted records is wrong ({$expected} != {$actual})");
|
||||
|
||||
// Insert some records
|
||||
$this->db->insert('tmp', array('tmp_ip' => '127.0.0.1', 'tmp_time' => time(), 'tmp_info' => 'Delete test 1'));
|
||||
@@ -666,7 +666,7 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
||||
// Count records
|
||||
$expected = 3;
|
||||
$actual = $this->db->count('tmp');
|
||||
$this->assertEquals($expected, $actual, "Number of inserted records is wrong ({$expected} != {$actual}");
|
||||
$this->assertEquals($expected, $actual, "Number of inserted records is wrong ({$expected} != {$actual})");
|
||||
|
||||
// Delete 1 record
|
||||
$expected = 1;
|
||||
@@ -676,7 +676,7 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
||||
// Check if the returned value is equal to the number of affected records
|
||||
$expected = $actual;
|
||||
$actual = $this->db->rowCount();
|
||||
$this->assertEquals($expected, $actual, "Number of deleted records is wrong ({$expected} != {$actual}");
|
||||
$this->assertEquals($expected, $actual, "Number of deleted records is wrong ({$expected} != {$actual})");
|
||||
|
||||
// Delete all remaining (2) records
|
||||
$expected = 2;
|
||||
@@ -686,7 +686,7 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
||||
// Check if the returned value is equal to the number of affected records
|
||||
$expected = $actual;
|
||||
$actual = $this->db->rowCount();
|
||||
$this->assertEquals($expected, $actual, "Number of deleted records is wrong ({$expected} != {$actual}");
|
||||
$this->assertEquals($expected, $actual, "Number of deleted records is wrong ({$expected} != {$actual})");
|
||||
|
||||
// Delete from an table that doesn't exist
|
||||
$actual = $this->db->delete('tmp_unknown_table');
|
||||
@@ -819,11 +819,8 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
||||
|
||||
$result = $this->db->escape("Can't", true);
|
||||
$this->assertEquals("Can't", $result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testDb_Table_exists()
|
||||
{
|
||||
$result = $this->db->db_Table_exists('plugin');
|
||||
@@ -923,43 +920,6 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
||||
}
|
||||
|
||||
|
||||
public function testBackup()
|
||||
{
|
||||
$opts = array(
|
||||
'gzip' => false,
|
||||
'nologs' => false,
|
||||
'droptable' => false,
|
||||
);
|
||||
|
||||
$result = $this->db->backup('user,core_media_cat', null, $opts);
|
||||
$uncompressedSize = filesize($result);
|
||||
|
||||
$tmp = file_get_contents($result);
|
||||
|
||||
$this->assertStringNotContainsString("DROP TABLE IF EXISTS `e107_user`;", $tmp);
|
||||
$this->assertStringContainsString("CREATE TABLE `e107_user` (", $tmp);
|
||||
$this->assertStringContainsString("INSERT INTO `e107_user` VALUES (1", $tmp);
|
||||
$this->assertStringContainsString("CREATE TABLE `e107_core_media_cat`", $tmp);
|
||||
|
||||
$result = $this->db->backup('*', null, $opts);
|
||||
$size = filesize($result);
|
||||
$this->assertGreaterThan(100000,$size);
|
||||
|
||||
$opts = array(
|
||||
'gzip' => true,
|
||||
'nologs' => false,
|
||||
'droptable' => false,
|
||||
);
|
||||
|
||||
$result = $this->db->backup('user,core_media_cat', null, $opts);
|
||||
$compressedSize = filesize($result);
|
||||
$this->assertLessThan($uncompressedSize, $compressedSize);
|
||||
|
||||
$result = $this->db->backup('missing_table', null, $opts);
|
||||
$this->assertFalse($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testGetLanguage()
|
||||
{
|
||||
@@ -982,7 +942,6 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
||||
$this->db->select('doesnt_exists');
|
||||
$result = $this->db->getLastErrorNumber();
|
||||
$this->assertEquals("42S02", $result);
|
||||
|
||||
}
|
||||
|
||||
public function testGetLastErrorText()
|
||||
|
Reference in New Issue
Block a user