Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 21... Línea 21...
21
 *
21
 *
22
 * @package enrol_lti
22
 * @package enrol_lti
23
 * @copyright 2016 Mark Nelson <markn@moodle.com>
23
 * @copyright 2016 Mark Nelson <markn@moodle.com>
24
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
25
 */
26
class helper_test extends \advanced_testcase {
26
final class helper_test extends \advanced_testcase {
Línea 27... Línea 27...
27
 
27
 
28
    /**
28
    /**
29
     * @var \stdClass $user1 A user.
29
     * @var \stdClass $user1 A user.
30
     */
30
     */
Línea 39... Línea 39...
39
     * Test set up.
39
     * Test set up.
40
     *
40
     *
41
     * This is executed before running any test in this file.
41
     * This is executed before running any test in this file.
42
     */
42
     */
43
    public function setUp(): void {
43
    public function setUp(): void {
-
 
44
        parent::setUp();
44
        $this->resetAfterTest();
45
        $this->resetAfterTest();
Línea 45... Línea 46...
45
 
46
 
46
        // Set this user as the admin.
47
        // Set this user as the admin.
Línea 402... Línea 403...
402
    }
403
    }
Línea 403... Línea 404...
403
 
404
 
404
    /**
405
    /**
405
     * Data provider for the set_xpath test.
406
     * Data provider for the set_xpath test.
406
     */
407
     */
407
    public function set_xpath_provider() {
408
    public static function set_xpath_provider(): array {
408
        return [
409
        return [
409
            "Correct structure" => [
410
            "Correct structure" => [
410
                "parameters" => [
411
                "parameters" => [
411
                    "/root" => [
412
                    "/root" => [
Línea 477... Línea 478...
477
    public function test_set_xpath($parameters, $expected): void {
478
    public function test_set_xpath($parameters, $expected): void {
478
        $helper = new \ReflectionClass('enrol_lti\\helper');
479
        $helper = new \ReflectionClass('enrol_lti\\helper');
479
        $function = $helper->getMethod('set_xpath');
480
        $function = $helper->getMethod('set_xpath');
Línea 480... Línea 481...
480
 
481
 
481
        $document = new \DOMDocument();
482
        $document = new \DOMDocument();
482
        $document->load(realpath(__DIR__ . '/fixtures/input.xml'));
483
        $document->load(realpath(self::get_fixture_path(__NAMESPACE__, 'input.xml')));
483
        $xpath = new \DOMXpath($document);
484
        $xpath = new \DOMXpath($document);
484
        $function->invokeArgs(null, [$xpath, $parameters]);
485
        $function->invokeArgs(null, [$xpath, $parameters]);
485
        $result = $document->saveXML();
486
        $result = $document->saveXML();
486
        $expected = file_get_contents(realpath(__DIR__ . '/fixtures/' . $expected));
487
        $expected = file_get_contents(realpath(self::get_fixture_path(__NAMESPACE__, $expected)));
487
        $this->assertEquals($expected, $result);
488
        $this->assertEquals($expected, $result);
Línea 488... Línea 489...
488
    }
489
    }
489
 
490
 
Línea 501... Línea 502...
501
        ];
502
        ];
502
        $helper = new \ReflectionClass('enrol_lti\\helper');
503
        $helper = new \ReflectionClass('enrol_lti\\helper');
503
        $function = $helper->getMethod('set_xpath');
504
        $function = $helper->getMethod('set_xpath');
Línea 504... Línea 505...
504
 
505
 
505
        $document = new \DOMDocument();
506
        $document = new \DOMDocument();
506
        $document->load(realpath(__DIR__ . '/fixtures/input.xml'));
507
        $document->load(realpath(self::get_fixture_path(__NAMESPACE__, 'input.xml')));
Línea 507... Línea 508...
507
        $xpath = new \DOMXpath($document);
508
        $xpath = new \DOMXpath($document);
508
 
509
 
509
        $this->expectException('coding_exception');
510
        $this->expectException('coding_exception');