Merge "objectcache: add "staleTTL" option to WANObjectCache::set()"
[lhc/web/wiklou.git] / tests / phpunit / ResourceLoaderTestCase.php
index 85bf954..18a49f6 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+use Psr\Log\LoggerInterface;
+use Psr\Log\NullLogger;
+
 abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
        /**
         * @param string $lang
@@ -64,10 +67,13 @@ class ResourceLoaderTestModule extends ResourceLoaderModule {
        protected $dependencies = [];
        protected $group = null;
        protected $source = 'local';
+       protected $position = 'bottom';
        protected $script = '';
        protected $styles = '';
        protected $skipFunction = null;
        protected $isRaw = false;
+       protected $isKnownEmpty = false;
+       protected $type = ResourceLoaderModule::LOAD_GENERAL;
        protected $targets = [ 'phpunit' ];
 
        public function __construct( $options = [] ) {
@@ -99,6 +105,13 @@ class ResourceLoaderTestModule extends ResourceLoaderModule {
        public function getSource() {
                return $this->source;
        }
+       public function getPosition() {
+               return $this->position;
+       }
+
+       public function getType() {
+               return $this->type;
+       }
 
        public function getSkipFunction() {
                return $this->skipFunction;
@@ -107,6 +120,9 @@ class ResourceLoaderTestModule extends ResourceLoaderModule {
        public function isRaw() {
                return $this->isRaw;
        }
+       public function isKnownEmpty( ResourceLoaderContext $context ) {
+               return $this->isKnownEmpty;
+       }
 
        public function enableModuleContentVersion() {
                return true;
@@ -115,3 +131,13 @@ class ResourceLoaderTestModule extends ResourceLoaderModule {
 
 class ResourceLoaderFileModuleTestModule extends ResourceLoaderFileModule {
 }
+
+class EmptyResourceLoader extends ResourceLoader {
+       // TODO: This won't be needed once ResourceLoader is empty by default
+       // and default registrations are done from ServiceWiring instead.
+       public function __construct( Config $config = null, LoggerInterface $logger = null ) {
+               $this->setLogger( $logger ?: new NullLogger() );
+               $this->config = $config ?: ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+               $this->setMessageBlobStore( new MessageBlobStore( $this, $this->getLogger() ) );
+       }
+}