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

unit tests giving error with $CFG->unittestprefix set

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a bug
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Unit tests
    • Labels:
      None
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      Just running the tests in lib/grade/simpletest/testgradecategory.php

      In my config.php I have:
      $CFG->unittestprefix = 'testing_';

      Getting the following output:

      In grade_test constructor
      revert_to_real_db called when the test DB was not already selected. This suggest you are doing something wrong and dangerous. Please review your code immediately.

      • line 464 of /lib/simpletestlib.php: call to debugging()
      • line 513 of /lib/simpletestlib.php: call to UnitTestCaseUsingDatabase->revert_to_real_db()
      • line 535 of /lib/simpletestlib.php: call to UnitTestCaseUsingDatabase->automatic_clean_up()
      • line 616 of /lib/simpletestlib/test_case.php: call to UnitTestCaseUsingDatabase->__destruct()
      • line 618 of /lib/simpletestlib/test_case.php: call to TestSuite->run()
      • line 37 of /admin/report/unittest/ex_simple_test.php: call to TestSuite->run()
      • line 144 of /lib/simpletestcoveragelib.php: call to AutoGroupTest->run()
      • line 91 of /admin/report/unittest/index.php: call to autogroup_test_coverage->run()

      In grade_category_test constructor

      switch_to_test_db called when the test DB was already selected. This suggest you are doing something wrong and dangerous. Please review your code immediately.

      • line 453 of /lib/simpletestlib.php: call to debugging()
      • line 81 of /lib/simpletest/fixtures/gradetest.php: call to UnitTestCaseUsingDatabase->switch_to_test_db()
      • line 67 of /lib/simpletestlib/invoker.php: call to grade_test->setUp()
      • line 137 of /lib/simpletestlib/invoker.php: call to SimpleInvoker->invoke()
      • line 53 of /lib/simpletestlib/errors.php: call to SimpleInvokerDecorator->invoke()
      • line 137 of /lib/simpletestlib/invoker.php: call to SimpleErrorTrappingInvoker->invoke()
      • line 43 of /lib/simpletestlib/exceptions.php: call to SimpleInvokerDecorator->invoke()
      • line 143 of /lib/simpletestlib/test_case.php: call to SimpleExceptionTrappingInvoker->invoke()
      • line 615 of /lib/simpletestlib/test_case.php: call to SimpleTestCase->run()
      • line 618 of /lib/simpletestlib/test_case.php: call to TestSuite->run()
      • line 37 of /admin/report/unittest/ex_simple_test.php: call to TestSuite->run()
      • line 144 of /lib/simpletestcoveragelib.php: call to AutoGroupTest->run()
      • line 91 of /admin/report/unittest/index.php: call to autogroup_test_coverage->run()

      ( ! ) Fatal error: Call to a member function get_manager() on a non-object in /home/andrew/Desktop/repos/moodle/lib/simpletestlib.php on line 548
      Call Stack

      1. Time Memory Function Location
        1 0.0005 167712 {main}

        ( ) ../index.php:0
        2 0.6743 76901544 autogroup_test_coverage->run( ) ../index.php:91
        3 0.6743 76901816 AutoGroupTest->run( ) ../simpletestcoveragelib.php:144
        4 0.6743 76902272 TestSuite->run( ) ../ex_simple_test.php:37
        5 0.6744 76902992 TestSuite->run( ) ../test_case.php:618
        6 0.6758 76232000 SimpleTestCase->run( ) ../test_case.php:615
        7 0.6769 76244880 SimpleExceptionTrappingInvoker->invoke( ) ../test_case.php:143
        8 0.6770 76246688 SimpleInvokerDecorator->invoke( ) ../exceptions.php:43
        9 0.6770 76246816 SimpleErrorTrappingInvoker->invoke( ) ../invoker.php:137
        10 0.6770 76249136 SimpleInvokerDecorator->invoke( ) ../errors.php:53
        11 0.6770 76249264 SimpleInvoker->invoke( ) ../invoker.php:137
        12 0.6770 76249464 grade_test->setUp( ) ../invoker.php:67
        13 0.6773 76251088 UnitTestCaseUsingDatabase->create_test_tables( ) ../gradetest.php:84
        14 0.6773 76253568 UnitTestCaseUsingDatabase->create_test_table( ) ../simpletestlib.php:570

      The line giving the error is within create_test_table():
      $dbman = $this->testdb->get_manager();

      This is MySQL. I think all of my existing tables are MyISAM.

        Attachments

          Activity

            People

            • Assignee:
              andyjdavis Andrew Davis
              Reporter:
              andyjdavis Andrew Davis
              Tester:
              Nobody
              Participants:
              Component watchers:
              Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                24/Nov/10