MDL-19698 deprecated assign new by ref in portfolio
[moodle.git] / portfolio / boxnet / simpletest / testportfoliopluginboxnet.php
1 <?php
2 require_once("$CFG->libdir/simpletest/testportfoliolib.php");
3 require_once("$CFG->dirroot/portfolio/boxnet/lib.php");
4 require_once("$CFG->dirroot/$CFG->admin/generator.php");
6 Mock::generate('boxclient', 'mock_boxclient');
7 Mock::generatePartial('portfolio_plugin_boxnet', 'mock_boxnetplugin', array('ensure_ticket', 'ensure_account_tree'));
9 class testPortfolioPluginBoxnet extends portfoliolib_test {
10     public static $includecoverage = array('lib/portfoliolib.php', 'portfolio/boxnet/lib.php');
11     public function setUp() {
12         global $DB;
14         parent::setUp();
15         $this->plugin = new mock_boxnetplugin($this);
16         $this->plugin->boxclient = new mock_boxclient();
18         $settings = array('tiny' => 1, 'quiet' => 1, 'database_prefix' => 'tst_', 'pre_cleanup' => 1,
19                           'modules_list' => array('glossary'), 'entries_per_glossary' => 20,
20                           'number_of_students' => 5, 'students_per_course' => 5, 'number_of_sections' => 1,
21                           'number_of_modules' => 1, 'questions_per_course' => 0);
22         generator_generate_data($settings);
23     }
25     public function tearDown() {
26         parent::tearDown();
27     }
29     public function test_caller_glossary() {
30         global $DB;
31         $glossaries = $DB->get_records('glossary');
32         print_object($glossaries);
33     }
35     public function test_something() {
36         global $DB;
38         $ticket = md5(rand(0,873907));
39         $authtoken = 'ezfoeompplpug3ofii4nud0d8tvg96e0';
41         $this->plugin->setReturnValue('ensure_account_tree', true);
42         $this->plugin->setReturnValue('ensure_ticket', $ticket);
44         $this->plugin->boxclient->setReturnValue('renameFile', true);
45         $this->plugin->boxclient->setReturnValue('uploadFile', array('status' => 'upload_ok', 'id' => array(1)));
46         $this->plugin->boxclient->setReturnValue('createFolder', array(1 => 'folder 1', 2 => 'folder 2'));
47         $this->plugin->boxclient->setReturnValue('isError', false);
48         $this->plugin->boxclient->authtoken = $authtoken;
50         $this->assertTrue($this->plugin->set('exporter', $this->exporter));
51         $this->assertTrue($this->plugin->set('ticket', $ticket));
52         $this->assertTrue($this->plugin->set('authtoken', $authtoken));
53         $this->plugin->set_export_config(array('folder' => 1));
55         $this->assertTrue($this->plugin->prepare_package());
56         $this->assertTrue($this->plugin->send_package());
57     }
58 }