2

I'm trying to set up codeception to use a sqlite database during testing but i am running into the error bellow. I've tried to include bootstrap/app.php so that the application is running but that didn't fix it. Does anybody have an idea?
I'm using:

  • lumen v5.7.4
  • php v7.2.10
  • codeception 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
    

    full error

    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  
    

    edit: the model does work outside of the tests. so if i call the model through in routes/web.php it returns the data without a problem. it just doesn't seem to function within the test

    edit2: looks like the application isn't being launched, will update with fix once i find it

    3
    • did you find the fix for this? Commented Oct 13, 2021 at 6:51
    • @AustinRodrigues i just ended up going a different direction. can't remember fixing it and moved on to another project Commented Jan 13, 2022 at 16:30
    • need to enable Lumen in modules Commented Jan 14, 2022 at 6:35

    1 Answer 1

    1
    actor: UnitTester
    modules:
    enabled:
        - Asserts
        - \Helper\Unit
        - Cli
        - Lumen
        - Db:
              dsn: 'sqlite:tests/_data/database.sqlite'
              dbname: 'tests/_data/database.sqlite'
              dump: 'tests/_data/test.sql'
              user: ''
              password: ''
              populate: true
              cleanup: false
              reconnect: true
              waitlock: 0
    step_decorators: ~        
    
    Sign up to request clarification or add additional context in comments.

    Comments

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.