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

Unit test - failure to create tst_capabilities table

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.3, 2.1
    • Fix Version/s: 2.0.4, 2.1.1
    • Component/s: Unit tests
    • Labels:
      None
    • Testing Instructions:
      Hide
      1. Login as admin
      2. Site administration -> Development -> Unit tests
      3. Turn block editing on by clicking the button top right.
      4. Run tests on lib/simpletest/testblocklib_blockmanager.php
      5. Check everything passes
      Show
      Login as admin Site administration -> Development -> Unit tests Turn block editing on by clicking the button top right. Run tests on lib/simpletest/testblocklib_blockmanager.php Check everything passes
    • Workaround:
      Hide

      Make sure that the admin user is not editing a course page or any other page. When I logged in directly and went to run the unit tests I did not get any of these errors. Peace - Anthony

      Show
      Make sure that the admin user is not editing a course page or any other page. When I logged in directly and went to run the unit tests I did not get any of these errors. Peace - Anthony
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull Master Branch:
      wip-MDL-28137-master

      Description

      When running unit tests, I received a few exceptions because the tst_capabilities table was not found.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              aborrow Anthony Borrow added a comment -

              linking to qa issue

              Show
              aborrow Anthony Borrow added a comment - linking to qa issue
              Hide
              aborrow Anthony Borrow added a comment -

              Some debug info:

              Exception: lib/simpletest/testblocklib_blockmanager.php / ► moodle_block_manager_test_saving_loading / ► test_empty_initially
              Unexpected exception of type [dml_read_exception] with message [Error reading from database] in [/home/arborrow/NetBeansProjects/m21/lib/dml/moodle_database.php line 393]

              Debug info:

              Table 'm21.tst_capabilities' doesn't exist
              SELECT * FROM tst_capabilities ORDER BY id, name, captype, riskbitmask
              [array (
              )]

              line 794 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
              line 1111 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
              line 1060 of /lib/dml/moodle_database.php: call to moodle_database->get_records_select()
              line 4159 of /lib/accesslib.php: call to moodle_database->get_records()
              line 578 of /lib/accesslib.php: call to get_capability_info()
              line 743 of /lib/accesslib.php: call to has_capability()
              line 686 of /lib/pagelib.php: call to has_any_capability()
              line 669 of /lib/pagelib.php: call to moodle_page->user_allowed_editing()
              line 529 of /lib/blocklib.php: call to moodle_page->user_is_editing()
              line 222 of /lib/simpletest/testblocklib_blockmanager.php: call to block_manager->load_blocks()
              line ... of ...

              Show
              aborrow Anthony Borrow added a comment - Some debug info: Exception: lib/simpletest/testblocklib_blockmanager.php / ► moodle_block_manager_test_saving_loading / ► test_empty_initially Unexpected exception of type [dml_read_exception] with message [Error reading from database] in [/home/arborrow/NetBeansProjects/m21/lib/dml/moodle_database.php line 393] Debug info: Table 'm21.tst_capabilities' doesn't exist SELECT * FROM tst_capabilities ORDER BY id, name, captype, riskbitmask [array ( )] line 794 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end() line 1111 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql() line 1060 of /lib/dml/moodle_database.php: call to moodle_database->get_records_select() line 4159 of /lib/accesslib.php: call to moodle_database->get_records() line 578 of /lib/accesslib.php: call to get_capability_info() line 743 of /lib/accesslib.php: call to has_capability() line 686 of /lib/pagelib.php: call to has_any_capability() line 669 of /lib/pagelib.php: call to moodle_page->user_allowed_editing() line 529 of /lib/blocklib.php: call to moodle_page->user_is_editing() line 222 of /lib/simpletest/testblocklib_blockmanager.php: call to block_manager->load_blocks() line ... of ...
              Hide
              aborrow Anthony Borrow added a comment -

              Here is the full page output from the test

              Show
              aborrow Anthony Borrow added a comment - Here is the full page output from the test
              Hide
              samhemelryk Sam Hemelryk added a comment -

              Just had a look into this with Anthony.
              The capability check shouldn't, or isn't expected to be made by this code. It is only been made because $USER->editing isn't empty.
              In Anthony's case he had been editing a course before running the unit test.
              Certainly it is still a bug but it's no longer a blocker - everything passes when running the block manager unit tests with editing off.
              I'll add details about a small patch to fix this shortly.

              Cheers
              Sam

              Show
              samhemelryk Sam Hemelryk added a comment - Just had a look into this with Anthony. The capability check shouldn't, or isn't expected to be made by this code. It is only been made because $USER->editing isn't empty. In Anthony's case he had been editing a course before running the unit test. Certainly it is still a bug but it's no longer a blocker - everything passes when running the block manager unit tests with editing off. I'll add details about a small patch to fix this shortly. Cheers Sam
              Hide
              aborrow Anthony Borrow added a comment -

              changing link type from block to will help resolve

              Show
              aborrow Anthony Borrow added a comment - changing link type from block to will help resolve
              Hide
              aborrow Anthony Borrow added a comment -

              Pretty straight forward - looks good to me.

              Show
              aborrow Anthony Borrow added a comment - Pretty straight forward - looks good to me.
              Hide
              samhemelryk Sam Hemelryk added a comment -

              Up for integration

              Show
              samhemelryk Sam Hemelryk added a comment - Up for integration
              Hide
              skodak Petr Skoda added a comment -

              Integrated, thanks.

              Show
              skodak Petr Skoda added a comment - Integrated, thanks.
              Hide
              skodak Petr Skoda added a comment -

              Tested, works fine now, thanks!

              Show
              skodak Petr Skoda added a comment - Tested, works fine now, thanks!

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    1/Aug/11