对该成员函数connection()的代码接收调用为null

时间:2018-11-13 15:04:09

标签: eloquent lumen codeception php-7.2

我正在尝试将代码接收设置为在测试期间使用sqlite数据库,但是我遇到了以下错误提示。我试图包括bootstrap / app.php,以便该应用程序正在运行,但并没有解决。有人有主意吗?
我正在使用:

  • 流明v5.7.4
  • php v7.2.10
  • 代码接收v2.5.1
  • LPaymentTransactionTest.php

     public function testReturn(): void
    {
        \App\DAO\Order::find(1);
    }
    



    codeception.yml

      paths:
          tests: tests
          output: tests/_output
          data: tests/_data
          support: tests/_support
          envs: tests/_envs
      actor_suffix: Tester
      extensions:
        enabled:
        - Codeception\Extension\RunFailed
      modules:
        enabled:
        - Asserts
        - \Helper\Unit
        - Db:
            dsn: 'sqlite:tests/_data/sqliteTestDb.db'
            user: ''
            password: ''
            #      dump: 'tests/_data/test.sql'
            dump: 'tests/_data/databaseDump.sql'
            populate: true
            cleanup: true
    

    完全错误

    Call to a member function connection() on null
     /home/projects/vendor/illuminate/database/Eloquent/Model.php:1239
     /home/projects/vendor/illuminate/database/Eloquent/Model.php:1205
     /home/projects/vendor/illuminate/database/Eloquent/Model.php:1035
     /home/projects/vendor/illuminate/database/Eloquent/Model.php:952
     /home/projects/vendor/illuminate/database/Eloquent/Model.php:988
     /home/projects/vendor/illuminate/database/Eloquent/Model.php:941
     /home/projects/vendor/illuminate/database/Eloquent/Model.php:1608
     /home/projects/vendor/illuminate/database/Eloquent/Model.php:1620
     /home/projects/tests/unit/LPaymentTransactionTest.php:96
     /tmp/ide-codeception.php:40  
    

    编辑: 该模型确实可以在测试之外工作。因此,如果我通过routes / web.php调用模型,它将返回数据而不会出现问题。 它似乎在测试中似乎不起作用

    edit2: 看起来好像该应用程序没有启动,一旦找到它就会进行修复更新

    0 个答案:

    没有答案