1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-14 09:32:17 +02:00

Added additional assertion in testDelete()

This commit is contained in:
Achim Ennenbach 2019-02-08 21:45:01 +01:00
parent 964eef125e
commit 77a2ae1092

View File

@ -378,8 +378,15 @@
public function testDelete()
{
// make sure the table is empty
// table may contain data, so number of deleted records is unknown,
// but should always be >= 0
$actual = $this->db->delete('tmp');
$this->assertNotEmpty($actual, 'Unable to empty the table.');
$this->assertGreaterThanOrEqual(0, $actual, 'Unable to empty the table.');
// 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}");
// Insert some records
$this->db->insert('tmp', array('tmp_ip' => '127.0.0.1', 'tmp_time' => time(), 'tmp_info' => 'Delete test 1'));
@ -396,11 +403,21 @@
$actual = $this->db->delete('tmp', 'tmp_ip="127.0.0.1"');
$this->assertEquals($expected, $actual, 'Unable to delete 1 records.');
// 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}");
// Delete all remaining (2) records
$expected = 2;
$actual = $this->db->delete('tmp');
$this->assertEquals($expected, $actual, 'Unable to delete the remaining records.');
// 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}");
// Delete from an table that doesn't exist
$actual = $this->db->delete('tmp_unknown_table');
$this->assertFalse($actual, 'Trying to delete records from an invalid table should return FALSE!');