dirroot . '/course/lib.php'); class courselib_test extends UnitTestCase { function setUp() { } function tearDown() { } function testReorderSections() { $sections = array(20 => 0, 21 => 1, 22 => 2, 23 => 3, 24 => 4, 25 => 5); $this->assertFalse(reorder_sections(1,3,4)); $newsections = reorder_sections($sections, 2, 4); $newsections_flipped = array_flip($newsections); $this->assertEqual(20, reset($newsections_flipped)); $this->assertEqual(21, next($newsections_flipped)); $this->assertEqual(23, next($newsections_flipped)); $this->assertEqual(24, next($newsections_flipped)); $this->assertEqual(22, next($newsections_flipped)); $this->assertEqual(25, next($newsections_flipped)); $newsections = reorder_sections($sections, 4, 0); $newsections_flipped = array_flip($newsections); $this->assertEqual(20, reset($newsections_flipped)); $this->assertEqual(24, next($newsections_flipped)); $this->assertEqual(21, next($newsections_flipped)); $this->assertEqual(22, next($newsections_flipped)); $this->assertEqual(23, next($newsections_flipped)); $this->assertEqual(25, next($newsections_flipped)); $newsections = reorder_sections($sections, 1, 5); $newsections_flipped = array_flip($newsections); $this->assertEqual(20, reset($newsections_flipped)); $this->assertEqual(22, next($newsections_flipped)); $this->assertEqual(23, next($newsections_flipped)); $this->assertEqual(24, next($newsections_flipped)); $this->assertEqual(25, next($newsections_flipped)); $this->assertEqual(21, next($newsections_flipped)); } }