Codeception / Codeception/module-mezzio

ZendExpressive module fails when trying to use DataFactory with recreateApplicationBetweenTests set to true

オープン
#7 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
PHP
スター
1
フォーク
4
PR マージ指標
30日以内にマージされた PR はありません

説明

#### What are you trying to achieve?

I'm trying to use use FactoryMuffin for tests in my Zend Expressive application. With default setting **recreateApplicationBetweenTests: true** for ZendExpressive module tests don't work. I'm getting an exception. Changing config to **recreateApplicationBetweenTests: false** helps but I need to use **recreateApplicationBetweenTests: true**.

#### What do you get instead?

```bash
php vendor/bin/codecept run tests/api/Stores/CreateViewCest.php -vvv
Codeception PHP Testing Framework v3.1.0
Powered by PHPUnit 8.3.4 by Sebastian Bergmann and contributors.
Running with seed:

[Seed] 1069952343

[Connecting To Db] {"config":{"populate":false,"cleanup":false,"reconnect":false,"waitlock":0,"dump":"tools/migration/giftcard_structure.sql","populator":null,"dsn":"mysql:host=127.0.0.1;dbname=test_giftcard_local;port=32768","user":"api_user","password":"api_user_pwd"},"options":[]}
[Db] Connected to default test_giftcard_local
PHP Fatal error: Uncaught Error: Call to a member function has() on null in /Users/local/Workspace/proj/vendor/codeception/codeception/src/Codeception/Module/ZendExpressive.php:94
Stack trace:
#0 /Users/local/Workspace/proj/vendor/codeception/codeception/src/Codeception/Module/Doctrine2.php(222): Codeception\Module\ZendExpressive->_getEntityManager()
Codeception/Codeception#1 /Users/local/Workspace/proj/vendor/codeception/codeception/src/Codeception/Module/Doctrine2.php(1011): Codeception\Module\Doctrine2->retrieveEntityManager()
Codeception/Codeception#2 /Users/local/Workspace/proj/vendor/codeception/codeception/src/Codeception/Module/DataFactory.php(178): Codeception\Module\Doctrine2->_getEntityManager()
Codeception/Codeception#3 /Users/local/Workspace/proj/vendor/codeception/codeception/src/Codeception/Module/DataFactory.php(158): Codeception\Module\DataFactory->getStore()
Codeception/Codeception#4 /Users/local/Workspace/proj/vendor/codeception/codeception/src/Codeception/Module/ZendExpressive.php on line 94
```

### Details

* Codeception version: 3.1.0
* PHP Version: 7.1.3
* Operating System: MacOS
* Installation type: Composer
* List of installed packages (`composer show`)
```
codeception/codeception 3.1.0
zendframework/zend-expressive 3.2.1
phpunit/phpunit 8.3.4
league/factory-muffin v3.0.1
```

* Suite configuration:
\Tests\Helper\Api extends \Codeception\Module\ZendExpressive

```yml
class_name: ApiTester
modules:
enabled:
- \Tests\Helper\Api
- Asserts
- Db
- REST
- DataFactory
config:
\Tests\Helper\Api:
environment_file: .env.testing
disable_exception_handling: false
run_database_seeder: false
cleanup: false
recreateApplicationBetweenTests: true
REST:
depends: \Tests\Helper\Api
part: Json
DataFactory:
factories: tests/_support/factories
depends: Doctrine2
cleanup: false
Doctrine2:
depends: \Tests\Helper\Api

```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Codeception/Module/ZendExpressive.php の94行目から始め、recreateApplicationBetweenTests が true の場合に Doctrine2 と DataFactory から呼び出される処理を追跡します。提供されている Codeception コマンドと suite 設定で再現し、その後、設定が false の場合の挙動と比較します。DataFactory の経路で null has() エラーが発生しなくなり、再作成が有効なままであれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
mysql, php
領域
backend, testing-qa
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。