Merge "rdbms: avoid LoadBalancer::getConnection waste when using $groups"
[lhc/web/wiklou.git] / tests / phpunit / includes / resourceloader / MessageBlobStoreTest.php
index e577643..e094d92 100644 (file)
@@ -25,7 +25,7 @@ class MessageBlobStoreTest extends PHPUnit\Framework\TestCase {
 
        public function testBlobCreation() {
                $module = $this->makeModule( [ 'mainpage' ] );
-               $rl = new ResourceLoader();
+               $rl = new EmptyResourceLoader();
                $rl->register( $module->getName(), $module );
 
                $blobStore = $this->makeBlobStore( null, $rl );
@@ -34,21 +34,32 @@ class MessageBlobStoreTest extends PHPUnit\Framework\TestCase {
                $this->assertEquals( '{"mainpage":"Main Page"}', $blob, 'Generated blob' );
        }
 
+       public function testBlobCreation_empty() {
+               $module = $this->makeModule( [] );
+               $rl = new EmptyResourceLoader();
+               $rl->register( $module->getName(), $module );
+
+               $blobStore = $this->makeBlobStore( null, $rl );
+               $blob = $blobStore->getBlob( $module, 'en' );
+
+               $this->assertEquals( '{}', $blob, 'Generated blob' );
+       }
+
        public function testBlobCreation_unknownMessage() {
-               $module = $this->makeModule( [ 'i-dont-exist' ] );
-               $rl = new ResourceLoader();
+               $module = $this->makeModule( [ 'i-dont-exist', 'mainpage', 'i-dont-exist2' ] );
+               $rl = new EmptyResourceLoader();
                $rl->register( $module->getName(), $module );
                $blobStore = $this->makeBlobStore( null, $rl );
 
-               // Generating a blob should succeed without errors,
-               // even if a message is unknown.
+               // Generating a blob should continue without errors,
+               // with keys of unknown messages excluded from the blob.
                $blob = $blobStore->getBlob( $module, 'en' );
-               $this->assertEquals( '{"i-dont-exist":"\u29fci-dont-exist\u29fd"}', $blob, 'Generated blob' );
+               $this->assertEquals( '{"mainpage":"Main Page"}', $blob, 'Generated blob' );
        }
 
        public function testMessageCachingAndPurging() {
                $module = $this->makeModule( [ 'example' ] );
-               $rl = new ResourceLoader();
+               $rl = new EmptyResourceLoader();
                $rl->register( $module->getName(), $module );
                $blobStore = $this->makeBlobStore( [ 'fetchMessage' ], $rl );
 
@@ -93,7 +104,7 @@ class MessageBlobStoreTest extends PHPUnit\Framework\TestCase {
 
        public function testPurgeEverything() {
                $module = $this->makeModule( [ 'example' ] );
-               $rl = new ResourceLoader();
+               $rl = new EmptyResourceLoader();
                $rl->register( $module->getName(), $module );
                $blobStore = $this->makeBlobStore( [ 'fetchMessage' ], $rl );
                // Advance this new WANObjectCache instance to a normal state.
@@ -127,7 +138,7 @@ class MessageBlobStoreTest extends PHPUnit\Framework\TestCase {
        public function testValidateAgainstModuleRegistry() {
                // Arrange version 1 of a module
                $module = $this->makeModule( [ 'foo' ] );
-               $rl = new ResourceLoader();
+               $rl = new EmptyResourceLoader();
                $rl->register( $module->getName(), $module );
                $blobStore = $this->makeBlobStore( [ 'fetchMessage' ], $rl );
                $blobStore->expects( $this->once() )
@@ -146,7 +157,7 @@ class MessageBlobStoreTest extends PHPUnit\Framework\TestCase {
                // must always match the set of message keys required by the module.
                // We do not receive purges for this because no messages were changed.
                $module = $this->makeModule( [ 'foo', 'bar' ] );
-               $rl = new ResourceLoader();
+               $rl = new EmptyResourceLoader();
                $rl->register( $module->getName(), $module );
                $blobStore = $this->makeBlobStore( [ 'fetchMessage' ], $rl );
                $blobStore->expects( $this->exactly( 2 ) )