Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-46778

Allow use a separate DB configuration (not just prefix) for Behat similar to PHPUnit

    XMLWordPrintable

Details

    • MOODLE_27_STABLE
    • MOODLE_400_STABLE
    • MDL-46778-master
    • Hide
      1. Create a new database named behatdb
      2. Create a new user and grant all permissions to behatdb database (username newusername, password newpass)
      3. Add in config.php the next settings:
        1. $CFG->behat_prefix = 'b_';
        2. $CFG->behat_dbname = 'behatdb';
        3. $CFG->behat_dbuser = 'newusername';
        4. $CFG->behat_dbpass = 'newpass';
      4. Run:

        php admin/tool/behat/cli/init.php

      5. Make sure that the tables are created in the NEW database.
      6. Remove $CFG->behat_dbname$CFG->behat_dbuser and $CFG->behat_dbpass from config.php
      7. Run again:

        php admin/tool/behat/cli/init.php

      8. Make sure that the tables are created in the ORIGINAL moodle database.
      9. Change $CFG->behat_prefix and give it the same value as $CFG->prefix in config.php
      10. Run again:

        php admin/tool/behat/cli/init.php

      11. Make sure that you get an error.
      12. Add again in config.php the next settings:
        1. $CFG->behat_dbname = 'behatdb';
        2. $CFG->behat_dbuser = 'newusername';
        3. $CFG->behat_dbpass = 'newpass';
      13. Run again:

        php admin/tool/behat/cli/init.php

      14. Make sure that the tables are created in the NEW database even when the prefix is the same.
      15. Edit again config.php, and use an unexisting dbuser or a wrong password for the dbuser:
      16. Run again:

        php admin/tool/behat/cli/init.php

      17. Make sure that you get an error.

       

      Show
      Create a new database named behatdb Create a new user and grant all permissions to behatdb database (username newusername, password newpass) Add in config.php the next settings: $CFG->behat_prefix = 'b_'; $CFG->behat_dbname = 'behatdb'; $CFG->behat_dbuser = 'newusername'; $CFG->behat_dbpass = 'newpass'; Run: php admin/tool/behat/cli/init.php Make sure that the tables are created in the NEW database. Remove  $CFG->behat_dbname ,  $CFG->behat_dbuser and  $CFG->behat_dbpass from config.php Run again: php admin/tool/behat/cli/init.php Make sure that the tables are created in the ORIGINAL moodle database. Change $CFG->behat_prefix and give it the same value as  $CFG->prefix in config.php Run again: php admin/tool/behat/cli/init.php Make sure that you get an error. Add again in config.php the next settings: $CFG->behat_dbname = 'behatdb'; $CFG->behat_dbuser = 'newusername'; $CFG->behat_dbpass = 'newpass'; Run again: php admin/tool/behat/cli/init.php Make sure that the tables are created in the NEW database even when the prefix is the same. Edit again config.php, and use an unexisting dbuser or a wrong password for the dbuser: Run again: php admin/tool/behat/cli/init.php Make sure that you get an error.  

    Description

      As mentioned by Urs, in https://moodle.org/mod/forum/discuss.php?d=264631

      It would be helpful to have separate Db option for behat, similar to phpunit.

      $CFG->behat_dbname = 'moodle_b';
      

      Attachments

        1. MDL-46778_11.png
          MDL-46778_11.png
          38 kB
        2. MDL-46778_14.png
          MDL-46778_14.png
          40 kB
        3. MDL-46778_17.png
          MDL-46778_17.png
          81 kB
        4. MDL-46778_5.png
          MDL-46778_5.png
          178 kB
        5. MDL-46778_8.png
          MDL-46778_8.png
          126 kB

        Activity

          People

            odei.alba@moodle.com Odei Alba
            rajeshtaneja Rajesh Taneja
            Amaia Anabitarte Amaia Anabitarte
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Mihail Geshoski Mihail Geshoski
            Votes:
            3 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              19/Apr/22

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 6 hours, 15 minutes
                1d 6h 15m