| Línea 26... | Línea 26... | 
          
            | 26 |  *
 | 26 |  *
 | 
          
            | 27 |  * @package     mod_quiz
 | 27 |  * @package     mod_quiz
 | 
          
            | 28 |  * @copyright   2021 Paul Holden <paulh@moodle.com>
 | 28 |  * @copyright   2021 Paul Holden <paulh@moodle.com>
 | 
          
            | 29 |  * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 29 |  * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 
          
            | 30 |  */
 | 30 |  */
 | 
          
            | 31 | class restore_attempt_test extends \advanced_testcase {
 | 31 | final class restore_attempt_test extends \advanced_testcase {
 | 
          
            | Línea 32... | Línea 32... | 
          
            | 32 |  
 | 32 |  
 | 
          
            | 33 |     /**
 | 33 |     /**
 | 
          
            | 34 |      * Load required libraries
 | 34 |      * Load required libraries
 | 
          
            | 35 |      */
 | 35 |      */
 | 
          
            | 36 |     public static function setUpBeforeClass(): void {
 | 36 |     public static function setUpBeforeClass(): void {
 | 
          
            | Línea 37... | Línea 37... | 
          
            | 37 |         global $CFG;
 | 37 |         global $CFG;
 | 
          
            | - |   | 38 |  
 | 
          
            | 38 |  
 | 39 |         require_once("{$CFG->dirroot}/backup/util/includes/restore_includes.php");
 | 
          
            | Línea 39... | Línea 40... | 
          
            | 39 |         require_once("{$CFG->dirroot}/backup/util/includes/restore_includes.php");
 | 40 |         parent::setUpBeforeClass();
 | 
          
            | 40 |     }
 | 41 |     }
 | 
          
            | 41 |  
 | 42 |  
 | 
          
            | Línea 51... | Línea 52... | 
          
            | 51 |         $this->setAdminUser();
 | 52 |         $this->setAdminUser();
 | 
          
            | Línea 52... | Línea 53... | 
          
            | 52 |  
 | 53 |  
 | 
          
            | 53 |         // Contains a quiz with four attempts from different users. The users are as follows (user ID -> user):
 | 54 |         // Contains a quiz with four attempts from different users. The users are as follows (user ID -> user):
 | 
          
            | 54 |         // 3 -> User 01, 4 -> User 02, 5 -> User 03, 6 -> User 04.
 | 55 |         // 3 -> User 01, 4 -> User 02, 5 -> User 03, 6 -> User 04.
 | 
          
            | 55 |         // The user details for User 02 and User 03 have been removed from the backup file.
 | 56 |         // The user details for User 02 and User 03 have been removed from the backup file.
 | 
          
            | Línea 56... | Línea 57... | 
          
            | 56 |         $testfixture = __DIR__ . '/fixtures/question_attempts_missing_users.mbz';
 | 57 |         $testfixture = self::get_fixture_path(__NAMESPACE__, 'question_attempts_missing_users.mbz');
 | 
          
            | 57 |  
 | 58 |  
 | 
          
            | 58 |         // Extract our test fixture, ready to be restored.
 | 59 |         // Extract our test fixture, ready to be restored.
 | 
          
            | 59 |         $backuptempdir = 'aaa';
 | 60 |         $backuptempdir = 'aaa';
 | 
          
            | Línea 65... | Línea 66... | 
          
            | 65 |         $courseid = restore_dbops::create_new_course('Test fullname', 'Test shortname', $categoryid);
 | 66 |         $courseid = restore_dbops::create_new_course('Test fullname', 'Test shortname', $categoryid);
 | 
          
            | Línea 66... | Línea 67... | 
          
            | 66 |  
 | 67 |  
 | 
          
            | 67 |         $controller = new restore_controller($backuptempdir, $courseid, backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id,
 | 68 |         $controller = new restore_controller($backuptempdir, $courseid, backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id,
 | 
          
            | Línea 68... | Línea 69... | 
          
            | 68 |             backup::TARGET_NEW_COURSE);
 | 69 |             backup::TARGET_NEW_COURSE);
 | 
          
            | - |   | 70 |  
 | 
          
            | - |   | 71 |         $controller->execute_precheck();
 | 
          
            | - |   | 72 |         $results = $controller->get_precheck_results();
 | 
          
            | - |   | 73 |         // Backup contains categories attached to deprecated contexts so the results should only contain warnings for these.
 | 
          
            | - |   | 74 |         $this->assertCount(2, $results['warnings']);
 | 
          
            | - |   | 75 |         foreach ($results['warnings'] as $warning) {
 | 
          
            | - |   | 76 |             $this->assertStringContainsString('will be created at a question bank module context by restore', $warning);
 | 
          
            | - |   | 77 |         }
 | 
          
            | 69 |  
 | 78 |         $this->assertArrayNotHasKey('errors', $results);
 | 
          
            | 70 |         $this->assertTrue($controller->execute_precheck());
 | 79 |  
 | 
          
            | Línea 71... | Línea 80... | 
          
            | 71 |         $controller->execute_plan();
 | 80 |         $controller->execute_plan();
 | 
          
            | 72 |         $controller->destroy();
 | 81 |         $controller->destroy();
 |