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

Increased reliability of unit tests running in shuffle mode

Which means decreasing the dependence of tests on the results of
previous tests

In codeception.yml, settings.shuffle = true
This commit is contained in:
Deltik 2019-02-12 23:52:40 -06:00
parent c9d9c71835
commit a82ffc4adb
No known key found for this signature in database
GPG Key ID: 1167C5F9C9897637
5 changed files with 36 additions and 15 deletions

View File

@ -6,6 +6,7 @@ paths:
envs: tests/_envs
actor_suffix: Tester
settings:
shuffle: true
bootstrap: _bootstrap.php
coverage:
enabled: true

2
e107

@ -1 +1 @@
Subproject commit f5f2212b54af8c0c82b464891bee93cc1c2e0b29
Subproject commit a8d1541b9d059437d7a98cf1c3b652b879ebb7ca

View File

@ -352,6 +352,12 @@
unset($actual[$unimportant_key]);
}
// Filter out cruft from e_LEGACY_MODE database output
foreach ($actual as $key => $value)
{
if (is_int($key)) unset($actual[$key]);
}
$this->assertEquals($expected,$actual);
$status = $this->ep->XmlSiteLinks('uninstall',$plugVars);

View File

@ -28,6 +28,7 @@
$this->fail("Couldn't load e_db_mysql object");
}
define('e_LEGACY_MODE', true);
$this->db->__construct();
$this->loadConfig();
@ -180,11 +181,13 @@
$data = $this->db->retrieve('dblog','dblog_title, dblog_user_id', "dblog_type = ".$log_type. " AND dblog_title = '".$remark ."' ");
$expected = array (
'dblog_title' => 'e_db_pdoTest',
'dblog_user_id' => '1',
'dblog_title' => 'e_db_pdoTest',
'dblog_user_id' => '1',
0 => 'e_db_pdoTest',
1 => '1'
);
$this->assertEquals($data, $expected);
$this->assertEquals($expected, $data);
}
@ -205,7 +208,7 @@
public function testRetrieve()
{
$expected = array ('user_id' => '1', 'user_name' => 'e107', );
$expected = array ('user_id' => '1', 'user_name' => 'e107', 0 => '1', 1 => 'e107');
$result = $this->db->retrieve('user', 'user_id, user_name', 'user_id = 1');
$this->assertEquals($expected,$result);
@ -215,7 +218,7 @@
$this->assertEquals($expected,$result);
$expected = array ( 0 => array ( 'user_id' => '1', 'user_name' => 'e107', ),);
$expected = array ( 0 => array ( 'user_id' => '1', 'user_name' => 'e107', 0 => '1', 1 => 'e107'),);
$result = $this->db->retrieve('user', 'user_id, user_name', 'user_id = 1', true);
$this->assertEquals($expected,$result);
@ -277,7 +280,10 @@
$expected = array(
'tmp_ip' => '127.0.0.1',
'tmp_time' => '12345435',
'tmp_info' => 'Insert test'
'tmp_info' => 'Insert test',
0 => '127.0.0.1',
1 => '12345435',
2 => 'Insert test'
);
$actual = $this->db->retrieve('tmp', '*','tmp_ip = "127.0.0.1" AND tmp_time = 12345435');
$this->assertEquals($expected, $actual, 'Inserted content doesn\'t match the retrieved content');
@ -304,8 +310,10 @@
);
$this->db->insert('generic', $insert);
$actual = $this->db->lastInsertId();
$this->assertEquals(2,$actual);
$first = $this->db->lastInsertId();
$this->db->insert('generic', $insert);
$next = $this->db->lastInsertId();
$this->assertEquals(1, $next - $first);
}
@ -394,7 +402,10 @@
$expected = array(
'tmp_ip' => '127.0.0.1',
'tmp_time' => '1234568',
'tmp_info' => 'Update test 3'
'tmp_info' => 'Update test 3',
0 => '127.0.0.1',
1 => '1234568',
2 => 'Update test 3'
);
$actual = $this->db->retrieve('tmp', '*','tmp_ip = "127.0.0.1"');
$this->assertEquals($expected, $actual, 'Test 4: Updated content doesn\'t match the retrieved content');
@ -500,7 +511,6 @@
$check = (strpos($row[1], "CREATE TABLE `e107_user`") !== false);
$this->assertTrue($check);
define('e_LEGACY_MODE', true);
$this->db->select('user', '*', 'user_id = 1');
$row = $this->db->db_Fetch();
$this->assertEquals("e107", $row['user_name']);
@ -770,8 +780,13 @@
public function testDb_CopyRow()
{
$result = $this->db->db_CopyRow('news', '*', "news_id = 1");
$this->assertEquals(2,$result);
$count_args = ['news', '(*)', ''];
$copy_args = ['news', '*', 'news_id = 1'];
$initial_count = $this->db->count(...$count_args);
$this->db->db_CopyRow(...$copy_args);
$next_count = $this->db->count(...$count_args);
$this->assertEquals(1, $next_count - $initial_count);
}
public function testDb_CopyTable()

View File

@ -30,7 +30,7 @@
$this->fail("Couldn't load e_db_pdo object");
}
define('e_LEGACY_MODE', true);
$this->db->__construct();
$this->loadConfig();
@ -527,7 +527,6 @@
$check = (strpos($row[1], "CREATE TABLE `e107_user`") !== false);
$this->assertTrue($check);
define('e_LEGACY_MODE', true);
$this->db->select('user', '*', 'user_id = 1');
$row = $this->db->db_Fetch();
$this->assertEquals("e107", $row['user_name']);