mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-69882 phpunit: final removal of deprecated 310 helper methods.
This commit is contained in:
parent
5e1df25566
commit
6b6e7eaad2
@ -147,64 +147,31 @@ abstract class advanced_testcase extends base_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new XMLDataSet with the given $xmlFile. (absolute path.)
|
||||
*
|
||||
* @deprecated since Moodle 3.10 - See MDL-67673 and MDL-64600 for more info.
|
||||
* @todo This will be removed for Moodle 4.2 as part of MDL-69882.
|
||||
*
|
||||
* @param string $xmlFile
|
||||
* @return phpunit_dataset
|
||||
*/
|
||||
protected function createXMLDataSet($xmlFile) {
|
||||
debugging(__FUNCTION__ . '() is deprecated. Please use dataset_from_files() instead.', DEBUG_DEVELOPER);
|
||||
return $this->dataset_from_files([$xmlFile]);
|
||||
protected function createXMLDataSet() {
|
||||
throw new coding_exception(__FUNCTION__ . '() is deprecated. Please use dataset_from_files() instead.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new CsvDataSet from the given array of csv files. (absolute paths.)
|
||||
*
|
||||
* @deprecated since Moodle 3.10 - See MDL-67673 and MDL-64600 for more info.
|
||||
* @todo This will be removed for Moodle 4.2 as part of MDL-69882.
|
||||
*
|
||||
* @param array $files array tablename=>cvsfile
|
||||
* @param string $delimiter unused
|
||||
* @param string $enclosure unused
|
||||
* @param string $escape unused
|
||||
* @return phpunit_dataset
|
||||
*/
|
||||
protected function createCsvDataSet($files, $delimiter = ',', $enclosure = '"', $escape = '"') {
|
||||
debugging(__FUNCTION__ . '() is deprecated. Please use dataset_from_files() instead.', DEBUG_DEVELOPER);
|
||||
return $this->dataset_from_files($files);
|
||||
protected function createCsvDataSet() {
|
||||
throw new coding_exception(__FUNCTION__ . '() is deprecated. Please use dataset_from_files() instead.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new ArrayDataSet from given array
|
||||
*
|
||||
* @deprecated since Moodle 3.10 - See MDL-67673 and MDL-64600 for more info.
|
||||
* @todo This will be removed for Moodle 4.2 as part of MDL-69882.
|
||||
*
|
||||
* @param array $data array of tables, first row in each table is columns
|
||||
* @return phpunit_dataset
|
||||
*/
|
||||
protected function createArrayDataSet(array $data) {
|
||||
debugging(__FUNCTION__ . '() is deprecated. Please use dataset_from_array() instead.', DEBUG_DEVELOPER);
|
||||
return $this->dataset_from_array($data);
|
||||
protected function createArrayDataSet() {
|
||||
throw new coding_exception(__FUNCTION__ . '() is deprecated. Please use dataset_from_array() instead.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load date into moodle database tables from standard PHPUnit data set.
|
||||
*
|
||||
* @deprecated since Moodle 3.10 - See MDL-67673 and MDL-64600 for more info.
|
||||
* @todo This will be removed for Moodle 4.2 as part of MDL-69882.
|
||||
*
|
||||
* Note: it is usually better to use data generators
|
||||
*
|
||||
* @param phpunit_dataset $dataset
|
||||
* @return void
|
||||
*/
|
||||
protected function loadDataSet(phpunit_dataset $dataset) {
|
||||
debugging(__FUNCTION__ . '() is deprecated. Please use dataset->to_database() instead.', DEBUG_DEVELOPER);
|
||||
$dataset->to_database();
|
||||
protected function loadDataSet() {
|
||||
throw new coding_exception(__FUNCTION__ . '() is deprecated. Please use dataset->to_database() instead.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,78 +308,6 @@ class advanced_test extends \advanced_testcase {
|
||||
$this->assertFalse($DB->get_record('user', array('id'=>9999)));
|
||||
}
|
||||
|
||||
public function test_load_data_dataset_xml() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$this->assertFalse($DB->record_exists('user', array('id' => 5)));
|
||||
$this->assertFalse($DB->record_exists('user', array('id' => 7)));
|
||||
$dataset = $this->createXMLDataSet(__DIR__.'/fixtures/sample_dataset.xml');
|
||||
$this->assertDebuggingCalled('createXMLDataSet() is deprecated. Please use dataset_from_files() instead.');
|
||||
$this->loadDataSet($dataset);
|
||||
$this->assertDebuggingCalled('loadDataSet() is deprecated. Please use dataset->to_database() instead.');
|
||||
$this->assertTrue($DB->record_exists('user', array('id' => 5)));
|
||||
$this->assertTrue($DB->record_exists('user', array('id' => 7)));
|
||||
$user5 = $DB->get_record('user', array('id' => 5));
|
||||
$user7 = $DB->get_record('user', array('id' => 7));
|
||||
$this->assertSame('bozka.novakova', $user5->username);
|
||||
$this->assertSame('pepa.novak', $user7->username);
|
||||
|
||||
}
|
||||
|
||||
public function test_load_dataset_csv() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$this->assertFalse($DB->record_exists('user', array('id' => 8)));
|
||||
$this->assertFalse($DB->record_exists('user', array('id' => 9)));
|
||||
$dataset = $this->createCsvDataSet(array('user' => __DIR__.'/fixtures/sample_dataset.csv'));
|
||||
$this->assertDebuggingCalled('createCsvDataSet() is deprecated. Please use dataset_from_files() instead.');
|
||||
$this->loadDataSet($dataset);
|
||||
$this->assertDebuggingCalled('loadDataSet() is deprecated. Please use dataset->to_database() instead.');
|
||||
$this->assertEquals(5, $DB->get_field('user', 'id', array('username' => 'bozka.novakova')));
|
||||
$this->assertEquals(7, $DB->get_field('user', 'id', array('username' => 'pepa.novak')));
|
||||
|
||||
}
|
||||
|
||||
public function test_load_dataset_array() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$data = array(
|
||||
'user' => array(
|
||||
array('username', 'email'),
|
||||
array('top.secret', 'top@example.com'),
|
||||
array('low.secret', 'low@example.com'),
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertFalse($DB->record_exists('user', array('email' => 'top@example.com')));
|
||||
$this->assertFalse($DB->record_exists('user', array('email' => 'low@example.com')));
|
||||
$dataset = $this->createArrayDataSet($data);
|
||||
$this->assertDebuggingCalled('createArrayDataSet() is deprecated. Please use dataset_from_array() instead.');
|
||||
$this->loadDataSet($dataset);
|
||||
$this->assertDebuggingCalled('loadDataSet() is deprecated. Please use dataset->to_database() instead.');
|
||||
$this->assertTrue($DB->record_exists('user', array('email' => 'top@example.com')));
|
||||
$this->assertTrue($DB->record_exists('user', array('email' => 'low@example.com')));
|
||||
|
||||
$data = array(
|
||||
'user' => array(
|
||||
array('username' => 'noidea', 'email' => 'noidea@example.com'),
|
||||
array('username' => 'onemore', 'email' => 'onemore@example.com'),
|
||||
),
|
||||
);
|
||||
$dataset = $this->createArrayDataSet($data);
|
||||
$this->assertDebuggingCalled('createArrayDataSet() is deprecated. Please use dataset_from_array() instead.');
|
||||
$this->loadDataSet($dataset);
|
||||
$this->assertDebuggingCalled('loadDataSet() is deprecated. Please use dataset->to_database() instead.');
|
||||
$this->assertTrue($DB->record_exists('user', array('username' => 'noidea')));
|
||||
$this->assertTrue($DB->record_exists('user', array('username' => 'onemore')));
|
||||
}
|
||||
|
||||
public function test_assert_time_current() {
|
||||
$this->assertTimeCurrent(time());
|
||||
|
||||
|
@ -79,6 +79,11 @@ information provided here is intended especially for developers.
|
||||
Course formats using components will be allowed to use one level indentation only.
|
||||
* The method `flexible_table::set_columnsattributes` now can be used with 'class' key to add custom classes to the DOM.
|
||||
* The editor_tinymce plugin has been removed from core.
|
||||
* The following phpunit advanced testcase helper methods, deprecated since 3.10, have been removed and can no longer be used:
|
||||
- `createXMLDataSet`
|
||||
- `createCsvDataSet`
|
||||
- `createArrayDataSet`
|
||||
- `loadDataSet`
|
||||
|
||||
=== 4.1 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user