Merge branch 'MDL-56516-master' of git://github.com/andrewnicols/moodle

This commit is contained in:
David Monllao 2016-10-25 12:37:44 +08:00
commit 0add237ef5
3 changed files with 2 additions and 32 deletions

View File

@ -61,10 +61,8 @@ class cache {
$sql = <<<EOF
SELECT t.*
FROM {tool_usertours_tours} t
INNER JOIN {tool_usertours_steps} s ON s.tourid = t.id
WHERE t.enabled = 1
GROUP BY t.id
HAVING COUNT(s.id) > 0
AND t.id IN (SELECT s.tourid FROM {tool_usertours_steps} s GROUP BY s.tourid)
ORDER BY t.sortorder ASC
EOF;

View File

@ -561,7 +561,6 @@ class manager {
public static function get_matching_tours(\moodle_url $pageurl) {
global $PAGE;
$tours = cache::get_matching_tourdata($pageurl->out_as_local_url());
foreach ($tours as $record) {

View File

@ -242,10 +242,7 @@ class tool_usertours_manager_testcase extends advanced_testcase {
$this->resetAfterTest();
foreach ($alltours as $tourconfig) {
$tourconfig = (object) $tourconfig;
$tourconfig->id = null;
$tour = \tool_usertours\tour::load_from_record($tourconfig, true);
$tour->persist(true);
$tour = $this->helper_create_tour((object) $tourconfig);
$this->helper_create_step((object) ['tourid' => $tour->get_id()]);
}
@ -257,28 +254,4 @@ class tool_usertours_manager_testcase extends advanced_testcase {
$this->assertEquals($expected, $match->get_name());
}
}
/**
* Tests for the get_matching_tours function when requiring an upgrade
*
* @dataProvider get_matching_tours_provider
* @param array $alltours The list of tours to insert
* @param string $url The URL to test
* @param string $expected The name of the expected matching tour
*/
public function test_get_matching_tours_requires_upgrade($alltours, $url, $expected) {
$this->resetAfterTest();
global $CFG;
unset($CFG->version);
foreach ($alltours as $tourconfig) {
$tourconfig = (object) $tourconfig;
$tourconfig->id = null;
$tour = \tool_usertours\tour::load_from_record($tourconfig, true);
$tour->persist(true);
}
$this->assertNull(\tool_usertours\manager::get_matching_tours(new moodle_url($url)));
}
}