示例#1
0
 /**
  * Teset that sortorder is reset according to sortorder with values from 0.
  */
 public function test_reset_step_sortorder()
 {
     $tour = new \tool_usertours\tour();
     $mockdata = [];
     for ($i = 4; $i >= 0; $i--) {
         $id = rand($i * 10, $i * 10 + 9);
         $mockdata[] = (object) ['id' => $id];
         $expectations[] = [$this->equalTo('tool_usertours_steps'), $this->equalTo('sortorder'), 4 - $i, ['id' => $id]];
     }
     // Mock the database.
     $DB = $this->mock_database();
     $DB->expects($this->once())->method('get_records')->willReturn($mockdata);
     $setfield = $DB->expects($this->exactly(5))->method('set_field');
     call_user_func_array([$setfield, 'withConsecutive'], $expectations);
     $tour->reset_step_sortorder();
 }