/** * Method to test pmclass:auto_create_class() * for ELIS-6854 * @dataProvider dataprovider_pmclass_auto_create * @param array $pmclassdata Data to pass to pmclass contructor * @param array $autocreateparams Data to pass to pmclass::auto_create_class * @param bool $accreturn False if pmclass::auto_create_class should return false, true otherwise * @param int $startdate Expected new class startdate * @param int $enddate Expected new class enddate */ public function test_pmclass_auto_create_class($pmclassdata, $autocreateparams, $accreturn, $startdate, $enddate) { global $DB; $datagenerator = new elis_program_datagenerator($DB); $course = $datagenerator->create_course(); if (!empty($pmclassdata['courseid'])) { $pmclassdata['courseid'] = $course->id; } if (!empty($autocreateparams['courseid'])) { $autocreateparams['courseid'] = $course->id; } $pmclass = new pmclass((object) $pmclassdata); $realaccret = $pmclass->auto_create_class($autocreateparams); if ($accreturn) { $this->assertTrue(!empty($realaccret)); $this->assertEquals($startdate, $pmclass->startdate); $this->assertEquals($enddate, $pmclass->enddate); } else { $this->assertFalse($realaccret); } }