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

mtrace should not use stdout when in PHPUNIT_TEST

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3
    • Component/s: Unit tests
    • Labels:
    • Testing Instructions:
      Hide
      1. Run cron via CLI and web
      2. VERIFY: Messages still get printed (starting cron... etc etc)
      3. Run phpunit tests. You can use MDL-33326 as the test case, or you could add the test_cron() function in the issue description to lib/filestorage/tests/file_storage_test.php
      Show
      Run cron via CLI and web VERIFY: Messages still get printed (starting cron... etc etc) Run phpunit tests. You can use MDL-33326 as the test case, or you could add the test_cron() function in the issue description to lib/filestorage/tests/file_storage_test.php
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull Master Branch:

      Description

      If mtrace outputs using normal output, then we can use the various phpunit output buffering functions to check the output of mtrace.

      Also, right now, by using STDOUT during phpunit tests its very difficult to prevent the output.

      The test I was starting to write:

          public function test_cron() {
              $this->resetAfterTest(true);
       
              $fs = get_file_storage();
       
              // We expect a string for two reasons, 1) because we expect to see this string,
              // 2) because using this prevents the output.
              $this->expectOutputRegex('/Cleaning up/');
              $fs->cron();
          }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              poltawski Dan Poltawski
              Reporter:
              poltawski Dan Poltawski
              Peer reviewer:
              Petr Skoda
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                25/Jun/12