. /** * Tests for servicelib.php * * @package mod_lti * @copyright Copyright (c) 2015 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot.'/mod/lti/servicelib.php'); /** * Tests for servicelib.php * * @package mod_lti * @copyright Copyright (c) 2015 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mod_lti_servicelib_testcase extends basic_testcase { /** * Test that lti_parse_message_id never fails with good and bad XML. * * @dataProvider message_id_provider * @param mixed $expected Expected message ID. * @param string $xml XML to parse. */ public function test_lti_parse_message_id($expected, $xml) { $xml = simplexml_load_string($xml); $this->assertEquals($expected, lti_parse_message_id($xml)); } /** * Test data provider for testing lti_parse_message_id * * @return array */ public function message_id_provider() { $valid = << V1.0 9999 XML; $noheader = << V1.0 9999 XML; $noinfo = << V1.0 9999 XML; $noidentifier = << V1.0 XML; return array( array(9999, $valid), array('', $noheader), array('', $noinfo), array('', $noidentifier), ); } }