Skip to content

Commit

Permalink
MDL-37457 testing Refactoring references
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Jan 15, 2013
1 parent f16e1af commit 5c3c2c8
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 57 deletions.
8 changes: 4 additions & 4 deletions blocks/online_users/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* block_online_users data generator
*
* @package block_online_users
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -27,14 +27,14 @@


/**
* Page module PHPUnit data generator class
* Online users block data generator class
*
* @package mod_page
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_online_users_generator extends phpunit_block_generator {
class block_online_users_generator extends testing_block_generator {

/**
* Create new block instance
Expand Down
2 changes: 1 addition & 1 deletion lib/phpunit/classes/advanced_testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public static function setGuestUser() {
/**
* Get data generator
* @static
* @return phpunit_data_generator
* @return testing_data_generator
*/
public static function getDataGenerator() {
return phpunit_util::get_data_generator();
Expand Down
8 changes: 4 additions & 4 deletions lib/phpunit/classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class phpunit_util {
/** @var int last value of db writes counter, used for db resetting */
public static $lastdbwrites = null;

/** @var phpunit_data_generator */
/** @var testing_data_generator */
protected static $generator = null;

/** @var resource used for prevention of parallel test execution */
Expand Down Expand Up @@ -140,12 +140,12 @@ public static function initialise_cfg() {
/**
* Get data generator
* @static
* @return phpunit_data_generator
* @return testing_data_generator
*/
public static function get_data_generator() {
if (is_null(self::$generator)) {
require_once(__DIR__.'/../generatorlib.php');
self::$generator = new phpunit_data_generator();
require_once(__DIR__.'/../../testing/generator/lib.php');
self::$generator = new testing_data_generator();
}
return self::$generator;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/phpunit/tests/advanced_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function test_change_detection() {

public function test_getDataGenerator() {
$generator = $this->getDataGenerator();
$this->assertInstanceOf('phpunit_data_generator', $generator);
$this->assertInstanceOf('testing_data_generator', $generator);
}

public function test_database_mock1() {
Expand Down
6 changes: 3 additions & 3 deletions lib/testing/generator/block_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class phpunit_block_generator {
/** @var phpunit_data_generator@var */
abstract class testing_block_generator {
/** @var testing_data_generator */
protected $datagenerator;

/** @var number of created instances */
protected $instancecount = 0;

public function __construct(phpunit_data_generator $datagenerator) {
public function __construct(testing_data_generator $datagenerator) {
$this->datagenerator = $datagenerator;
}

Expand Down
12 changes: 6 additions & 6 deletions lib/testing/generator/data_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class phpunit_data_generator {
class testing_data_generator {
protected $usercounter = 0;
protected $categorycount = 0;
protected $cohortcount = 0;
Expand Down Expand Up @@ -84,7 +84,7 @@ public function reset() {
$this->coursecount = 0;
$this->scalecount = 0;

foreach($this->generators as $generator) {
foreach ($this->generators as $generator) {
$generator->reset();
}
}
Expand Down Expand Up @@ -395,11 +395,11 @@ public function create_course_section($record = null, array $options = null) {
$record = (array)$record;

if (empty($record['course'])) {
throw new coding_exception('course must be present in phpunit_data_generator::create_course_section() $record');
throw new coding_exception('course must be present in testing_data_generator::create_course_section() $record');
}

if (!isset($record['section'])) {
throw new coding_exception('section must be present in phpunit_data_generator::create_course_section() $record');
throw new coding_exception('section must be present in testing_data_generator::create_course_section() $record');
}

course_create_sections_if_missing($record['course'], $record['section']);
Expand Down Expand Up @@ -453,7 +453,7 @@ public function create_group($record) {
$record = (array)$record;

if (empty($record['courseid'])) {
throw new coding_exception('courseid must be present in phpunit_data_generator::create_group() $record');
throw new coding_exception('courseid must be present in testing_data_generator::create_group() $record');
}

if (!isset($record['name'])) {
Expand Down Expand Up @@ -496,7 +496,7 @@ public function create_grouping($record) {
$record = (array)$record;

if (empty($record['courseid'])) {
throw new coding_exception('courseid must be present in phpunit_data_generator::create_grouping() $record');
throw new coding_exception('courseid must be present in testing_data_generator::create_grouping() $record');
}

if (!isset($record['name'])) {
Expand Down
10 changes: 5 additions & 5 deletions lib/phpunit/generatorlib.php → lib/testing/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* PHPUnit data generator support
* Adds data generator support
*
* @package core
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

// NOTE: MOODLE_INTERNAL is not verified here because we load this before setup.php!

require_once(__DIR__.'/../testing/generator/data_generator.php');
require_once(__DIR__.'/../testing/generator/module_generator.php');
require_once(__DIR__.'/../testing/generator/block_generator.php');
require_once(__DIR__.'/data_generator.php');
require_once(__DIR__.'/module_generator.php');
require_once(__DIR__.'/block_generator.php');

8 changes: 4 additions & 4 deletions lib/testing/generator/module_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class phpunit_module_generator {
/** @var phpunit_data_generator@var */
abstract class testing_module_generator {
/** @var testing_data_generator@var */
protected $datagenerator;

/** @var number of created instances */
protected $instancecount = 0;

public function __construct(phpunit_data_generator $datagenerator) {
public function __construct(testing_data_generator $datagenerator) {
$this->datagenerator = $datagenerator;
}

Expand Down Expand Up @@ -94,7 +94,7 @@ protected function precreate_course_module($courseid, array $options) {
$cm->added = time();

$columns = $DB->get_columns('course_modules');
foreach ($options as $key=>$value) {
foreach ($options as $key => $value) {
if ($key === 'id' or !isset($columns[$key])) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* PHPUnit integration tests
* Data generators tests
*
* @package core
* @category phpunit
* @category test
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -30,11 +30,11 @@
* Test data generator
*
* @package core
* @category phpunit
* @category test
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_phpunit_generator_testcase extends advanced_testcase {
class core_test_generator_testcase extends advanced_testcase {
public function test_create() {
global $DB;

Expand Down
6 changes: 3 additions & 3 deletions mod/assign/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
defined('MOODLE_INTERNAL') || die();

/**
* assign module PHPUnit data generator class
* assign module data generator class
*
* @package mod_assign
* @category phpunit
* @category testing
* @copyright 2012 Paul Charsley
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_assign_generator extends phpunit_module_generator {
class mod_assign_generator extends testing_module_generator {

/**
* Create new assign module instance
Expand Down
8 changes: 4 additions & 4 deletions mod/assignment/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* mod_assignment data generator
*
* @package mod_assignment
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -27,14 +27,14 @@


/**
* Assignment module PHPUnit data generator class
* Assignment module data generator class
*
* @package mod_assignment
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_assignment_generator extends phpunit_module_generator {
class mod_assignment_generator extends testing_module_generator {

/**
* Create new assignment module instance
Expand Down
8 changes: 4 additions & 4 deletions mod/data/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* mod_data data generator
*
* @package mod_data
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -27,14 +27,14 @@


/**
* Page module PHPUnit data generator class
* Database module data generator class
*
* @package mod_data
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_data_generator extends phpunit_module_generator {
class mod_data_generator extends testing_module_generator {

/**
* Create new data module instance
Expand Down
8 changes: 4 additions & 4 deletions mod/forum/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* mod_forum data generator
*
* @package mod_forum
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -27,14 +27,14 @@


/**
* Assignment module PHPUnit data generator class
* Forum module data generator class
*
* @package mod_forum
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_forum_generator extends phpunit_module_generator {
class mod_forum_generator extends testing_module_generator {

/**
* Create new forum module instance
Expand Down
10 changes: 5 additions & 5 deletions mod/lti/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* mod_lti data generator
*
* @package mod_lti
* @category phpunit
* @category testing
* @copyright Copyright (c) 2012 Moodlerooms Inc. (http://www.moodlerooms.com)
* @author Mark Nielsen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -27,15 +27,15 @@
defined('MOODLE_INTERNAL') || die();

/**
* Assignment module PHPUnit data generator class
* LTI module data generator class
*
* @package mod_lti
* @category phpunit
* @category testing
* @copyright Copyright (c) 2012 Moodlerooms Inc. (http://www.moodlerooms.com)
* @author Mark Nielsen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_lti_generator extends phpunit_module_generator {
class mod_lti_generator extends testing_module_generator {

/**
* Create new lti module instance
Expand Down Expand Up @@ -98,4 +98,4 @@ public function create_instance($record = null, array $options = null) {
$id = lti_add_instance($record, null);
return $this->post_add_instance($id, $record->coursemodule);
}
}
}
8 changes: 4 additions & 4 deletions mod/page/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* mod_page data generator
*
* @package mod_page
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -27,14 +27,14 @@


/**
* Page module PHPUnit data generator class
* Page module data generator class
*
* @package mod_page
* @category phpunit
* @category testing
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_page_generator extends phpunit_module_generator {
class mod_page_generator extends testing_module_generator {

/**
* Create new page module instance
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_generator extends phpunit_module_generator {
class mod_quiz_generator extends testing_module_generator {

/**
* Create new quiz module instance.
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<testsuite name="core_phpunit">
<directory suffix="_test.php">lib/phpunit/tests</directory>
</testsuite>
<testsuite name="core_test">
<directory suffix="_test.php">lib/testing/tests</directory>
</testsuite>
<testsuite name="core_db">
<directory suffix="_test.php">lib/ddl/tests</directory>
<directory suffix="_test.php">lib/dml/tests</directory>
Expand Down

0 comments on commit 5c3c2c8

Please sign in to comment.