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

Privacy tests override or report invalid data

    XMLWordPrintable

Details

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

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              dobedobedoh Andrew Lyons
              fred Frédéric Massart
              Adrian Greeve Adrian Greeve
              Jun Pataleta Jun Pataleta
              CiBoT CiBoT
              Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                17/May/18