<exclude-pattern>*/profileinfo\.php</exclude-pattern>
<!-- Language converters use the pattern of 2 classes in one file -->
<exclude-pattern>*/languages/*\.php</exclude-pattern>
- <!-- We don't care that much about violations in tests -->
- <exclude-pattern>*/tests/*\.php</exclude-pattern>
+ <!-- Skip violations in some tests for now -->
+ <exclude-pattern>*/tests/parser/*\.php</exclude-pattern>
+ <exclude-pattern>*/tests/phan/*\.php</exclude-pattern>
+ <exclude-pattern>*/tests/phpunit/maintenance/*\.php</exclude-pattern>
+ <exclude-pattern>*/tests/phpunit/bootstrap\.php</exclude-pattern>
+ <exclude-pattern>*/tests/phpunit/phpunit\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Files.ClassMatchesFilename.WrongCase">
<!--
<exclude-pattern>*/maintenance/storage/checkStorage\.php</exclude-pattern>
<exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
<exclude-pattern>*/maintenance/storage/trackBlobs\.php</exclude-pattern>
- <!-- We don't care that much about violations in tests -->
- <exclude-pattern>*/tests/*\.php</exclude-pattern>
+ <!-- Skip violations in some tests for now -->
+ <exclude-pattern>*/tests/phpunit/includes/GlobalFunctions/*\.php</exclude-pattern>
+ <exclude-pattern>*/tests/phpunit/maintenance/*\.php</exclude-pattern>
</rule>
<rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
use Wikimedia\Rdbms\DatabaseSqlite;
use Wikimedia\Rdbms\ResultWrapper;
-class DatabaseSqliteMock extends DatabaseSqlite {
- public static function newInstance( array $p = [] ) {
- $p['dbFilePath'] = ':memory:';
- $p['schema'] = false;
-
- return Database::factory( 'SqliteMock', $p );
- }
-
- function query( $sql, $fname = '', $tempIgnore = false ) {
- return true;
- }
-
- /**
- * Override parent visibility to public
- */
- public function replaceVars( $s ) {
- return parent::replaceVars( $s );
- }
-}
-
/**
* @group sqlite
* @group Database
$this->assertTrue( $attributes[Database::ATTR_DB_LEVEL_LOCKING] );
}
}
+
+class DatabaseSqliteMock extends DatabaseSqlite {
+ public static function newInstance( array $p = [] ) {
+ $p['dbFilePath'] = ':memory:';
+ $p['schema'] = false;
+
+ return Database::factory( 'SqliteMock', $p );
+ }
+
+ function query( $sql, $fname = '', $tempIgnore = false ) {
+ return true;
+ }
+
+ /**
+ * Override parent visibility to public
+ */
+ public function replaceVars( $s ) {
+ return parent::replaceVars( $s );
+ }
+}
<?php
-class MockSearch extends SearchEngine {
- public static $id;
- public static $title;
- public static $text;
-
- public function __construct( $db ) {
- }
-
- public function update( $id, $title, $text ) {
- self::$id = $id;
- self::$title = $title;
- self::$text = $text;
- }
-}
-
/**
* @group Search
*/
);
}
}
+
+class MockSearch extends SearchEngine {
+ public static $id;
+ public static $title;
+ public static $text;
+
+ public function __construct( $db ) {
+ }
+
+ public function update( $id, $title, $text ) {
+ self::$id = $id;
+ self::$title = $title;
+ self::$text = $text;
+ }
+}
<?php
/**
- * A MemoizedCallable subclass that stores function return values
- * in an instance property rather than APC or APCu.
- */
-class ArrayBackedMemoizedCallable extends MemoizedCallable {
- private $cache = [];
-
- protected function fetchResult( $key, &$success ) {
- if ( array_key_exists( $key, $this->cache ) ) {
- $success = true;
- return $this->cache[$key];
- }
- $success = false;
- return false;
- }
-
- protected function storeResult( $key, $result ) {
- $this->cache[$key] = $result;
- }
-}
-
-/**
- * PHP Unit tests for MemoizedCallable class.
+ * PHPUnit tests for MemoizedCallable class.
* @covers MemoizedCallable
*/
class MemoizedCallableTest extends PHPUnit\Framework\TestCase {
$memoized = new MemoizedCallable( 14 );
}
}
+
+/**
+ * A MemoizedCallable subclass that stores function return values
+ * in an instance property rather than APC or APCu.
+ */
+class ArrayBackedMemoizedCallable extends MemoizedCallable {
+ private $cache = [];
+
+ protected function fetchResult( $key, &$success ) {
+ if ( array_key_exists( $key, $this->cache ) ) {
+ $success = true;
+ return $this->cache[$key];
+ }
+ $success = false;
+ return false;
+ }
+
+ protected function storeResult( $key, $result ) {
+ $this->cache[$key] = $result;
+ }
+}
<?php
-// We will use this class with getMockForAbstractClass to create a concrete mock class.
-// That call will die if the contructor is not public, unless we use disableOriginalConstructor(),
-// in which case we could not test the constructor.
-abstract class PoolCounterAbstractMock extends PoolCounter {
- public function __construct() {
- call_user_func_array( 'parent::__construct', func_get_args() );
- }
-}
-
/**
* @covers PoolCounter
*/
);
}
}
+
+// We will use this class with getMockForAbstractClass to create a concrete mock class.
+// That call will die if the contructor is not public, unless we use disableOriginalConstructor(),
+// in which case we could not test the constructor.
+abstract class PoolCounterAbstractMock extends PoolCounter {
+ public function __construct() {
+ call_user_func_array( 'parent::__construct', func_get_args() );
+ }
+}