Skip to content

Commit

Permalink
Fixed phpunit failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josaphatim committed Sep 2, 2023
1 parent b533fb4 commit fbf1219
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions tests/phpunit/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function test_decode_failed() {
* @runInSeparateProcess
*/
public function test_get_path() {
$this->assertEquals('./data/testuser.txt', $this->config->get_path('testuser'));
$this->assertEquals(APP_PATH.'tests/phpunit/data/testuser.txt', $this->config->get_path('testuser'));
}
/**
* @preserveGlobalState disabled
Expand Down Expand Up @@ -181,15 +181,15 @@ public function test_get_modules() {
* @runInSeparateProcess
*/
public function test_site_load() {
$config = new Hm_Site_Config_File('./data/siteconfig.rc');
$config = new Hm_Site_Config_File(APP_PATH.'tests/phpunit/data/siteconfig.rc');
$this->assertEquals(array('version' => VERSION, 'foo' => 'bar', 'default_setting_foo' => 'bar'), $config->dump());
}
/**
* @preserveGlobalState disabled
* @runInSeparateProcess
*/
public function test_get_user_defaults() {
$config = new Hm_Site_Config_File('./data/siteconfig.rc');
$config = new Hm_Site_Config_File(APP_PATH.'tests/phpunit/data/siteconfig.rc');
$this->assertEquals(array('version' => VERSION, 'foo' => 'bar', 'default_setting_foo' => 'bar'), $config->dump());
}
public function tearDown(): void {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/mocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Hm_Mock_Config {
public $mods = array();
public $user_defaults = array();
public $data = array(
'user_settings_dir' => './data',
'user_settings_dir' => APP_PATH.'tests/phpunit/data',
'default_language' => 'es',
'default_setting_inline_message' => true
);
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ public function test_run_output_modules() {
* @runInSeparateProcess
*/
public function test_run_output_module() {
require '../../modules/core/setup.php';
require '../../modules/core/modules.php';
require APP_PATH.'/modules/core/setup.php';
require APP_PATH.'/modules/core/modules.php';
$request = new Hm_Mock_Request('HTTP');
$session = new Hm_Mock_Session();
Hm_Output_Modules::add('test', 'date', false, false, false, true, 'core');
Expand All @@ -205,8 +205,8 @@ public function test_run_output_module() {
* @runInSeparateProcess
*/
public function test_run_handler_modules() {
require '../../modules/core/setup.php';
require '../../modules/core/modules.php';
require APP_PATH.'/modules/core/setup.php';
require APP_PATH.'/modules/core/modules.php';
$request = new Hm_Mock_Request('HTTP');
$session = new Hm_Mock_Session();
Hm_Handler_Modules::add('test', 'date', false, false, false, true, 'core');
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
class Hm_Test_Core_Functions extends TestCase {

public function setUp(): void {
require 'bootstrap.php';
require __DIR__.'/../../bootstrap.php';
require APP_PATH.'modules/core/modules.php';
}
/**
* @preserveGlobalState disabled
* @runInSeparateProcess
*/
public function test_interface_langs() {
$this->assertEquals(15, count(interface_langs()));
$this->assertEquals(16, count(interface_langs()));
}
/**
* @preserveGlobalState disabled
Expand Down Expand Up @@ -228,7 +228,7 @@ class Hm_Test_Core_Functions_Debug extends TestCase {

public function setUp(): void {
define('DEBUG_MODE', true);
require 'bootstrap.php';
require __DIR__.'/../../bootstrap.php';
require APP_PATH.'modules/core/modules.php';
}
/**
Expand All @@ -237,7 +237,7 @@ public function setUp(): void {
*/
public function test_get_ini_debug() {
$mock_config = new Hm_Mock_Config();
$mock_config->data['app_data_dir'] = './data';
$mock_config->data['app_data_dir'] = APP_PATH.'tests/phpunit/data';
$mock_config->data['foo.ini'] = 'bar';
$this->assertEquals(array('foo' => 'bar'), get_ini($mock_config, 'foo.ini'));
$this->assertEquals(array(), get_ini($mock_config, 'no.ini'));
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/modules/core/message_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Hm_Test_Core_Message_Functions extends TestCase {

public function setUp(): void {
require 'bootstrap.php';
require __DIR__.'/../../bootstrap.php';
require APP_PATH.'modules/core/modules.php';
}
/**
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/modules/core/message_list_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Hm_Test_Core_Message_List_Functions extends TestCase {

public function setUp(): void {
date_default_timezone_set('UTC');
require 'bootstrap.php';
require __DIR__.'/../../bootstrap.php';
require APP_PATH.'modules/core/modules.php';
}
/**
Expand Down
16 changes: 8 additions & 8 deletions tests/phpunit/modules/core/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class Hm_Test_Core_Handler_Modules extends TestCase {

public function setUp(): void {
require 'bootstrap.php';
require 'helpers.php';
require __DIR__.'/../../bootstrap.php';
require __DIR__.'/../../helpers.php';
require APP_PATH.'modules/core/modules.php';
}
/**
Expand Down Expand Up @@ -466,7 +466,7 @@ public function test_load_user_data() {
public function test_save_user_data() {
$test = new Handler_Test('save_user_data', 'core');
$res = $test->run();
$this->assertEquals(array('user_settings_dir' => './data', 'default_language' => 'es', 'default_setting_inline_message' => true), $res->session->get('user_data'));
$this->assertEquals(array('user_settings_dir' => APP_PATH.'tests/phpunit/data', 'default_language' => 'es', 'default_setting_inline_message' => true), $res->session->get('user_data'));
}
/**
* @preserveGlobalState disabled
Expand Down Expand Up @@ -567,8 +567,8 @@ public function test_process_search_terms() {
class Hm_Test_Core_Output_Modules extends TestCase {

public function setUp(): void {
require 'bootstrap.php';
require 'helpers.php';
require __DIR__.'/../../bootstrap.php';
require __DIR__.'/../../helpers.php';
require APP_PATH.'modules/core/modules.php';
}
/**
Expand Down Expand Up @@ -1110,7 +1110,7 @@ public function test_language_setting() {
$test = new Output_Test('language_setting', 'core');
$test->handler_response = array('language'=> 'en');
$res = $test->run();
$this->assertEquals(array('<tr class="general_setting"><td><label for="language">Language</label></td><td><select id="language" name="language"><option value="az">Azerbaijani</option><option value="pt-BR">Brazilian Portuguese</option><option value="nl">Dutch</option><option selected="selected" value="en">English</option><option value="et">Estonian</option><option value="fa">Farsi</option><option value="fr">French</option><option value="de">German</option><option value="hu">Hungarian</option><option value="id">Indonesian</option><option value="it">Italian</option><option value="ja">Japanese</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="es">Spanish</option></select></td></tr>'), $res->output_response);
$this->assertEquals(array('<tr class="general_setting"><td><label for="language">Language</label></td><td><select id="language" name="language"><option value="az">Azerbaijani</option><option value="pt-BR">Brazilian Portuguese</option><option value="zh-Hans">Chinese Simplified</option><option value="nl">Dutch</option><option selected="selected" value="en">English</option><option value="et">Estonian</option><option value="fa">Farsi</option><option value="fr">French</option><option value="de">German</option><option value="hu">Hungarian</option><option value="id">Indonesian</option><option value="it">Italian</option><option value="ja">Japanese</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="es">Spanish</option></select></td></tr>'), $res->output_response);
}
/**
* @preserveGlobalState disabled
Expand Down Expand Up @@ -1479,8 +1479,8 @@ public function test_message_list_end() {
class Hm_Test_Core_Output_Modules_Debug extends TestCase {
public function setUp(): void {
define('DEBUG_MODE', true);
require 'bootstrap.php';
require 'helpers.php';
require __DIR__.'/../../bootstrap.php';
require __DIR__.'/../../helpers.php';
require APP_PATH.'modules/core/modules.php';
}
/**
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/modules/imap/hm-imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Hm_Test_Hm_IMAP extends TestCase {

public function setUp(): void {
define('IMAP_TEST', true);
require 'bootstrap.php';
require __DIR__.'/../../bootstrap.php';
require APP_PATH.'modules/imap/hm-imap.php';
require APP_PATH.'modules/core/message_functions.php';
$this->create();
Expand Down

0 comments on commit fbf1219

Please sign in to comment.