$this->backupStaticAttributes = false;
}
+ public function __destruct() {
+ // Complain if self::setUp() was called, but not self::tearDown()
+ // $this->called['setUp'] will be checked by self::testMediaWikiTestCaseParentSetupCalled()
+ if ( isset( $this->called['setUp'] ) && !isset( $this->called['tearDown'] ) ) {
+ throw new MWException( get_called_class() . "::tearDown() must call parent::tearDown()" );
+ }
+ }
+
public function run( PHPUnit_Framework_TestResult $result = null ) {
/* Some functions require some kind of caching, and will end up using the db,
* which we can't allow, as that would open a new connection for mysql.
protected function setUp() {
wfProfileIn( __METHOD__ );
parent::setUp();
- $this->called['setUp'] = 1;
+ $this->called['setUp'] = true;
$this->phpErrorLevel = intval( ini_get( 'error_reporting' ) );
protected function tearDown() {
wfProfileIn( __METHOD__ );
+ $this->called['tearDown'] = true;
// Cleaning up temporary files
foreach ( $this->tmpFiles as $fileName ) {
if ( is_file( $fileName ) || ( is_link( $fileName ) ) ) {
$this->assertEmpty( $errors, implode( "\n", $errors ) );
}
+
+ /**
+ * Note: we are overriding this method to remove the deprecated error
+ * @see https://bugzilla.wikimedia.org/show_bug.cgi?id=69505
+ * @see https://github.com/sebastianbergmann/phpunit/issues/1292
+ *
+ * @param array $matcher
+ * @param string $actual
+ * @param string $message
+ * @param bool $isHtml
+ */
+ public static function assertTag( $matcher, $actual, $message = '', $isHtml = true ) {
+ //trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED);
+
+ $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 );
+ }
}