Z
Z
zalatov_a2014-11-27 05:11:45
Yii
zalatov_a, 2014-11-27 05:11:45

Why does Yupe (Yii) need index-test.php?

Why is index-test.php needed, which is actually a copy of index.php minus the config file?
Maybe I don't understand the principle of this separation, but...
As for me, I would make index-test.php just an entry point, for example, to set cookies and run index.php.
For example, like this:

// -- Устанавливаем куки, чтобы определять, что сейчас мы в режиме тестирования
$_COOKIE['CODECEPTION_COOKIE'] = 1;
setcookie('CODECEPTION_COOKIE', 1);
// -- -- -- --

require_once('index.php');// Подключаем основной файл

And in index.php I will already decide which config to connect:
// -- Подключаем разные конфиги в зависимости от того, тест это или рабочая версия сайта
if (array_key_exists('CODECEPTION_COOKIE', $_COOKIE)) {
    $configFile = 'test';
} else {
    $configFile = 'main';
}
// -- -- -- --

After all, in fact, we need to test the site with the same settings with which it will be in production.
And in view of this, index.php should just be connected, because the server settings are also indicated there, for example:
if (!ini_get('date.timezone')) {...}
mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');

In addition, when working through index-test.php, /index-test.php/ is added to the beginning of the URL.
And because of this, during tests, it is not possible to find a link like href="/logout", since it contains the name of the script (showScriptName is enabled).
In general, to summarize the question ...
Is there any objective sense to duplicate the code?
Or is it just from a series of "well, it happened ..."?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gorcer, 2014-11-28
@gorcer

I believe that the logic is duplicated in index-test.php so that programmers NOT involved in tests do not get confused in the logic made for tests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question