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

未关闭
#7 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
mysql, php

调研方向

从 Codeception/Module/ZendExpressive.php 第 94 行开始,跟踪 recreateApplicationBetweenTests 为 true 时来自 Doctrine2 和 DataFactory 的调用。使用提供的 Codeception 命令和 suite 配置重现,然后将行为与设置为 false 时的行为进行比较。当 DataFactory 路径不再引发 null has() 错误,同时重建仍保持启用时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

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?
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
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

主要语言
PHP
星标
1
派生
4
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Codeception/module-mezzio 的其他 Issue

查看 Codeception/module-mezzio 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。