mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-71036 phpunit: Coding style changes, 99% whitespace only
I've gone over a few of the mofified files (those which were showing warnings and errors to CiBoT. Some of them have been fixed completely, while others only have fixed for the lines belonging to this issue (lib/tests/moodlelib_test.php) for example.
This commit is contained in:
parent
49975d5879
commit
713722c3fb
@ -436,7 +436,8 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertEquals($this->c1->id, $errors[0]['courseid']);
|
||||
$this->assertEquals($this->f1comps['A1']->get('id'), $errors[0]['competencyid']);
|
||||
$this->assertEquals(null, $errors[0]['cmid']);
|
||||
$this->assertMatchesRegularExpression('/Sorry, but you do not currently have permissions to do that/', $errors[0]['message']);
|
||||
$this->assertMatchesRegularExpression('/Sorry, but you do not currently have permissions to do that/',
|
||||
$errors[0]['message']);
|
||||
$this->assertEquals($this->f1comps['A3']->get('id'), $errors[1]['competencyid']);
|
||||
|
||||
$this->assertCourseCompetencyNotMigrated($this->c1, $this->f1comps['A1'], $this->f2comps['A1']);
|
||||
@ -465,7 +466,8 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertEquals($this->c2->id, $errors[0]['courseid']);
|
||||
$this->assertEquals($this->f1comps['A2']->get('id'), $errors[0]['competencyid']);
|
||||
$this->assertEquals($this->cms[$this->c2->id]['F1']->cmid, $errors[0]['cmid']);
|
||||
$this->assertMatchesRegularExpression('/Sorry, but you do not currently have permissions to do that/', $errors[0]['message']);
|
||||
$this->assertMatchesRegularExpression('/Sorry, but you do not currently have permissions to do that/',
|
||||
$errors[0]['message']);
|
||||
$this->assertEquals($this->f1comps['A3']->get('id'), $errors[1]['competencyid']);
|
||||
|
||||
// The new competencies were added to the course, but the old ones were not removed because they are still in modules.
|
||||
@ -616,5 +618,4 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertEquals($before->get('sortorder'), $after->get('sortorder'));
|
||||
$this->assertEquals($before->get('ruleoutcome'), $after->get('ruleoutcome'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -498,7 +498,8 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
|
||||
|
||||
$modurl = new moodle_url('/mod/book/view.php', array('id' => $book->cmid));
|
||||
|
||||
$this->assertMatchesRegularExpression('~<h2>.*' . preg_quote($event->get_url()->out(), '~') . '.*</h2>~', $msg->fullmessagehtml);
|
||||
$this->assertMatchesRegularExpression('~<h2>.*' . preg_quote($event->get_url()->out(), '~') . '.*</h2>~',
|
||||
$msg->fullmessagehtml);
|
||||
$this->assertMatchesRegularExpression('~<li>.*' . preg_quote($modurl->out(), '~') . '.*</li>~', $msg->fullmessagehtml);
|
||||
$this->assertStringContainsString('<li><strong>'.$rule->get_name($context).'</strong></li>', $msg->fullmessagehtml);
|
||||
$this->assertStringContainsString('<li>'.$rule->get_description($context).'</li>', $msg->fullmessagehtml);
|
||||
|
@ -2525,7 +2525,8 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
|
||||
(new DateTime('1997-11-06 09:00:00 EST'))->getTimestamp()
|
||||
];
|
||||
foreach ($records as $record) {
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates, date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates,
|
||||
date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2603,7 +2604,8 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
|
||||
(new DateTime('1997-09-02 15:00:00 EDT'))->getTimestamp(),
|
||||
];
|
||||
foreach ($records as $record) {
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates, date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates,
|
||||
date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2634,7 +2636,8 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
|
||||
(new DateTime('1997-09-02 10:15:00 EDT'))->getTimestamp(),
|
||||
];
|
||||
foreach ($records as $record) {
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates, date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates,
|
||||
date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2663,7 +2666,8 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
|
||||
(new DateTime('1997-09-02 13:30:00 EDT'))->getTimestamp(),
|
||||
];
|
||||
foreach ($records as $record) {
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates, date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates,
|
||||
date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2707,7 +2711,8 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
|
||||
$this->assertCount($count, $records);
|
||||
|
||||
foreach ($records as $record) {
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates, date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates,
|
||||
date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2751,7 +2756,8 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
|
||||
$this->assertCount($count, $records);
|
||||
|
||||
foreach ($records as $record) {
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates, date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates,
|
||||
date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2782,7 +2788,8 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
|
||||
(new DateTime('1997-08-24 09:00:00 EDT'))->getTimestamp(),
|
||||
];
|
||||
foreach ($records as $record) {
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates, date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates,
|
||||
date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2815,7 +2822,8 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
|
||||
];
|
||||
|
||||
foreach ($records as $record) {
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates, date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
$this->assertContainsEquals($record->timestart, $expecteddates,
|
||||
date('Y-m-d H:i:s', $record->timestart) . ' is not found.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$plan = api::update_plan($record);
|
||||
$this->fail('Updating the status is not allowed.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertMatchesRegularExpression('/To change the status of a plan use the appropriate methods./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/To change the status of a plan use the appropriate methods./',
|
||||
$e->getMessage());
|
||||
}
|
||||
|
||||
// Test when user with manage own plan capability try to edit other user plan.
|
||||
@ -2101,8 +2102,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$c3 = $lpg->create_competency(array('competencyframeworkid' => $f1->get('id')));
|
||||
|
||||
// Creating an evidence with minimal information.
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_COMPLETE, 'invaliddata',
|
||||
'error');
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_COMPLETE,
|
||||
'invaliddata', 'error');
|
||||
$evidence->read();
|
||||
$uc = \core_competency\user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c1->get('id')));
|
||||
$this->assertEquals(\core_competency\user_competency::STATUS_IDLE, $uc->get('status'));
|
||||
@ -2119,8 +2120,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$this->assertSame(null, $evidence->get('actionuserid'));
|
||||
|
||||
// Creating an evidence complete on competency with custom scale.
|
||||
$evidence = api::add_evidence($u1->id, $c2->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_COMPLETE, 'invaliddata',
|
||||
'error');
|
||||
$evidence = api::add_evidence($u1->id, $c2->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_COMPLETE,
|
||||
'invaliddata', 'error');
|
||||
$evidence->read();
|
||||
$uc = \core_competency\user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c2->get('id')));
|
||||
$this->assertEquals(\core_competency\user_competency::STATUS_IDLE, $uc->get('status'));
|
||||
@ -2141,8 +2142,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
'proficiency' => 0));
|
||||
$this->assertEquals(1, $uc->get('grade'));
|
||||
$this->assertEquals(0, $uc->get('proficiency'));
|
||||
$evidence = api::add_evidence($u1->id, $c3->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_COMPLETE, 'invaliddata',
|
||||
'error');
|
||||
$evidence = api::add_evidence($u1->id, $c3->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_COMPLETE,
|
||||
'invaliddata', 'error');
|
||||
$evidence->read();
|
||||
$uc->read();
|
||||
$this->assertEquals(\core_competency\user_competency::STATUS_IDLE, $uc->get('status'));
|
||||
@ -2159,8 +2160,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$this->assertSame(null, $evidence->get('actionuserid'));
|
||||
|
||||
// Creating a standard evidence and send for review.
|
||||
$evidence = api::add_evidence($u1->id, $c2->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_COMPLETE, 'invaliddata',
|
||||
'error', null, true);
|
||||
$evidence = api::add_evidence($u1->id, $c2->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_COMPLETE,
|
||||
'invaliddata', 'error', null, true);
|
||||
$evidence->read();
|
||||
$uc = \core_competency\user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c2->get('id')));
|
||||
$this->assertEquals(\core_competency\user_competency::STATUS_WAITING_FOR_REVIEW, $uc->get('status'));
|
||||
@ -2185,8 +2186,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get('id')));
|
||||
|
||||
// Creating an evidence with minimal information.
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_OVERRIDE, 'invaliddata',
|
||||
'error');
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_OVERRIDE,
|
||||
'invaliddata', 'error');
|
||||
$evidence->read();
|
||||
$uc = \core_competency\user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c1->get('id')));
|
||||
$this->assertEquals(\core_competency\user_competency::STATUS_IDLE, $uc->get('status'));
|
||||
@ -2203,8 +2204,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$this->assertSame(null, $evidence->get('actionuserid'));
|
||||
|
||||
// Creating an evidence with a grade information.
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_OVERRIDE, 'invaliddata',
|
||||
'error', null, false, null, 3);
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_OVERRIDE,
|
||||
'invaliddata', 'error', null, false, null, 3);
|
||||
$evidence->read();
|
||||
$uc = \core_competency\user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c1->get('id')));
|
||||
$this->assertEquals(\core_competency\user_competency::STATUS_IDLE, $uc->get('status'));
|
||||
@ -2221,8 +2222,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$this->assertSame(null, $evidence->get('actionuserid'));
|
||||
|
||||
// Creating an evidence with another grade information.
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_OVERRIDE, 'invaliddata',
|
||||
'error', null, false, null, 1);
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_OVERRIDE,
|
||||
'invaliddata', 'error', null, false, null, 1);
|
||||
$evidence->read();
|
||||
$uc = \core_competency\user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c1->get('id')));
|
||||
$this->assertEquals(\core_competency\user_competency::STATUS_IDLE, $uc->get('status'));
|
||||
@ -2239,8 +2240,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$this->assertSame(null, $evidence->get('actionuserid'));
|
||||
|
||||
// Creating reverting the grade and send for review.
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_OVERRIDE, 'invaliddata',
|
||||
'error', null, true);
|
||||
$evidence = api::add_evidence($u1->id, $c1->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_OVERRIDE,
|
||||
'invaliddata', 'error', null, true);
|
||||
$evidence->read();
|
||||
$uc = \core_competency\user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c1->get('id')));
|
||||
$this->assertSame(null, $uc->get('grade'));
|
||||
@ -2407,7 +2408,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::add_evidence($u1->id, $c1a, $ctxid, evidence::ACTION_LOG, 'commentincontext', 'core');
|
||||
$uc1a = user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c1a->get('id')));
|
||||
$this->assertSame(null, $uc1a->get('proficiency'));
|
||||
$this->assertFalse(user_competency::record_exists_select('userid = ? AND competencyid = ?', array($u1->id, $c1->get('id'))));
|
||||
$this->assertFalse(user_competency::record_exists_select('userid = ? AND competencyid = ?',
|
||||
array($u1->id, $c1->get('id'))));
|
||||
|
||||
// Now let's try complete a competency but the rule won't match (not all children are complete).
|
||||
// The parent (the thing with the rule) will be created but won't have any evidence attached, and not
|
||||
@ -2450,7 +2452,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::add_evidence($u1->id, $c4a, $ctxid, evidence::ACTION_COMPLETE, 'commentincontext', 'core');
|
||||
$uc4a = user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c4a->get('id')));
|
||||
$this->assertEquals(true, $uc1a->get('proficiency'));
|
||||
$this->assertFalse(user_competency::record_exists_select('userid = ? AND competencyid = ?', array($u1->id, $c4->get('id'))));
|
||||
$this->assertFalse(user_competency::record_exists_select('userid = ? AND competencyid = ?',
|
||||
array($u1->id, $c4->get('id'))));
|
||||
|
||||
// Check marking on something that has no parent. This just checks that nothing breaks.
|
||||
api::add_evidence($u1->id, $c5, $ctxid, evidence::ACTION_COMPLETE, 'commentincontext', 'core');
|
||||
@ -2791,7 +2794,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get('id'),
|
||||
\core_competency\course_competency::OUTCOME_NONE));
|
||||
$recordscc = api::list_course_competencies($course->id);
|
||||
$this->assertEquals(\core_competency\course_competency::OUTCOME_NONE, $recordscc[0]['coursecompetency']->get('ruleoutcome'));
|
||||
$this->assertEquals(\core_competency\course_competency::OUTCOME_NONE,
|
||||
$recordscc[0]['coursecompetency']->get('ruleoutcome'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
|
||||
$DB = $this->createMock(get_class($DB));
|
||||
$CFG->enablecompletion = COMPLETION_ENABLED;
|
||||
$USER = (object)array('id' =>314159);
|
||||
$USER = (object)array('id' => 314159);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +101,7 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(COMPLETION_ENABLED, completion_info::is_enabled_for_site());
|
||||
|
||||
// Course.
|
||||
$course = (object)array('id' =>13);
|
||||
$course = (object)array('id' => 13);
|
||||
$c = new completion_info($course);
|
||||
$course->enablecompletion = COMPLETION_DISABLED;
|
||||
$this->assertEquals(COMPLETION_DISABLED, $c->is_enabled());
|
||||
@ -132,7 +132,7 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$mockbuilder->onlyMethods(array('is_enabled', 'get_data', 'internal_get_state', 'internal_set_data',
|
||||
'user_can_override_completion'));
|
||||
$mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
|
||||
$cm = (object)array('id'=>13, 'course'=>42);
|
||||
$cm = (object)array('id' => 13, 'course' => 42);
|
||||
|
||||
// Not enabled, should do nothing.
|
||||
$c = $mockbuilder->getMock();
|
||||
@ -171,8 +171,8 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
|
||||
// Manual, change state (no change).
|
||||
$c = $mockbuilder->getMock();
|
||||
$cm = (object)array('id'=>13, 'course'=>42, 'completion'=>COMPLETION_TRACKING_MANUAL);
|
||||
$current->completionstate=COMPLETION_COMPLETE;
|
||||
$cm = (object)array('id' => 13, 'course' => 42, 'completion' => COMPLETION_TRACKING_MANUAL);
|
||||
$current->completionstate = COMPLETION_COMPLETE;
|
||||
$c->expects($this->once())
|
||||
->method('is_enabled')
|
||||
->with($cm)
|
||||
@ -205,7 +205,7 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
|
||||
// Auto, change state.
|
||||
$c = $mockbuilder->getMock();
|
||||
$cm = (object)array('id'=>13, 'course'=>42, 'completion'=>COMPLETION_TRACKING_AUTOMATIC);
|
||||
$cm = (object)array('id' => 13, 'course' => 42, 'completion' => COMPLETION_TRACKING_AUTOMATIC);
|
||||
$current = (object)array('completionstate' => COMPLETION_COMPLETE, 'overrideby' => null);
|
||||
$c->expects($this->once())
|
||||
->method('is_enabled')
|
||||
@ -301,7 +301,7 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
->with($cm)
|
||||
->will($this->returnValue(true));
|
||||
$c->expects($this->Once()) // Pretend the user has the required capability for overriding completion statuses.
|
||||
->method('user_can_override_completion')
|
||||
->method('user_can_override_completion')
|
||||
->will($this->returnValue(true));
|
||||
$c->expects($this->once())
|
||||
->method('get_data')
|
||||
@ -455,7 +455,7 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$mockbuilder = $this->getMockBuilder('completion_info');
|
||||
$mockbuilder->onlyMethods(array('is_enabled', 'get_data', 'internal_set_data', 'update_state'));
|
||||
$mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
|
||||
$cm = (object)array('id'=>13, 'course'=>42);
|
||||
$cm = (object)array('id' => 13, 'course' => 42);
|
||||
|
||||
// Not tracking completion, should do nothing.
|
||||
$c = $mockbuilder->getMock();
|
||||
@ -481,7 +481,7 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$c->expects($this->once())
|
||||
->method('get_data')
|
||||
->with($cm, 0)
|
||||
->will($this->returnValue((object)array('viewed'=>COMPLETION_VIEWED)));
|
||||
->will($this->returnValue((object)array('viewed' => COMPLETION_VIEWED)));
|
||||
$c->set_module_viewed($cm);
|
||||
|
||||
// OK finally one that hasn't been viewed, now it should set it viewed
|
||||
@ -494,10 +494,10 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$c->expects($this->once())
|
||||
->method('get_data')
|
||||
->with($cm, false, 1337)
|
||||
->will($this->returnValue((object)array('viewed'=>COMPLETION_NOT_VIEWED)));
|
||||
->will($this->returnValue((object)array('viewed' => COMPLETION_NOT_VIEWED)));
|
||||
$c->expects($this->once())
|
||||
->method('internal_set_data')
|
||||
->with($cm, (object)array('viewed'=>COMPLETION_VIEWED));
|
||||
->with($cm, (object)array('viewed' => COMPLETION_VIEWED));
|
||||
$c->expects($this->once())
|
||||
->method('update_state')
|
||||
->with($cm, COMPLETION_COMPLETE, 1337);
|
||||
@ -508,8 +508,8 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
global $DB;
|
||||
$this->mock_setup();
|
||||
|
||||
$course = (object)array('id'=>13);
|
||||
$cm = (object)array('id'=>42);
|
||||
$course = (object)array('id' => 13);
|
||||
$cm = (object)array('id' => 42);
|
||||
|
||||
/** @var $DB PHPUnit_Framework_MockObject_MockObject */
|
||||
$DB->expects($this->once())
|
||||
@ -524,15 +524,15 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
global $DB;
|
||||
$this->mock_setup();
|
||||
|
||||
$course = (object)array('id'=>13);
|
||||
$cm = (object)array('id'=>42, 'course'=>13);
|
||||
$course = (object)array('id' => 13);
|
||||
$cm = (object)array('id' => 42, 'course' => 13);
|
||||
$c = new completion_info($course);
|
||||
|
||||
// Check it works ok without data in session.
|
||||
/** @var $DB PHPUnit_Framework_MockObject_MockObject */
|
||||
$DB->expects($this->once())
|
||||
->method('delete_records')
|
||||
->with('course_modules_completion', array('coursemoduleid'=>42))
|
||||
->with('course_modules_completion', array('coursemoduleid' => 42))
|
||||
->will($this->returnValue(true));
|
||||
$c->delete_all_state($cm);
|
||||
}
|
||||
@ -546,13 +546,14 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
|
||||
$c = $mockbuilder->getMock();
|
||||
|
||||
$cm = (object)array('id'=>13, 'course'=>42, 'completion'=>COMPLETION_TRACKING_AUTOMATIC);
|
||||
$cm = (object)array('id' => 13, 'course' => 42, 'completion' => COMPLETION_TRACKING_AUTOMATIC);
|
||||
|
||||
/** @var $DB PHPUnit_Framework_MockObject_MockObject */
|
||||
$DB->expects($this->once())
|
||||
->method('get_recordset')
|
||||
->will($this->returnValue(
|
||||
new core_completionlib_fake_recordset(array((object)array('id'=>1, 'userid'=>100), (object)array('id'=>2, 'userid'=>101)))));
|
||||
new core_completionlib_fake_recordset(array((object)array('id' => 1, 'userid' => 100),
|
||||
(object)array('id' => 2, 'userid' => 101)))));
|
||||
|
||||
$c->expects($this->once())
|
||||
->method('delete_all_state')
|
||||
@ -561,8 +562,8 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$c->expects($this->once())
|
||||
->method('get_tracked_users')
|
||||
->will($this->returnValue(array(
|
||||
(object)array('id'=>100, 'firstname'=>'Woot', 'lastname'=>'Plugh'),
|
||||
(object)array('id'=>201, 'firstname'=>'Vroom', 'lastname'=>'Xyzzy'))));
|
||||
(object)array('id' => 100, 'firstname' => 'Woot', 'lastname' => 'Plugh'),
|
||||
(object)array('id' => 201, 'firstname' => 'Vroom', 'lastname' => 'Xyzzy'))));
|
||||
|
||||
$c->expects($this->exactly(3))
|
||||
->method('update_state')
|
||||
@ -733,9 +734,7 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
// Cache for another user is not filled.
|
||||
$this->assertEquals(false, $cache->get($d2->userid . '_' . $cm2->course));
|
||||
|
||||
// 3) Test where it THINKS the data is new (from cache) but actually
|
||||
// in the database it has been set since.
|
||||
// 1) Test with new data.
|
||||
// 3) Test where it THINKS the data is new (from cache) but actually in the database it has been set since.
|
||||
$forum3 = $this->getDataGenerator()->create_module('forum', array('course' => $this->course->id), $completionauto);
|
||||
$cm3 = get_coursemodule_from_instance('forum', $forum3->id);
|
||||
$newuser2 = $this->getDataGenerator()->create_user();
|
||||
@ -765,23 +764,23 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
->method('get_tracked_users')
|
||||
->with(false, array(), 0, '', '', '', null)
|
||||
->will($this->returnValue(array(
|
||||
(object)array('id'=>100, 'firstname'=>'Woot', 'lastname'=>'Plugh'),
|
||||
(object)array('id'=>201, 'firstname'=>'Vroom', 'lastname'=>'Xyzzy'))));
|
||||
(object)array('id' => 100, 'firstname' => 'Woot', 'lastname' => 'Plugh'),
|
||||
(object)array('id' => 201, 'firstname' => 'Vroom', 'lastname' => 'Xyzzy'))));
|
||||
$DB->expects($this->once())
|
||||
->method('get_in_or_equal')
|
||||
->with(array(100, 201))
|
||||
->will($this->returnValue(array(' IN (100, 201)', array())));
|
||||
$progress1 = (object)array('userid'=>100, 'coursemoduleid'=>13);
|
||||
$progress2 = (object)array('userid'=>201, 'coursemoduleid'=>14);
|
||||
$progress1 = (object)array('userid' => 100, 'coursemoduleid' => 13);
|
||||
$progress2 = (object)array('userid' => 201, 'coursemoduleid' => 14);
|
||||
$DB->expects($this->once())
|
||||
->method('get_recordset_sql')
|
||||
->will($this->returnValue(new core_completionlib_fake_recordset(array($progress1, $progress2))));
|
||||
|
||||
$this->assertEquals(array(
|
||||
100 => (object)array('id'=>100, 'firstname'=>'Woot', 'lastname'=>'Plugh',
|
||||
'progress'=>array(13=>$progress1)),
|
||||
201 => (object)array('id'=>201, 'firstname'=>'Vroom', 'lastname'=>'Xyzzy',
|
||||
'progress'=>array(14=>$progress2)),
|
||||
100 => (object)array('id' => 100, 'firstname' => 'Woot', 'lastname' => 'Plugh',
|
||||
'progress' => array(13 => $progress1)),
|
||||
201 => (object)array('id' => 201, 'firstname' => 'Vroom', 'lastname' => 'Xyzzy',
|
||||
'progress' => array(14 => $progress2)),
|
||||
), $c->get_progress_all(false));
|
||||
}
|
||||
|
||||
@ -798,11 +797,11 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$ids = array();
|
||||
$progress = array();
|
||||
// With more than 1000 results.
|
||||
for ($i = 100; $i<2000; $i++) {
|
||||
$tracked[] = (object)array('id'=>$i, 'firstname'=>'frog', 'lastname'=>$i);
|
||||
for ($i = 100; $i < 2000; $i++) {
|
||||
$tracked[] = (object)array('id' => $i, 'firstname' => 'frog', 'lastname' => $i);
|
||||
$ids[] = $i;
|
||||
$progress[] = (object)array('userid'=>$i, 'coursemoduleid'=>13);
|
||||
$progress[] = (object)array('userid'=>$i, 'coursemoduleid'=>14);
|
||||
$progress[] = (object)array('userid' => $i, 'coursemoduleid' => 13);
|
||||
$progress[] = (object)array('userid' => $i, 'coursemoduleid' => 14);
|
||||
}
|
||||
$c->expects($this->once())
|
||||
->method('get_tracked_users')
|
||||
@ -825,16 +824,16 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
|
||||
$result = $c->get_progress_all(true, 3);
|
||||
$resultok = true;
|
||||
$resultok = $resultok && ($ids == array_keys($result));
|
||||
$resultok = $resultok && ($ids == array_keys($result));
|
||||
|
||||
foreach ($result as $userid => $data) {
|
||||
$resultok = $resultok && $data->firstname == 'frog';
|
||||
$resultok = $resultok && $data->lastname == $userid;
|
||||
$resultok = $resultok && $data->id == $userid;
|
||||
$resultok = $resultok && $data->firstname == 'frog';
|
||||
$resultok = $resultok && $data->lastname == $userid;
|
||||
$resultok = $resultok && $data->id == $userid;
|
||||
$cms = $data->progress;
|
||||
$resultok = $resultok && (array(13, 14) == array_keys($cms));
|
||||
$resultok = $resultok && ((object)array('userid'=>$userid, 'coursemoduleid'=>13) == $cms[13]);
|
||||
$resultok = $resultok && ((object)array('userid'=>$userid, 'coursemoduleid'=>14) == $cms[14]);
|
||||
$resultok = $resultok && (array(13, 14) == array_keys($cms));
|
||||
$resultok = $resultok && ((object)array('userid' => $userid, 'coursemoduleid' => 13) == $cms[13]);
|
||||
$resultok = $resultok && ((object)array('userid' => $userid, 'coursemoduleid' => 14) == $cms[14]);
|
||||
}
|
||||
$this->assertTrue($resultok);
|
||||
$this->assertCount(count($tracked), $result);
|
||||
@ -847,9 +846,9 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$mockbuilder->onlyMethods(array('is_enabled', 'update_state'));
|
||||
$mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
|
||||
|
||||
$cm = (object)array('course'=>42, 'id'=>13, 'completion'=>0, 'completiongradeitemnumber'=>null);
|
||||
$item = (object)array('itemnumber'=>3, 'gradepass'=>1, 'hidden'=>0);
|
||||
$grade = (object)array('userid'=>31337, 'finalgrade'=>0, 'rawgrade'=>0);
|
||||
$cm = (object)array('course' => 42, 'id' => 13, 'completion' => 0, 'completiongradeitemnumber' => null);
|
||||
$item = (object)array('itemnumber' => 3, 'gradepass' => 1, 'hidden' => 0);
|
||||
$grade = (object)array('userid' => 31337, 'finalgrade' => 0, 'rawgrade' => 0);
|
||||
|
||||
// Not enabled (should do nothing).
|
||||
$c = $mockbuilder->getMock();
|
||||
@ -869,7 +868,7 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
|
||||
// Enabled and completion required but item number is wrong, does nothing.
|
||||
$c = $mockbuilder->getMock();
|
||||
$cm = (object)array('course'=>42, 'id'=>13, 'completion'=>0, 'completiongradeitemnumber'=>7);
|
||||
$cm = (object)array('course' => 42, 'id' => 13, 'completion' => 0, 'completiongradeitemnumber' => 7);
|
||||
$c->expects($this->once())
|
||||
->method('is_enabled')
|
||||
->with($cm)
|
||||
@ -880,8 +879,8 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
// to call update_state with the new potential state being obtained from
|
||||
// internal_get_grade_state.
|
||||
$c = $mockbuilder->getMock();
|
||||
$cm = (object)array('course'=>42, 'id'=>13, 'completion'=>0, 'completiongradeitemnumber'=>3);
|
||||
$grade = (object)array('userid'=>31337, 'finalgrade'=>1, 'rawgrade'=>0);
|
||||
$cm = (object)array('course' => 42, 'id' => 13, 'completion' => 0, 'completiongradeitemnumber' => 3);
|
||||
$grade = (object)array('userid' => 31337, 'finalgrade' => 1, 'rawgrade' => 0);
|
||||
$c->expects($this->once())
|
||||
->method('is_enabled')
|
||||
->with($cm)
|
||||
@ -895,8 +894,8 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
// Same as above but marked deleted. It is supposed to call update_state
|
||||
// with new potential state being COMPLETION_INCOMPLETE.
|
||||
$c = $mockbuilder->getMock();
|
||||
$cm = (object)array('course'=>42, 'id'=>13, 'completion'=>0, 'completiongradeitemnumber'=>3);
|
||||
$grade = (object)array('userid'=>31337, 'finalgrade'=>1, 'rawgrade'=>0);
|
||||
$cm = (object)array('course' => 42, 'id' => 13, 'completion' => 0, 'completiongradeitemnumber' => 3);
|
||||
$grade = (object)array('userid' => 31337, 'finalgrade' => 1, 'rawgrade' => 0);
|
||||
$c->expects($this->once())
|
||||
->method('is_enabled')
|
||||
->with($cm)
|
||||
@ -1078,7 +1077,8 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
$this->assertInstanceOf('\core\event\course_module_completion_updated', $event);
|
||||
$this->assertEquals($forum->cmid, $event->get_record_snapshot('course_modules_completion', $event->objectid)->coursemoduleid);
|
||||
$this->assertEquals($forum->cmid,
|
||||
$event->get_record_snapshot('course_modules_completion', $event->objectid)->coursemoduleid);
|
||||
$this->assertEquals($current, $event->get_record_snapshot('course_modules_completion', $event->objectid));
|
||||
$this->assertEquals(context_module::instance($forum->cmid), $event->get_context());
|
||||
$this->assertEquals($USER->id, $event->userid);
|
||||
@ -1206,8 +1206,8 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
* @param string|null $expectedexception Expected exception.
|
||||
* @param int|null $expectedresult The expected completion status.
|
||||
*/
|
||||
public function test_get_grade_completion(bool $completionusegrade, bool $hasgrade, ?int $passinggrade, ?string $expectedexception,
|
||||
?int $expectedresult) {
|
||||
public function test_get_grade_completion(bool $completionusegrade, bool $hasgrade, ?int $passinggrade,
|
||||
?string $expectedexception, ?int $expectedresult) {
|
||||
$this->setup_data();
|
||||
|
||||
/** @var \mod_assign_generator $assigngenerator */
|
||||
|
@ -48,18 +48,17 @@ class core_curl_security_helper_testcase extends advanced_testcase {
|
||||
public function test_curl_security_helper_url_is_blocked($dns, $url, $blockedhosts, $allowedports, $expected) {
|
||||
$this->resetAfterTest(true);
|
||||
$helper = $this->getMockBuilder('\core\files\curl_security_helper')
|
||||
->onlyMethods(['get_host_list_by_name'])
|
||||
->getMock();
|
||||
->onlyMethods(['get_host_list_by_name'])
|
||||
->getMock();
|
||||
|
||||
// Override the get host list method to return hard coded values based on a mapping provided by $dns.
|
||||
$helper->method('get_host_list_by_name')
|
||||
->will(
|
||||
$this->returnCallback(
|
||||
function($host) use ($dns) {
|
||||
return isset($dns[$host]) ? $dns[$host] : [];
|
||||
}
|
||||
)
|
||||
);
|
||||
$helper->method('get_host_list_by_name')->will(
|
||||
$this->returnCallback(
|
||||
function($host) use ($dns) {
|
||||
return isset($dns[$host]) ? $dns[$host] : [];
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
set_config('curlsecurityblockedhosts', $blockedhosts);
|
||||
set_config('curlsecurityallowedport', $allowedports);
|
||||
|
@ -54,8 +54,10 @@ class core_filter_manager_testcase extends advanced_testcase {
|
||||
public function test_filter_normal() {
|
||||
$this->resetAfterTest();
|
||||
filter_set_global_state('emoticon', TEXTFILTER_ON);
|
||||
$this->assertMatchesRegularExpression('~^<p><img class="icon emoticon" alt="smile" title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p>$~',
|
||||
$this->filter_text('<p>:-)</p>', array()));
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~^<p><img class="icon emoticon" alt="smile" title="smile" ' .
|
||||
'src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p>$~',
|
||||
$this->filter_text('<p>:-)</p>', array()));
|
||||
}
|
||||
|
||||
public function test_one_filter_disabled() {
|
||||
@ -68,15 +70,17 @@ class core_filter_manager_testcase extends advanced_testcase {
|
||||
public function test_disabling_other_filter_does_not_break_it() {
|
||||
$this->resetAfterTest();
|
||||
filter_set_global_state('emoticon', TEXTFILTER_ON);
|
||||
$this->assertMatchesRegularExpression('~^<p><img class="icon emoticon" alt="smile" title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p>$~',
|
||||
$this->filter_text('<p>:-)</p>', array('urltolink')));
|
||||
$this->assertMatchesRegularExpression('~^<p><img class="icon emoticon" alt="smile" ' .
|
||||
'title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p>$~',
|
||||
$this->filter_text('<p>:-)</p>', array('urltolink')));
|
||||
}
|
||||
|
||||
public function test_one_filter_of_two_disabled() {
|
||||
$this->resetAfterTest();
|
||||
filter_set_global_state('emoticon', TEXTFILTER_ON);
|
||||
filter_set_global_state('urltolink', TEXTFILTER_ON);
|
||||
$this->assertMatchesRegularExpression('~^<p><img class="icon emoticon" alt="smile" title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /> http://google.com/</p>$~',
|
||||
$this->filter_text('<p>:-) http://google.com/</p>', array('glossary', 'urltolink')));
|
||||
$this->assertMatchesRegularExpression('~^<p><img class="icon emoticon" alt="smile" title="smile" ' .
|
||||
'src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /> http://google.com/</p>$~',
|
||||
$this->filter_text('<p>:-) http://google.com/</p>', array('glossary', 'urltolink')));
|
||||
}
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ class core_filterlib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
protected function setup_available_in_context_tests() {
|
||||
$course = $this->getDataGenerator()->create_course(array('category'=>1));
|
||||
$course = $this->getDataGenerator()->create_course(array('category' => 1));
|
||||
|
||||
$childcontext = context_coursecat::instance(1);
|
||||
$childcontext2 = context_course::instance($course->id);
|
||||
@ -704,7 +704,7 @@ class core_filterlib_testcase extends advanced_testcase {
|
||||
|
||||
$this->assertFileExists("$CFG->dirroot/filter/emailprotect"); // Any standard filter.
|
||||
$this->assertFileExists("$CFG->dirroot/filter/tidy"); // Any standard filter.
|
||||
$this->assertFileDoesNotExist("$CFG->dirroot/filter/grgrggr"); // Any non-existent filter
|
||||
$this->assertFileDoesNotExist("$CFG->dirroot/filter/grgrggr"); // Any non-existent filter.
|
||||
|
||||
// Setup fixture.
|
||||
set_config('filterall', 0);
|
||||
|
@ -2582,7 +2582,8 @@ EOF;
|
||||
|
||||
// Max username length is 100 chars. Select up to limit - (length of current time + 1 [period character]) from users email.
|
||||
$expectedemail = core_text::substr($user->email, 0, 100 - ($timestrlength + 1));
|
||||
$this->assertMatchesRegularExpression('/^' . preg_quote($expectedemail) . '\.\d{' . $timestrlength . '}$/', $usernamedeleted);
|
||||
$this->assertMatchesRegularExpression('/^' . preg_quote($expectedemail) . '\.\d{' . $timestrlength . '}$/',
|
||||
$usernamedeleted);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +93,8 @@ class core_plugin_manager_testcase extends advanced_testcase {
|
||||
$installed = core_plugin_manager::instance()->get_installed_plugins($type);
|
||||
foreach ($installed as $plugin => $version) {
|
||||
$this->assertMatchesRegularExpression('/^[a-z]+[a-z0-9_]*$/', $plugin);
|
||||
$this->assertTrue(is_numeric($version), 'All plugins should have a version, plugin '.$type.'_'.$plugin.' does not have version info.');
|
||||
$this->assertTrue(is_numeric($version),
|
||||
'All plugins should have a version, plugin '.$type.'_'.$plugin.' does not have version info.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -119,9 +120,11 @@ class core_plugin_manager_testcase extends advanced_testcase {
|
||||
$present = core_plugin_manager::instance()->get_present_plugins($type);
|
||||
if (is_array($present)) {
|
||||
foreach ($present as $plugin => $version) {
|
||||
$this->assertMatchesRegularExpression('/^[a-z]+[a-z0-9_]*$/', $plugin, 'All plugins are supposed to have version.php file.');
|
||||
$this->assertMatchesRegularExpression('/^[a-z]+[a-z0-9_]*$/', $plugin,
|
||||
'All plugins are supposed to have version.php file.');
|
||||
$this->assertIsObject($version);
|
||||
$this->assertTrue(is_numeric($version->version), 'All plugins should have a version, plugin '.$type.'_'.$plugin.' does not have version info.');
|
||||
$this->assertTrue(is_numeric($version->version),
|
||||
'All plugins should have a version, plugin '.$type.'_'.$plugin.' does not have version info.');
|
||||
}
|
||||
} else {
|
||||
// No plugins of this type exist.
|
||||
|
@ -43,8 +43,10 @@ class core_setuplib_testcase extends advanced_testcase {
|
||||
} else {
|
||||
$docroot = $CFG->docroot;
|
||||
}
|
||||
$this->assertMatchesRegularExpression('~^' . preg_quote($docroot, '') . '/\d{2,3}/' . current_language() . '/course/editing$~',
|
||||
get_docs_url('course/editing'));
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~^' . preg_quote($docroot, '') . '/\d{2,3}/' . current_language() . '/course/editing$~',
|
||||
get_docs_url('course/editing')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,8 +94,10 @@ class core_setuplib_testcase extends advanced_testcase {
|
||||
$exception = new moodle_exception('generalexceptionmessage', 'error', '', $fixture, $fixture);
|
||||
$exceptioninfo = get_exception_info($exception);
|
||||
|
||||
$this->assertStringContainsString($expected, $exceptioninfo->message, 'Exception message does not contain system paths');
|
||||
$this->assertStringContainsString($expected, $exceptioninfo->debuginfo, 'Exception debug info does not contain system paths');
|
||||
$this->assertStringContainsString($expected, $exceptioninfo->message,
|
||||
'Exception message does not contain system paths');
|
||||
$this->assertStringContainsString($expected, $exceptioninfo->debuginfo,
|
||||
'Exception debug info does not contain system paths');
|
||||
}
|
||||
|
||||
public function test_localcachedir() {
|
||||
|
@ -53,7 +53,8 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/',
|
||||
quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@ -77,7 +78,8 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/',
|
||||
quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@ -119,7 +121,8 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/',
|
||||
quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@ -152,7 +155,8 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/',
|
||||
quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@ -169,7 +173,8 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertMatchesRegularExpression('/Unfortunately your account on this site is disabled/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/Unfortunately your account on this site is disabled/',
|
||||
quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@ -189,7 +194,8 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertMatchesRegularExpression('/Unfortunately passwords cannot be reset on this site/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/Unfortunately passwords cannot be reset on this site/',
|
||||
quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
|
@ -168,9 +168,12 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$this->assertMatchesRegularExpression('~<source src="http://example.org/2.webm"~', $content);
|
||||
$this->assertMatchesRegularExpression('~<source src="http://example.org/3.ogv"~', $content);
|
||||
// Links to all files are included.
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/1.rv">1.rv</a>~', $content);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/2.webm">2.webm</a>~', $content);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/3.ogv">3.ogv</a>~', $content);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="http://example.org/1.rv">1.rv</a>~', $content);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="http://example.org/2.webm">2.webm</a>~', $content);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="http://example.org/3.ogv">3.ogv</a>~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,7 +188,8 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_videojs~', $content);
|
||||
$this->assertEquals(1, substr_count($content, '</video>'));
|
||||
$this->assertDoesNotMatchRegularExpression('~mediaplugin_html5video~', $content);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/some_filename.webm">Apply one player only</a>~', $content);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="http://example.org/some_filename.webm">Apply one player only</a>~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -343,14 +347,16 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$this->flash_plugin_engaged($t);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $t);
|
||||
$this->assertMatchesRegularExpression('~<source src="http://example.org/some_filename.flv"~', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/some_filename.flv">some_filename.flv</a>~', $t);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="http://example.org/some_filename.flv">some_filename.flv</a>~', $t);
|
||||
|
||||
// Flash disabled.
|
||||
set_config('useflash', 0, 'media_videojs');
|
||||
$url = new moodle_url('http://example.org/some_filename.flv');
|
||||
$t = $manager->embed_url($url);
|
||||
$this->assertStringNotContainsString('mediaplugin_videojs', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/some_filename.flv">some_filename.flv</a>~', $t);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="http://example.org/some_filename.flv">some_filename.flv</a>~', $t);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -365,7 +371,8 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');
|
||||
$t = $manager->embed_url($url);
|
||||
$this->assertStringNotContainsString('mediaplugin_videojs', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
|
||||
// RTMP enabled, flash disabled.
|
||||
set_config('useflash', 0, 'media_videojs');
|
||||
@ -373,7 +380,8 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');
|
||||
$t = $manager->embed_url($url);
|
||||
$this->assertStringNotContainsString('mediaplugin_videojs', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
|
||||
// RTMP enabled, flash enabled, rtmp/mp4 type expected.
|
||||
set_config('useflash', 1, 'media_videojs');
|
||||
@ -382,8 +390,10 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$t = $manager->embed_url($url);
|
||||
$this->flash_plugin_engaged($t);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $t);
|
||||
$this->assertMatchesRegularExpression('~<source src="rtmp://example.com/fms&mp4:path/to/file.mp4" type="rtmp/mp4"~', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<source src="rtmp://example.com/fms&mp4:path/to/file.mp4" type="rtmp/mp4"~', $t);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
|
||||
// RTMP enabled, flash enabled, rtmp/flv type expected.
|
||||
set_config('useflash', 1, 'media_videojs');
|
||||
@ -392,7 +402,9 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$t = $manager->embed_url($url);
|
||||
$this->flash_plugin_engaged($t);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $t);
|
||||
$this->assertMatchesRegularExpression('~<source src="rtmp://example.com/fms&flv:path/to/file.flv" type="rtmp/flv"~', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="rtmp://example.com/fms&flv:path/to/file.flv">file.flv</a>~', $t);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<source src="rtmp://example.com/fms&flv:path/to/file.flv" type="rtmp/flv"~', $t);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~<a class="mediafallbacklink" href="rtmp://example.com/fms&flv:path/to/file.flv">file.flv</a>~', $t);
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +232,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertStringContainsString('the assignment intro text here', $assignment['intro']);
|
||||
$this->assertNotEmpty($assignment['configs']);
|
||||
// Check the url of the file attatched.
|
||||
$this->assertMatchesRegularExpression('@"' . $CFG->wwwroot . '/webservice/pluginfile.php/\d+/mod_assign/intro/intro\.txt"@', $assignment['intro']);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'@"' . $CFG->wwwroot . '/webservice/pluginfile.php/\d+/mod_assign/intro/intro\.txt"@', $assignment['intro']);
|
||||
$this->assertEquals(1, $assignment['markingworkflow']);
|
||||
$this->assertEquals(1, $assignment['markingallocation']);
|
||||
$this->assertEquals(0, $assignment['preventsubmissionnotingroup']);
|
||||
@ -649,27 +650,22 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
$student1 = self::getDataGenerator()->create_user();
|
||||
$student2 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id, $course->id, $studentrole->id);
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
|
||||
// Create a student1 with an online text submission.
|
||||
// Simulate a submission.
|
||||
$this->setUser($student1);
|
||||
$submission = $assign->get_user_submission($student1->id, true);
|
||||
$data = new stdClass();
|
||||
$data->onlinetext_editor = array('itemid'=>file_get_unused_draft_itemid(),
|
||||
'text'=>'Submission text',
|
||||
'format'=>FORMAT_MOODLE);
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
'format' => FORMAT_MOODLE);
|
||||
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
||||
$plugin->save($submission, $data);
|
||||
|
||||
@ -685,9 +681,10 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$this->setUser($student2);
|
||||
$submission = $assign->get_user_submission($student2->id, true);
|
||||
$data = new stdClass();
|
||||
$data->onlinetext_editor = array('itemid'=>file_get_unused_draft_itemid(),
|
||||
'text'=>'Submission text',
|
||||
'format'=>FORMAT_MOODLE);
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
'format' => FORMAT_MOODLE);
|
||||
$notices = array();
|
||||
$this->expectException(moodle_exception::class);
|
||||
$assign->save_submission($data, $notices);
|
||||
@ -714,27 +711,22 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
$student1 = self::getDataGenerator()->create_user();
|
||||
$student2 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id, $course->id, $studentrole->id);
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
|
||||
// Create a student1 with an online text submission.
|
||||
// Simulate a submission.
|
||||
$this->setUser($student1);
|
||||
$submission = $assign->get_user_submission($student1->id, true);
|
||||
$data = new stdClass();
|
||||
$data->onlinetext_editor = array('itemid'=>file_get_unused_draft_itemid(),
|
||||
'text'=>'Submission text',
|
||||
'format'=>FORMAT_MOODLE);
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
'format' => FORMAT_MOODLE);
|
||||
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
||||
$plugin->save($submission, $data);
|
||||
|
||||
@ -756,9 +748,10 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$this->setUser($student2);
|
||||
$submission = $assign->get_user_submission($student2->id, true);
|
||||
$data = new stdClass();
|
||||
$data->onlinetext_editor = array('itemid'=>file_get_unused_draft_itemid(),
|
||||
'text'=>'Submission text',
|
||||
'format'=>FORMAT_MOODLE);
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
'format' => FORMAT_MOODLE);
|
||||
$notices = array();
|
||||
$assign->save_submission($data, $notices);
|
||||
}
|
||||
@ -787,19 +780,18 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$assign = new assign($context, $cm, $course);
|
||||
|
||||
$student1 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
|
||||
// Create a student1 with an online text submission.
|
||||
// Simulate a submission.
|
||||
$this->setUser($student1);
|
||||
$submission = $assign->get_user_submission($student1->id, true);
|
||||
$data = new stdClass();
|
||||
$data->onlinetext_editor = array('itemid'=>file_get_unused_draft_itemid(),
|
||||
'text'=>'Submission text',
|
||||
'format'=>FORMAT_MOODLE);
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
'format' => FORMAT_MOODLE);
|
||||
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
||||
$plugin->save($submission, $data);
|
||||
|
||||
@ -831,15 +823,13 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
$this->setUser($teacher);
|
||||
|
||||
$now = time();
|
||||
$yesterday = $now - 24*60*60;
|
||||
$tomorrow = $now + 24*60*60;
|
||||
$yesterday = $now - 24 * 60 * 60;
|
||||
$tomorrow = $now + 24 * 60 * 60;
|
||||
set_config('submissionreceipts', 0, 'assign');
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
||||
$params['course'] = $course->id;
|
||||
@ -854,10 +844,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$assign = new assign($context, $cm, $course);
|
||||
|
||||
$student1 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
|
||||
$this->setUser($student1);
|
||||
$result = mod_assign_external::submit_for_grading($instance->id, true);
|
||||
@ -889,7 +877,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$this->setUser($student1);
|
||||
$result = mod_assign_external::save_user_extensions($instance->id, array($student1->id), array($now, $tomorrow));
|
||||
$result = external_api::clean_returnvalue(mod_assign_external::save_user_extensions_returns(), $result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -903,10 +890,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
$this->setUser($teacher);
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
||||
@ -921,10 +906,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$assign = new assign($context, $cm, $course);
|
||||
|
||||
$student1 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
|
||||
$this->setUser($student1);
|
||||
$this->expectException(required_capability_exception::class);
|
||||
@ -979,18 +962,12 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
$student1 = self::getDataGenerator()->create_user();
|
||||
$student2 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id, $course->id, $studentrole->id);
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
|
||||
// Create a student1 with an online text submission.
|
||||
// Simulate a submission.
|
||||
@ -1007,7 +984,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
// Check for 0 warnings.
|
||||
$this->assertEquals(0, count($result));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1021,10 +997,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
$this->setUser($teacher);
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
||||
@ -1032,7 +1006,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$params['assignsubmission_onlinetext_enabled'] = 1;
|
||||
$params['assignsubmission_file_enabled'] = 1;
|
||||
$params['assignsubmission_file_maxfiles'] = 5;
|
||||
$params['assignsubmission_file_maxsizebytes'] = 1024*1024;
|
||||
$params['assignsubmission_file_maxsizebytes'] = 1024 * 1024;
|
||||
$instance = $generator->create_instance($params);
|
||||
$cm = get_coursemodule_from_instance('assign', $instance->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
@ -1041,13 +1015,9 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
$student1 = self::getDataGenerator()->create_user();
|
||||
$student2 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id, $course->id, $studentrole->id);
|
||||
// Create a student1 with an online text submission.
|
||||
// Simulate a submission.
|
||||
$this->setUser($student1);
|
||||
@ -1085,9 +1055,10 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
// Now try a submission.
|
||||
$submissionpluginparams = array();
|
||||
$submissionpluginparams['files_filemanager'] = $draftidfile;
|
||||
$onlinetexteditorparams = array('text' => '<p>Yeeha!</p>',
|
||||
'format'=>1,
|
||||
'itemid'=>$draftidonlinetext);
|
||||
$onlinetexteditorparams = array(
|
||||
'text' => '<p>Yeeha!</p>',
|
||||
'format' => 1,
|
||||
'itemid' => $draftidonlinetext);
|
||||
$submissionpluginparams['onlinetext_editor'] = $onlinetexteditorparams;
|
||||
$result = mod_assign_external::save_submission($instance->id, $submissionpluginparams);
|
||||
$result = external_api::clean_returnvalue(mod_assign_external::save_submission_returns(), $result);
|
||||
@ -1117,10 +1088,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
$this->setUser($teacher);
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
||||
@ -1167,14 +1136,15 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$feedbackeditorparams = array('text' => 'Yeeha!',
|
||||
'format' => 1);
|
||||
$feedbackpluginparams['assignfeedbackcomments_editor'] = $feedbackeditorparams;
|
||||
$result = mod_assign_external::save_grade($instance->id,
|
||||
$student1->id,
|
||||
50.0,
|
||||
-1,
|
||||
true,
|
||||
'released',
|
||||
false,
|
||||
$feedbackpluginparams);
|
||||
$result = mod_assign_external::save_grade(
|
||||
$instance->id,
|
||||
$student1->id,
|
||||
50.0,
|
||||
-1,
|
||||
true,
|
||||
'released',
|
||||
false,
|
||||
$feedbackpluginparams);
|
||||
// No warnings.
|
||||
$this->assertNull($result);
|
||||
|
||||
@ -1196,9 +1166,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
||||
$params['course'] = $course->id;
|
||||
@ -1213,12 +1181,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$student1 = self::getDataGenerator()->create_user();
|
||||
$student2 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id, $course->id, $studentrole->id);
|
||||
|
||||
$this->setUser($teacher);
|
||||
|
||||
@ -1353,9 +1317,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
|
||||
$groupingdata = array();
|
||||
$groupingdata['courseid'] = $course->id;
|
||||
@ -1391,18 +1353,10 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$student3 = self::getDataGenerator()->create_user();
|
||||
$student4 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student3->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student4->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student2->id, $course->id, $studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student3->id, $course->id, $studentrole->id);
|
||||
$this->getDataGenerator()->enrol_user($student4->id, $course->id, $studentrole->id);
|
||||
|
||||
groups_add_member($group1->id, $student1->id);
|
||||
groups_add_member($group1->id, $student2->id);
|
||||
@ -1463,15 +1417,15 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals(0, count($result));
|
||||
|
||||
$student3grade = $DB->get_record('assign_grades',
|
||||
array('userid' => $student3->id, 'assignment' => $instance->id),
|
||||
'*',
|
||||
MUST_EXIST);
|
||||
array('userid' => $student3->id, 'assignment' => $instance->id),
|
||||
'*',
|
||||
MUST_EXIST);
|
||||
$this->assertEquals($student3grade->grade, '50.0');
|
||||
|
||||
$student4grade = $DB->get_record('assign_grades',
|
||||
array('userid' => $student4->id, 'assignment' => $instance->id),
|
||||
'*',
|
||||
MUST_EXIST);
|
||||
array('userid' => $student4->id, 'assignment' => $instance->id),
|
||||
'*',
|
||||
MUST_EXIST);
|
||||
$this->assertEquals($student4grade->grade, '75.0');
|
||||
}
|
||||
|
||||
@ -1486,10 +1440,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id,
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
|
||||
$this->setUser($teacher);
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
||||
@ -1506,17 +1458,13 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$assign = new assign($context, $cm, $course);
|
||||
|
||||
$student1 = self::getDataGenerator()->create_user();
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id,
|
||||
$course->id,
|
||||
$studentrole->id);
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
|
||||
// Now try a submission.
|
||||
$this->setUser($student1);
|
||||
$draftidonlinetext = file_get_unused_draft_itemid();
|
||||
$submissionpluginparams = array();
|
||||
$onlinetexteditorparams = array('text'=>'Yeeha!',
|
||||
'format'=>1,
|
||||
'itemid'=>$draftidonlinetext);
|
||||
$onlinetexteditorparams = array('text' => 'Yeeha!', 'format' => 1, 'itemid' => $draftidonlinetext);
|
||||
$submissionpluginparams['onlinetext_editor'] = $onlinetexteditorparams;
|
||||
$submissionpluginparams['files_filemanager'] = file_get_unused_draft_itemid();
|
||||
$result = mod_assign_external::save_submission($instance->id, $submissionpluginparams);
|
||||
@ -1527,17 +1475,17 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
// Now try a grade.
|
||||
$feedbackpluginparams = array();
|
||||
$feedbackpluginparams['files_filemanager'] = file_get_unused_draft_itemid();
|
||||
$feedbackeditorparams = array('text'=>'Yeeha!',
|
||||
'format'=>1);
|
||||
$feedbackeditorparams = array('text' => 'Yeeha!', 'format' => 1);
|
||||
$feedbackpluginparams['assignfeedbackcomments_editor'] = $feedbackeditorparams;
|
||||
$result = mod_assign_external::save_grade($instance->id,
|
||||
$student1->id,
|
||||
50.0,
|
||||
-1,
|
||||
true,
|
||||
'released',
|
||||
false,
|
||||
$feedbackpluginparams);
|
||||
$result = mod_assign_external::save_grade(
|
||||
$instance->id,
|
||||
$student1->id,
|
||||
50.0,
|
||||
-1,
|
||||
true,
|
||||
'released',
|
||||
false,
|
||||
$feedbackpluginparams);
|
||||
$this->assertNull($result);
|
||||
|
||||
$this->setUser($student1);
|
||||
@ -1925,9 +1873,10 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$submission = $assign->get_user_submission($student1->id, true);
|
||||
|
||||
$data = new stdClass();
|
||||
$data->onlinetext_editor = array('itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text with a <a href="@@PLUGINFILE@@/intro.txt">link</a>',
|
||||
'format' => FORMAT_MOODLE);
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text with a <a href="@@PLUGINFILE@@/intro.txt">link</a>',
|
||||
'format' => FORMAT_MOODLE);
|
||||
|
||||
$draftidfile = file_get_unused_draft_itemid();
|
||||
$usercontext = context_user::instance($student1->id);
|
||||
@ -2121,14 +2070,15 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$feedbackeditorparams = array('text' => 'Yeeha!',
|
||||
'format' => 1);
|
||||
$feedbackpluginparams['assignfeedbackcomments_editor'] = $feedbackeditorparams;
|
||||
$result = mod_assign_external::save_grade($instance->id,
|
||||
$student1->id,
|
||||
50.0,
|
||||
-1,
|
||||
false,
|
||||
'released',
|
||||
false,
|
||||
$feedbackpluginparams);
|
||||
$result = mod_assign_external::save_grade(
|
||||
$instance->id,
|
||||
$student1->id,
|
||||
50.0,
|
||||
-1,
|
||||
false,
|
||||
'released',
|
||||
false,
|
||||
$feedbackpluginparams);
|
||||
$USER->ignoresesskey = true;
|
||||
$assign->testable_process_add_attempt($student1->id);
|
||||
|
||||
@ -2548,9 +2498,10 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$assign->testable_update_submission($submission, $student->id, true, false);
|
||||
$data = new stdClass();
|
||||
$data->onlinetext_editor = array('itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
'format' => FORMAT_MOODLE);
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
'format' => FORMAT_MOODLE);
|
||||
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
||||
$plugin->save($submission, $data);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -211,8 +211,9 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes
|
||||
$this->quba->get_right_answer_summary($this->slot));
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($mc->questiontext, '/') . '/',
|
||||
$this->quba->get_question_summary($this->slot));
|
||||
$this->assertMatchesRegularExpression('/(B|C) \[' . preg_quote(question_cbm::get_short_string(question_cbm::MED), '/') . '\]/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/(B|C) \[' . preg_quote(question_cbm::get_short_string(question_cbm::MED), '/') . '\]/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
|
||||
// Save the old attempt.
|
||||
$oldqa = $this->quba->get_question_attempt($this->slot);
|
||||
@ -249,8 +250,9 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes
|
||||
$this->get_contains_mc_radio_expectation($rightindex, false, true),
|
||||
$this->get_contains_cbm_radio_expectation(question_cbm::HIGH, false, true),
|
||||
$this->get_contains_correct_expectation());
|
||||
$this->assertMatchesRegularExpression('/(A) \[' . preg_quote(question_cbm::get_short_string(question_cbm::HIGH), '/') . '\]/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/(A) \[' . preg_quote(question_cbm::get_short_string(question_cbm::HIGH), '/') . '\]/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
}
|
||||
|
||||
public function test_deferred_cbm_truefalse_no_certainty_feedback_when_not_answered() {
|
||||
|
@ -233,7 +233,8 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_state(question_state::$needsgrading);
|
||||
$this->check_current_mark(null);
|
||||
$this->render();
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote(s('Once upon a time there was a little green frog.'), '/') . '/', $this->currentoutput);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/' . preg_quote(s('Once upon a time there was a little green frog.'), '/') . '/', $this->currentoutput);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($q),
|
||||
$this->get_contains_general_feedback_expectation($q));
|
||||
@ -497,7 +498,8 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->load_quba();
|
||||
$this->render();
|
||||
// Test taht no HTML comment has been added to the response.
|
||||
$this->assertMatchesRegularExpression('/Once upon a time there was a frog called Freddy. He lived happily ever after.(?!<!--)/', $this->currentoutput);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/Once upon a time there was a frog called Freddy. He lived happily ever after.(?!<!--)/', $this->currentoutput);
|
||||
// Test for the hash of an empty file area.
|
||||
$this->assertStringNotContainsString('d41d8cd98f00b204e9800998ecf8427e', $this->currentoutput);
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ class webservice_xmlrpc_locallib_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_prepare_response($returnsdesc, $returns, $expected) {
|
||||
$server = $this->getMockBuilder('webservice_xmlrpc_server')
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
|
||||
$rc = new \ReflectionClass('webservice_xmlrpc_server');
|
||||
$rcm = $rc->getMethod('prepare_response');
|
||||
@ -96,9 +96,9 @@ class webservice_xmlrpc_locallib_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_generate_error($exception, $code, $expected) {
|
||||
$server = $this->getMockBuilder('webservice_xmlrpc_server')
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
|
||||
$rc = new \ReflectionClass('webservice_xmlrpc_server');
|
||||
$rcm = $rc->getMethod('generate_error');
|
||||
|
@ -57,12 +57,12 @@ class xmlrpc_server_test extends advanced_testcase {
|
||||
*/
|
||||
public function test_parse_request($input, $expectfunction, $expectparams) {
|
||||
$server = $this->getMockBuilder('\webservice_xmlrpc_server')
|
||||
->onlyMethods(['fetch_input_content'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
->onlyMethods(['fetch_input_content'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$server->method('fetch_input_content')
|
||||
->willReturn($input);
|
||||
->willReturn($input);
|
||||
|
||||
$rc = new \ReflectionClass('\webservice_xmlrpc_server');
|
||||
$rcm = $rc->getMethod('parse_request');
|
||||
|
Loading…
x
Reference in New Issue
Block a user