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

Privacy tests override or report invalid data

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.3.6, 3.4.3
    • 3.3.5, 3.4.2
    • Privacy, Unit tests

      Here is a test.

          /**
           * Test export and recover with children.
           */
          public function test_get_data_with_children() {
              $writer = $this->get_writer_instance();
              $context = \context_system::instance();
       
              $writer->set_context($context)
                  ->export_data(['a'], (object) ['parent' => true])
                  ->export_data(['a', 'b'], (object) ['parent' => false]);
       
              $this->assertTrue($writer->get_data(['a'])->parent);
              $this->assertFalse($writer->get_data(['a', 'b'])->parent);
              $this->assertSame([], $writer->get_data(['a', 'b', 'c']));
          }
      

      I identified two issues:

      1. Writing a sub context overrides the parent
      2. Getting a sub context that does not exist returns the parent

      Andrew mentioned that this will likely affect other `get_*` methods.

            dobedobedoh Andrew Lyons
            fred Frédéric Massart
            Adrian Greeve Adrian Greeve
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.