Closed bscheshirwork closed 2 years ago
Why not using transactions?
Or do you mean that you want to turn it off via config but you can not?
Why not using transactions?
Acceptance browser (in my cese it is a Selenium) (i.e. app who running from browser) use another connection to db; I am right?
What do you mean by another? Do you have multiple connections?
Someone like "another instance of connection handler". Another process. Another (separated) request. (in my case - another container, another php :smile_cat: )
Use same(common) db connection settings for connect. Use same(common) code for create connection;
I don't get it :(
@samdark в разных приложениях -
тестовом, которое подключается к коду через коннектор (в вендорах или phar) src/Codeception/Lib/Connector/Yii2.php
модуля
и том, которое запускает сервер по запросу от эмулятора браузера (точка входа frontend/web/index-test.php
)
соединения к базе yii2\db\Connection::$pdo
, естественно, не один экземпляр класса PHP PDO
. Соответственно и естественно, транзакция не имеет смысла - происходящее в транзакции никак не скажется на тестируемой базе.
Учитывая скрытую магию задания этого параметра, в случае если он не указан, https://github.com/Codeception/Codeception/blob/b1d96dad56bb3dbc5185d7dcb7913db441c121b6/src/Codeception/Module/Yii2.php#L156-L158 создаётся путаница.
А, вот оно что... да, это будут два разных соединения и да, это не сразу очевидно. Что предлагаете сделать? Изменить умолчание совсем или изменить его только для этого типа тестов?
@DavertMik думаю, без тебя не обойдёмся...
Думаю, идеально зашла бы проверка на текущего тестера
class_name: AcceptanceTester
либо же осветить этот момент в документации поподробнее и объяснить всем и каждому, как задавать эту пару параметров для случая acceptance.suite.yml
:
class_name: AcceptanceTester
modules:
enabled:
- Yii2:
cleanup: true
transaction: false
и в чём её смысл.
С учётом того, что ещё встречаются проблемы с историческим _before
, это будет не лишним
Вот даже не знаю, что лучше...
usage depends of config
Yes, you are right usage depends on config There is no magical guessing which type of tests you run now. You have configuration and you are free to use it the way you like it.
What we can probably do is to provide an example config with transaction: false
for acceptance tests, or throw warnings if WebDriver
module is located.
Both ideas are good to implement.
Внесите, пожалуйста, правки в документ http://codeception.com/for/yii в связи с изменениями.
What we can probably do is to provide an example config with transaction: false for acceptance tests, or throw warnings if WebDriver module is located.
Alternatively we could split the module into several smaller modules.
Then we could have a Yii2Transaction
module that depends on Yii2
and conflicts with WebDriver
.
What are you trying to achieve?
don't use transaction mechanism in Acceptance tests
What do you get instead?
usage depends of config https://github.com/Codeception/Codeception/blob/b1d96dad56bb3dbc5185d7dcb7913db441c121b6/src/Codeception/Module/Yii2.php#L156-L158 https://github.com/Codeception/Codeception/blob/b1d96dad56bb3dbc5185d7dcb7913db441c121b6/src/Codeception/Module/Yii2.php#L194-L200
Details
composer show
)