Example #1
0
 /**
  * Validate scheduled tasks.
  */
 public function test_elis_tasks_get_cached()
 {
     $dataset = $this->createCsvDataSet(array('local_eliscore_sched_tasks' => elis::component_file('eliscore', 'tests/fixtures/elis_scheduled_tasks.csv')));
     $this->loadDataSet($dataset);
     $cachedtasks = elis_tasks_get_cached('elis_program');
     $this->assertNotEmpty($cachedtasks);
     $this->assertInternalType('array', $cachedtasks);
     $this->assertArrayHasKey('s:7:"pm_cron";', $cachedtasks);
     $this->assertNotEmpty($cachedtasks['s:7:"pm_cron";']);
     $this->assertInternalType('array', $cachedtasks['s:7:"pm_cron";']);
 }
Example #2
0
 /**
  * Validate ELIS config settings.
  */
 public function test_elis_config()
 {
     $dataset = $this->createCsvDataSet(array('config_plugins' => elis::component_file('eliscore', 'tests/fixtures/config_plugins.csv')));
     $this->loadDataSet($dataset);
     $elisconfig = new elis_config();
     $pluginconfig = $elisconfig->testplugin;
     $this->assertNotEmpty($pluginconfig);
     $this->assertInternalType('object', $pluginconfig);
     $this->assertObjectHasAttribute('testconfigkey', $pluginconfig);
     $this->assertEquals('testconfigvalue', $pluginconfig->testconfigkey);
 }
Example #3
0
 /**
  * Return the full path name for a PM file.
  */
 static function file($file)
 {
     return elis::component_file('elisprogram', $file);
 }
Example #4
0
 /**
  * Test for duplicate usertrack records.
  */
 public function test_duplicateusertrackdata()
 {
     global $CFG, $DB;
     require_once elispm::lib('data/usertrack.class.php');
     $dataset = $this->createCsvDataSet(array(usertrack::TABLE => elis::component_file('elisprogram', 'tests/fixtures/usertrack_trackassignment_listing.csv')));
     $this->loadDataSet($dataset);
     // Drop the table index so that we can insert a duplicate record.
     $table = new xmldb_table(usertrack::TABLE);
     $index = new xmldb_index('userid_trackid_ix', XMLDB_INDEX_UNIQUE, array('userid', 'trackid'));
     $dbman = $DB->get_manager();
     if ($dbman->index_exists($table, $index)) {
         $dbman->drop_index($table, $index);
     }
     // Should not report any duplicates.
     $duplicatecheck = new duplicate_usertracks();
     $this->assertEquals(0, $duplicatecheck->count);
     // Insert a duplicate record.
     $record = new stdClass();
     $record->userid = 100;
     $record->trackid = 1;
     $DB->insert_record(usertrack::TABLE, $record);
     // Should report duplicates.
     $duplicatecheck = new duplicate_usertracks();
     $this->assertGreaterThan(0, $duplicatecheck->count);
     // Remove duplicate records.
     pm_fix_duplicate_usertrack_records();
     // Should not report any duplicates.
     $duplicatecheck = new duplicate_usertracks();
     $this->assertEquals(0, $duplicatecheck->count);
     // Put the index back.
     $dbman->add_index($table, $index);
 }
Example #5
0
 /**
  * Load test data from CSV file.
  */
 protected function load_userset_csv_data() {
     $dataset = $this->createCsvDataSet(array(
         userset::TABLE => elis::component_file('elisprogram', 'tests/fixtures/userset.csv')
     ));
     $this->loadDataSet($dataset);
 }
 /**
  * Load custom profile field data from CSV.
  */
 protected function load_csv_data()
 {
     $dataset = $this->createCsvDataSet(array('user' => elis::component_file('elisprogram', 'tests/fixtures/mdluser.csv'), 'user_info_field' => elis::component_file('elisprogram', 'tests/fixtures/user_info_field.csv'), 'user_info_data' => elis::component_file('elisprogram', 'tests/fixtures/user_info_data.csv'), user::TABLE => elis::component_file('elisprogram', 'tests/fixtures/pmuser.csv'), usermoodle::TABLE => elis::component_file('elisprogram', 'tests/fixtures/usermoodle.csv'), field::TABLE => elis::component_file('elisprogram', 'tests/fixtures/user_field.csv'), field_owner::TABLE => elis::component_file('elisprogram', 'tests/fixtures/user_field_owner.csv'), userset::TABLE => elis::component_file('elisprogram', 'tests/fixtures/userset.csv')));
     $dataset = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($dataset);
     $dataset->addSubStrReplacement('\\n', "\n");
     $this->loadDataSet($dataset);
 }
Example #7
0
 /**
  * Test validation of duplicates.
  *
  * @expectedException data_object_validation_exception
  * @uses $DB
  */
 public function test_validation_prevents_duplicates()
 {
     global $DB;
     $dataset = $this->createCsvDataSet(array('config' => elis::component_file('eliscore', 'tests/fixtures/phpunit_data_object_test.csv')));
     $this->loadDataSet($dataset);
     $config = new config_object(false, null, array(), false, array(), $DB);
     $config->name = 'foo';
     $config->value = 'foovalue';
     $config->save();
 }