From 77ac22a5b60620966322e7bc5204d4285bc633f2 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Thu, 4 Sep 2008 11:44:48 +0000 Subject: [PATCH] MDL-15666 sha1 tests for glossary callers. Entry caller test currently fails. --- lib/portfoliolib.php | 2 +- lib/simpletest/testportfoliolib.php | 4 ++ mod/glossary/lib.php | 2 +- .../test_glossary_portfolio_callers.php | 58 +++++++++++++++++++ 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 mod/glossary/simpletest/test_glossary_portfolio_callers.php diff --git a/lib/portfoliolib.php b/lib/portfoliolib.php index f9d44fe9eb..42babe1797 100644 --- a/lib/portfoliolib.php +++ b/lib/portfoliolib.php @@ -1819,7 +1819,7 @@ final class portfolio_user_form extends moodleform { * * Class that handles the various stages of the actual export */ -final class portfolio_exporter { +class portfolio_exporter { private $currentstage; private $caller; diff --git a/lib/simpletest/testportfoliolib.php b/lib/simpletest/testportfoliolib.php index 0500f1d2fa..8e4fab8ecd 100755 --- a/lib/simpletest/testportfoliolib.php +++ b/lib/simpletest/testportfoliolib.php @@ -53,6 +53,10 @@ class portfolio_plugin_test extends portfolio_plugin_push_base { public function get_continue_url() { return ''; } + + public static function get_name() { + return ''; + } } class portfolio_caller_test extends portfolio_caller_base { diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 9695a8713e..ce197ae078 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -2386,7 +2386,7 @@ class glossary_csv_portfolio_caller extends portfolio_module_caller_base { $entries = $DB->get_records('glossary_entries', array('glossaryid' => $this->glossary->id)); list($where, $params) = $DB->get_in_or_equal(array_keys($entries)); - $aliases = $DB->get_records_select('glossary_alias', 'entryid' . $where, $params); + $aliases = $DB->get_records_select('glossary_alias', 'entryid ' . $where, $params); $categoryentries = $DB->get_records_sql('SELECT ec.entryid, c.name FROM {glossary_entries_categories} ec JOIN {glossary_categories} c ON c.id = ec.categoryid diff --git a/mod/glossary/simpletest/test_glossary_portfolio_callers.php b/mod/glossary/simpletest/test_glossary_portfolio_callers.php new file mode 100644 index 0000000000..d4f1c394c8 --- /dev/null +++ b/mod/glossary/simpletest/test_glossary_portfolio_callers.php @@ -0,0 +1,58 @@ +libdir.'/simpletest/testportfoliolib.php'); +require_once($CFG->dirroot.'/mod/glossary/lib.php'); +require_once($CFG->dirroot.'/admin/generator.php'); + +Mock::generate('glossary_entry_portfolio_caller', 'mock_entry_caller'); +Mock::generate('glossary_csv_portfolio_caller', 'mock_csv_caller'); +Mock::generate('portfolio_exporter', 'mock_exporter'); + +class testGlossaryPortfolioCallers extends portfoliolib_test { + + public $glossaries = array(); + public $entries = array(); + public $entry_caller; + public $csv_caller; + + public function setUp() { + global $DB; + + parent::setUp(); + + $settings = array('tiny' => 1, 'quiet' => 1, 'database_prefix' => 'tst_', 'pre_cleanup' => 1, + 'modules_list' => array('glossary'), 'entries_per_glossary' => 20, + 'number_of_students' => 5, 'students_per_course' => 5, 'number_of_sections' => 1, + 'number_of_modules' => 1, 'questions_per_course' => 0); + generator_generate_data($settings); + + $this->glossaries = $DB->get_records('glossary'); + $first_glossary = reset($this->glossaries); + $cm = get_coursemodule_from_instance('glossary', $first_glossary->id); + + $this->entries = $DB->get_records('glossary_entries', array('glossaryid' => $first_glossary->id)); + $first_entry = reset($this->entries); + + $callbackargs = array('id' => $cm->id, 'entryid' => $first_entry->id); + $this->entry_caller = new glossary_entry_portfolio_caller($callbackargs); + $this->entry_caller->set('exporter', new mock_exporter()); + $this->csv_caller = new glossary_csv_portfolio_caller($callbackargs); + $this->csv_caller->set('exporter', new mock_exporter()); + } + + public function tearDown() { + parent::tearDown(); + } + + public function test_entry_caller_sha1() { + $entry_sha1 = $this->entry_caller->get_sha1(); + $this->entry_caller->prepare_package(); + $this->assertEqual($entry_sha1, $this->entry_caller->get_sha1()); + } + + public function test_csv_caller_sha1() { + $csv_sha1 = $this->csv_caller->get_sha1(); + $this->csv_caller->prepare_package(); + $this->assertEqual($csv_sha1, $this->csv_caller->get_sha1()); + } +} +?> -- 2.39.5