mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-50926 phpunit: Upgrade to phpunit 4.x
This commit is contained in:
parent
f5d23fc162
commit
b80b35d0fc
9 changed files with 734 additions and 105 deletions
75
lib/phpunit/classes/base_testcase.php
Normal file
75
lib/phpunit/classes/base_testcase.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Base test case class.
|
||||
*
|
||||
* @package core
|
||||
* @category test
|
||||
* @author Tony Levi <tony.levi@blackboard.com>
|
||||
* @copyright 2015 Blackboard (http://www.blackboard.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Base class for PHPUnit test cases customised for Moodle
|
||||
*
|
||||
* It is intended for functionality common to both basic and advanced_testcase.
|
||||
*
|
||||
* @package core
|
||||
* @category test
|
||||
* @author Tony Levi <tony.levi@blackboard.com>
|
||||
* @copyright 2015 Blackboard (http://www.blackboard.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class base_testcase extends PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* Note: we are overriding this method to remove the deprecated error
|
||||
* @see https://tracker.moodle.org/browse/MDL-47129
|
||||
*
|
||||
* @param array $matcher
|
||||
* @param string $actual
|
||||
* @param string $message
|
||||
* @param boolean $ishtml
|
||||
*
|
||||
* @deprecated 3.0
|
||||
*/
|
||||
public static function assertTag($matcher, $actual, $message = '', $ishtml = true) {
|
||||
$dom = PHPUnit_Util_XML::load($actual, $ishtml);
|
||||
$tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $ishtml);
|
||||
$matched = count($tags) > 0 && $tags[0] instanceof DOMNode;
|
||||
self::assertTrue($matched, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: we are overriding this method to remove the deprecated error
|
||||
* @see https://tracker.moodle.org/browse/MDL-47129
|
||||
*
|
||||
* @param array $matcher
|
||||
* @param string $actual
|
||||
* @param string $message
|
||||
* @param boolean $ishtml
|
||||
*
|
||||
* @deprecated 3.0
|
||||
*/
|
||||
public static function assertNotTag($matcher, $actual, $message = '', $ishtml = true) {
|
||||
$dom = PHPUnit_Util_XML::load($actual, $ishtml);
|
||||
$tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $ishtml);
|
||||
$matched = count($tags) > 0 && $tags[0] instanceof DOMNode;
|
||||
self::assertFalse($matched, $message);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@
|
|||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class basic_testcase extends PHPUnit_Framework_TestCase {
|
||||
abstract class basic_testcase extends \base_testcase {
|
||||
|
||||
/**
|
||||
* Constructs a test case with the given name.
|
||||
|
|
|
@ -45,7 +45,7 @@ class Hint_ResultPrinter extends PHPUnit_TextUI_ResultPrinter {
|
|||
}
|
||||
}
|
||||
// Fallback if something goes wrong.
|
||||
parent::__construct(null, false, false, false);
|
||||
parent::__construct(null, false, self::COLOR_DEFAULT, false);
|
||||
}
|
||||
|
||||
protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) {
|
||||
|
@ -135,7 +135,7 @@ class Hacky_TextUI_Command_reader extends PHPUnit_TextUI_Command {
|
|||
$verbose = isset($config['verbose']) ? $config['verbose'] : false;
|
||||
$verbose = isset($arguments['verbose']) ? $arguments['verbose'] : $verbose;
|
||||
|
||||
$colors = isset($config['colors']) ? $config['colors'] : false;
|
||||
$colors = isset($config['colors']) ? $config['colors'] : Hint_ResultPrinter::COLOR_DEFAULT;
|
||||
$colors = isset($arguments['colors']) ? $arguments['colors'] : $colors;
|
||||
|
||||
$debug = isset($config['debug']) ? $config['debug'] : false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue