Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Composer test does not work as expeceted

    General Discussion
    2
    4
    217
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rabol last edited by

      Hi

      Composer test command does not work in a standard installation and there is no documentation stating how to set up the testing

      e.g
      composer test fails with this:

      set -e
      @php artisan migrate:fresh --env=testing

      Dropping all tables .................................................................................................................... 10ms FAIL

      In Connection.php line 759:

      SQLSTATE[HY000] [2002] Connection refused (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')

      In Exception.php line 18:

      SQLSTATE[HY000] [2002] Connection refused

      In PDOConnection.php line 40:

      SQLSTATE[HY000] [2002] Connection refused

      Normally testing uses SQlite not the same connection

      does one have to have a special .env or how can I make testing work ?

      Kind regards
      Steen

      1 Reply Last reply Reply Quote 0
      • sanjay-webkul
        sanjay-webkul last edited by

        @rabol said in Composer test does not work as expeceted:

        Connection refused

        Hi there,
        Please check your .env file, i guess you are not configure your databse credentials

        R 1 Reply Last reply Reply Quote 0
        • R
          rabol @sanjay-webkul last edited by

          @sanjay-webkul but normally one does not need to create a connection.
          Test should run using a separate database

          https://laravel.com/docs/9.x/testing

          when you specify --env=testing there NEED to be a .env file named .env.testing

          Maybe a note in the documentation 🙂

          even with a .env.testing and using SQLite (Which I think is quite normal) it does not work

          1 Reply Last reply Reply Quote 0
          • sanjay-webkul
            sanjay-webkul last edited by

            Hi there,
            But the databse should be created which in mentioned on your .env.test file.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post