public function test_decode_remote_request()
 {
     $installer = testable_tool_installaddon_installer::instance();
     $request = base64_encode(json_encode(array('name' => '<h1>Stamp collection</h1>"; DELETE FROM mdl_users; --', 'component' => 'mod_stampcoll', 'version' => 2013032800)));
     $request = $installer->testable_decode_remote_request($request);
     $this->assertTrue(is_object($request));
     // One, my little hobbit, never trusts the input parameters!
     $this->assertEquals('Stamp collection&quot;; DELETE FROM mdl_users; --', $request->name);
     $this->assertEquals('mod_stampcoll', $request->component);
     $this->assertEquals(2013032800, $request->version);
     $request = base64_encode(json_encode(array('name' => 'Theme with invalid version number', 'component' => 'theme_invalid', 'version' => '1.0')));
     $this->assertSame(false, $installer->testable_decode_remote_request($request));
     $request = base64_encode(json_encode(array('name' => 'Invalid activity name', 'component' => 'mod_invalid_activity', 'version' => 2013032800)));
     $this->assertSame(false, $installer->testable_decode_remote_request($request));
     $request = base64_encode(json_encode(array('name' => 'Moodle 3.0', 'component' => 'core', 'version' => 2022010100)));
     $this->assertSame(false, $installer->testable_decode_remote_request($request));
     $request = base64_encode(json_encode(array('name' => 'Invalid core subsystem', 'component' => 'core_cache', 'version' => 2014123400)));
     $this->assertSame(false, $installer->testable_decode_remote_request($request));
     $request = base64_encode(json_encode(array('name' => 'Non-existing plugintype', 'component' => 'david_mudrak', 'version' => 2012123199)));
     $this->assertSame(false, $installer->testable_decode_remote_request($request));
 }
    public function test_detect_plugin_component_from_versionphp()
    {
        $installer = testable_tool_installaddon_installer::instance();
        $this->assertEquals('bar_bar_conan', $installer->detect_plugin_component_from_versionphp('
$plugin->version  = 2014121300;
  $plugin->component=   "bar_bar_conan"  ; // Go Arnie go!'));
    }
Exemple #3
0
 public function test_make_installfromzip_storage()
 {
     $installer = testable_tool_installaddon_installer::instance();
     // Check we get writable directory.
     $storage1 = $installer->make_installfromzip_storage();
     $this->assertTrue(is_dir($storage1));
     $this->assertTrue(is_writable($storage1));
     file_put_contents($storage1 . '/hello.txt', 'Find me if you can!');
     // Check we get unique directory on each call.
     $storage2 = $installer->make_installfromzip_storage();
     $this->assertTrue(is_dir($storage2));
     $this->assertTrue(is_writable($storage2));
     $this->assertFalse(file_exists($storage2 . '/hello.txt'));
     // Check both are in the same parent directory.
     $this->assertEquals(dirname($storage1), dirname($storage2));
 }