1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +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
5 changed files with 36 additions and 15 deletions

View File

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

2
e107

Submodule e107 updated: f5f2212b54...a8d1541b9d

View File

@@ -352,6 +352,12 @@
unset($actual[$unimportant_key]); 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); $this->assertEquals($expected,$actual);
$status = $this->ep->XmlSiteLinks('uninstall',$plugVars); $status = $this->ep->XmlSiteLinks('uninstall',$plugVars);

View File

@@ -28,6 +28,7 @@
$this->fail("Couldn't load e_db_mysql object"); $this->fail("Couldn't load e_db_mysql object");
} }
define('e_LEGACY_MODE', true);
$this->db->__construct(); $this->db->__construct();
$this->loadConfig(); $this->loadConfig();
@@ -182,9 +183,11 @@
$expected = array ( $expected = array (
'dblog_title' => 'e_db_pdoTest', 'dblog_title' => 'e_db_pdoTest',
'dblog_user_id' => '1', '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() 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'); $result = $this->db->retrieve('user', 'user_id, user_name', 'user_id = 1');
$this->assertEquals($expected,$result); $this->assertEquals($expected,$result);
@@ -215,7 +218,7 @@
$this->assertEquals($expected,$result); $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); $result = $this->db->retrieve('user', 'user_id, user_name', 'user_id = 1', true);
$this->assertEquals($expected,$result); $this->assertEquals($expected,$result);
@@ -277,7 +280,10 @@
$expected = array( $expected = array(
'tmp_ip' => '127.0.0.1', 'tmp_ip' => '127.0.0.1',
'tmp_time' => '12345435', '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'); $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'); $this->assertEquals($expected, $actual, 'Inserted content doesn\'t match the retrieved content');
@@ -304,8 +310,10 @@
); );
$this->db->insert('generic', $insert); $this->db->insert('generic', $insert);
$actual = $this->db->lastInsertId(); $first = $this->db->lastInsertId();
$this->assertEquals(2,$actual); $this->db->insert('generic', $insert);
$next = $this->db->lastInsertId();
$this->assertEquals(1, $next - $first);
} }
@@ -394,7 +402,10 @@
$expected = array( $expected = array(
'tmp_ip' => '127.0.0.1', 'tmp_ip' => '127.0.0.1',
'tmp_time' => '1234568', '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"'); $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'); $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); $check = (strpos($row[1], "CREATE TABLE `e107_user`") !== false);
$this->assertTrue($check); $this->assertTrue($check);
define('e_LEGACY_MODE', true);
$this->db->select('user', '*', 'user_id = 1'); $this->db->select('user', '*', 'user_id = 1');
$row = $this->db->db_Fetch(); $row = $this->db->db_Fetch();
$this->assertEquals("e107", $row['user_name']); $this->assertEquals("e107", $row['user_name']);
@@ -770,8 +780,13 @@
public function testDb_CopyRow() public function testDb_CopyRow()
{ {
$result = $this->db->db_CopyRow('news', '*', "news_id = 1"); $count_args = ['news', '(*)', ''];
$this->assertEquals(2,$result); $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() public function testDb_CopyTable()

View File

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