|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 require_once("$CFG->libdir/simpletest/testportfoliolib.php"); 00003 require_once("$CFG->dirroot/portfolio/boxnet/lib.php"); 00004 00005 /* 00006 * TODO: The portfolio unit tests were obselete and did not work. 00007 * They have been commented out so that they do not break the 00008 * unit tests in Moodle 2. 00009 * 00010 * At some point: 00011 * 1. These tests should be audited to see which ones were valuable. 00012 * 2. The useful ones should be rewritten using the current standards 00013 * for writing test cases. 00014 * 00015 * This might be left until Moodle 2.1 when the test case framework 00016 * is due to change. 00017 */ 00018 Mock::generate('boxclient', 'mock_boxclient'); 00019 Mock::generatePartial('portfolio_plugin_boxnet', 'mock_boxnetplugin', array('ensure_ticket', 'ensure_account_tree')); 00020 00021 class testPortfolioPluginBoxnet extends portfoliolib_test { 00022 /* 00023 public static $includecoverage = array('lib/portfoliolib.php', 'portfolio/boxnet/lib.php'); 00024 public function setUp() { 00025 global $DB; 00026 00027 parent::setUp(); 00028 $this->plugin = new mock_boxnetplugin($this); 00029 $this->plugin->boxclient = new mock_boxclient(); 00030 00031 $settings = array('tiny' => 1, 'quiet' => 1, 'database_prefix' => 'tst_', 'pre_cleanup' => 1, 00032 'modules_list' => array('glossary'), 'entries_per_glossary' => 20, 00033 'number_of_students' => 5, 'students_per_course' => 5, 'number_of_sections' => 1, 00034 'number_of_modules' => 1, 'questions_per_course' => 0); 00035 generator_generate_data($settings); 00036 } 00037 00038 public function tearDown() { 00039 parent::tearDown(); 00040 } 00041 00042 public function test_caller_glossary() { 00043 global $DB; 00044 $glossaries = $DB->get_records('glossary'); 00045 print_object($glossaries); 00046 } 00047 00048 public function test_something() { 00049 global $DB; 00050 00051 $ticket = md5(rand(0,873907)); 00052 $authtoken = 'ezfoeompplpug3ofii4nud0d8tvg96e0'; 00053 00054 $this->plugin->setReturnValue('ensure_account_tree', true); 00055 $this->plugin->setReturnValue('ensure_ticket', $ticket); 00056 00057 $this->plugin->boxclient->setReturnValue('renameFile', true); 00058 $this->plugin->boxclient->setReturnValue('uploadFile', array('status' => 'upload_ok', 'id' => array(1))); 00059 $this->plugin->boxclient->setReturnValue('createFolder', array(1 => 'folder 1', 2 => 'folder 2')); 00060 $this->plugin->boxclient->setReturnValue('isError', false); 00061 $this->plugin->boxclient->authtoken = $authtoken; 00062 00063 $this->assertTrue($this->plugin->set('exporter', $this->exporter)); 00064 $this->assertTrue($this->plugin->set('ticket', $ticket)); 00065 $this->assertTrue($this->plugin->set('authtoken', $authtoken)); 00066 $this->plugin->set_export_config(array('folder' => 1)); 00067 00068 $this->assertTrue($this->plugin->prepare_package()); 00069 $this->assertTrue($this->plugin->send_package()); 00070 } 00071 */ 00072 }