Moodle
  1. Moodle
  2. MDL-28137

Unit test - failure to create tst_capabilities table

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major 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
    • Rank:
      17756

      Description

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

        Issue Links

          Activity

          Hide
          Anthony Borrow added a comment -

          linking to qa issue

          Show
          Anthony Borrow added a comment - linking to qa issue
          Hide
          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
          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
          Anthony Borrow added a comment -

          Here is the full page output from the test

          Show
          Anthony Borrow added a comment - Here is the full page output from the test
          Hide
          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
          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
          Anthony Borrow added a comment -

          changing link type from block to will help resolve

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

          Pretty straight forward - looks good to me.

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

          Up for integration

          Show
          Sam Hemelryk added a comment - Up for integration
          Hide
          Petr Škoda added a comment -

          Integrated, thanks.

          Show
          Petr Škoda added a comment - Integrated, thanks.
          Hide
          Petr Škoda added a comment -

          Tested, works fine now, thanks!

          Show
          Petr Škoda 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: