From 88de0070a760fb13beb44ffcaf99bdba101ce5bf Mon Sep 17 00:00:00 2001 From: Kiran Parajuli Date: Tue, 27 Dec 2022 16:11:23 +0545 Subject: [PATCH] Only define bootstrap constants for local api tests, skip for other tests run Signed-off-by: Kiran Parajuli --- .../features/bootstrap/bootstrap.php | 62 +++++++++++++++---- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/tests/acceptance/features/bootstrap/bootstrap.php b/tests/acceptance/features/bootstrap/bootstrap.php index b6e18a60e..c5a649912 100644 --- a/tests/acceptance/features/bootstrap/bootstrap.php +++ b/tests/acceptance/features/bootstrap/bootstrap.php @@ -1,4 +1,5 @@ addPsr4("TestHelpers\\", __DIR__ . "/../../../TestHelpers", true); $classLoader->register(); +// while running for the local api tests, the tests code form ownCloud/core is not used +// so we need the constants to be defined for the tests to use them, but for the case where, +// the tests are running for core api tests, the constants are already defined in the core bootstrap.php +// so we do not declare them again to avoid the "already defined" error // Sleep for 10 milliseconds -const STANDARD_SLEEP_TIME_MILLISEC = 10; -const STANDARD_SLEEP_TIME_MICROSEC = STANDARD_SLEEP_TIME_MILLISEC * 1000; + +if (!\defined('STANDARD_SLEEP_TIME_MILLISEC')) { + \define('STANDARD_SLEEP_TIME_MILLISEC', 10); +} + +if (!\defined('STANDARD_SLEEP_TIME_MICROSEC')) { + \define('STANDARD_SLEEP_TIME_MICROSEC', STANDARD_SLEEP_TIME_MILLISEC * 1000); +} // Long timeout for use in code that needs to wait for known slow UI -const LONG_UI_WAIT_TIMEOUT_MILLISEC = 60000; +if (!\defined('LONG_UI_WAIT_TIMEOUT_MILLISEC')) { + \define('LONG_UI_WAIT_TIMEOUT_MILLISEC', 60000); +} + // Default timeout for use in code that needs to wait for the UI -const STANDARD_UI_WAIT_TIMEOUT_MILLISEC = 10000; +if (!\defined('STANDARD_UI_WAIT_TIMEOUT_MILLISEC')) { + \define('STANDARD_UI_WAIT_TIMEOUT_MILLISEC', 10000); +} + // Minimum timeout for use in code that needs to wait for the UI -const MINIMUM_UI_WAIT_TIMEOUT_MILLISEC = 500; -const MINIMUM_UI_WAIT_TIMEOUT_MICROSEC = MINIMUM_UI_WAIT_TIMEOUT_MILLISEC * 1000; +if (!\defined('MINIMUM_UI_WAIT_TIMEOUT_MILLISEC')) { + \define('MINIMUM_UI_WAIT_TIMEOUT_MILLISEC', 500); +} + +if (!\defined('MINIMUM_UI_WAIT_TIMEOUT_MICROSEC')) { + \define('MINIMUM_UI_WAIT_TIMEOUT_MICROSEC', MINIMUM_UI_WAIT_TIMEOUT_MILLISEC * 1000); +} // Minimum timeout for emails -const EMAIL_WAIT_TIMEOUT_SEC = 10; -const EMAIL_WAIT_TIMEOUT_MILLISEC = EMAIL_WAIT_TIMEOUT_SEC * 1000; +if (!\defined('EMAIL_WAIT_TIMEOUT_SEC')) { + \define('EMAIL_WAIT_TIMEOUT_SEC', 10); +} +if (!\defined('EMAIL_WAIT_TIMEOUT_MILLISEC')) { + \define('EMAIL_WAIT_TIMEOUT_MILLISEC', EMAIL_WAIT_TIMEOUT_SEC * 1000); +} // Default number of times to retry where retries are useful -const STANDARD_RETRY_COUNT = 5; +if (!\defined('STANDARD_RETRY_COUNT')) { + \define('STANDARD_RETRY_COUNT', 5); +} // Minimum number of times to retry where retries are useful -const MINIMUM_RETRY_COUNT = 2; +if (!\defined('MINIMUM_RETRY_COUNT')) { + \define('MINIMUM_RETRY_COUNT', 2); +} // The remote server-under-test might or might not happen to have this directory. // If it does not exist, then the tests may end up creating it. -const ACCEPTANCE_TEST_DIR_ON_REMOTE_SERVER = "tests/acceptance"; +if (!\defined('ACCEPTANCE_TEST_DIR_ON_REMOTE_SERVER')) { + \define('ACCEPTANCE_TEST_DIR_ON_REMOTE_SERVER', 'tests/acceptance'); +} // The following directory should NOT already exist on the remote server-under-test. // Acceptance tests are free to do anything needed in this directory, and to // delete it during or at the end of testing. -const TEMPORARY_STORAGE_DIR_ON_REMOTE_SERVER = ACCEPTANCE_TEST_DIR_ON_REMOTE_SERVER . "/server_tmp"; +if (!\defined('TEMPORARY_STORAGE_DIR_ON_REMOTE_SERVER')) { + \define('TEMPORARY_STORAGE_DIR_ON_REMOTE_SERVER', ACCEPTANCE_TEST_DIR_ON_REMOTE_SERVER . '/server_tmp'); +} // The following directory is created, used, and deleted by tests that need to // use some "local external storage" on the server. -const LOCAL_STORAGE_DIR_ON_REMOTE_SERVER = TEMPORARY_STORAGE_DIR_ON_REMOTE_SERVER . "/local_storage"; +if (!\defined('LOCAL_STORAGE_DIR_ON_REMOTE_SERVER')) { + \define('LOCAL_STORAGE_DIR_ON_REMOTE_SERVER', TEMPORARY_STORAGE_DIR_ON_REMOTE_SERVER . '/local_storage'); +}