Exemplo n.º 1
0
 /**
  * Test the public API of the {@link lang_installer} class
  */
 public function test_lang_installer()
 {
     // test the manipulation with the download queue
     $installer = new testable_lang_installer();
     $this->assertFalse($installer->protected_is_queued());
     $installer->protected_add_to_queue('cs');
     $installer->protected_add_to_queue(array('cs', 'sk'));
     $this->assertTrue($installer->protected_is_queued());
     $this->assertTrue($installer->protected_is_queued('cs'));
     $this->assertTrue($installer->protected_is_queued('sk'));
     $this->assertFalse($installer->protected_is_queued('de_kids'));
     $installer->set_queue('de_kids');
     $this->assertFalse($installer->protected_is_queued('cs'));
     $this->assertFalse($installer->protected_is_queued('sk'));
     $this->assertFalse($installer->protected_is_queued('de'));
     $this->assertFalse($installer->protected_is_queued('de_du'));
     $this->assertTrue($installer->protected_is_queued('de_kids'));
     $installer->set_queue(array('cs', 'de_kids'));
     $this->assertTrue($installer->protected_is_queued('cs'));
     $this->assertFalse($installer->protected_is_queued('sk'));
     $this->assertFalse($installer->protected_is_queued('de'));
     $this->assertFalse($installer->protected_is_queued('de_du'));
     $this->assertTrue($installer->protected_is_queued('de_kids'));
     $installer->set_queue(array());
     $this->assertFalse($installer->protected_is_queued());
     unset($installer);
     // install a set of lang packs
     $installer = new testable_lang_installer(array('cs', 'de_kids', 'xx'));
     $result = $installer->run();
     $this->assertEqual($result['cs'], lang_installer::RESULT_UPTODATE);
     $this->assertEqual($result['de_kids'], lang_installer::RESULT_INSTALLED);
     $this->assertEqual($result['xx'], lang_installer::RESULT_DOWNLOADERROR);
     // the following two were automatically added to the queue
     $this->assertEqual($result['de_du'], lang_installer::RESULT_INSTALLED);
     $this->assertEqual($result['de'], lang_installer::RESULT_UPTODATE);
     // exception throwing
     $installer = new testable_lang_installer(array('yy'));
     $this->expectException('lang_installer_exception');
     $installer->run();
 }
Exemplo n.º 2
0
 /**
  * Test the public API of the {@link lang_installer} class.
  */
 public function test_lang_installer()
 {
     // Test the manipulation with the download queue.
     $installer = new testable_lang_installer();
     $this->assertFalse($installer->protected_is_queued());
     $installer->protected_add_to_queue('cs');
     $installer->protected_add_to_queue(array('cs', 'sk'));
     $this->assertTrue($installer->protected_is_queued());
     $this->assertTrue($installer->protected_is_queued('cs'));
     $this->assertTrue($installer->protected_is_queued('sk'));
     $this->assertFalse($installer->protected_is_queued('de_kids'));
     $installer->set_queue('de_kids');
     $this->assertFalse($installer->protected_is_queued('cs'));
     $this->assertFalse($installer->protected_is_queued('sk'));
     $this->assertFalse($installer->protected_is_queued('de'));
     $this->assertFalse($installer->protected_is_queued('de_du'));
     $this->assertTrue($installer->protected_is_queued('de_kids'));
     $installer->set_queue(array('cs', 'de_kids'));
     $this->assertTrue($installer->protected_is_queued('cs'));
     $this->assertFalse($installer->protected_is_queued('sk'));
     $this->assertFalse($installer->protected_is_queued('de'));
     $this->assertFalse($installer->protected_is_queued('de_du'));
     $this->assertTrue($installer->protected_is_queued('de_kids'));
     $installer->set_queue(array());
     $this->assertFalse($installer->protected_is_queued());
     unset($installer);
     // Install a set of lang packs.
     $installer = new testable_lang_installer(array('cs', 'de_kids', 'xx'));
     $result = $installer->run();
     $this->assertSame($result['cs'], lang_installer::RESULT_UPTODATE);
     $this->assertSame($result['de_kids'], lang_installer::RESULT_INSTALLED);
     $this->assertSame($result['xx'], lang_installer::RESULT_DOWNLOADERROR);
     // The following two were automatically added to the queue.
     $this->assertSame($result['de_du'], lang_installer::RESULT_INSTALLED);
     $this->assertSame($result['de'], lang_installer::RESULT_UPTODATE);
     // Exception throwing.
     $installer = new testable_lang_installer(array('yy'));
     try {
         $installer->run();
         $this->fail('lang_installer_exception exception expected');
     } catch (moodle_exception $e) {
         $this->assertInstanceOf('lang_installer_exception', $e);
     }
 }