resourceloader: Complete test coverage for FileModule::getTemplates()
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 27 Jun 2017 04:21:36 +0000 (21:21 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 27 Jun 2017 04:22:48 +0000 (21:22 -0700)
* Add coverage for the 'else' branch for file not existing and
  an exception being thrown.

Change-Id: Ia7d608f1ed72f07f46b969046d9c9910fbfd738d

tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php

index 7d12e59..9a03d3c 100644 (file)
@@ -41,6 +41,12 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
                                ]
                        ],
 
+                       'htmlTemplateUnknown' => $base + [
+                               'templates' => [
+                                       'templates/notfound.html',
+                               ]
+                       ],
+
                        'aliasedHtmlTemplateModule' => $base + [
                                'templates' => [
                                        'foo.html' => 'templates/template.html',
@@ -259,6 +265,10 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
                                        'bar.html' => "<div>goodbye</div>\n",
                                ],
                        ],
+                       [
+                               $modules['htmlTemplateUnknown'],
+                               false,
+                       ],
                ];
        }
 
@@ -270,7 +280,12 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
                $rl = new ResourceLoaderFileModule( $module );
                $rl->setName( 'testing' );
 
-               $this->assertEquals( $rl->getTemplates(), $expected );
+               if ( $expected === false ) {
+                       $this->setExpectedException( MWException::class );
+                       $rl->getTemplates();
+               } else {
+                       $this->assertEquals( $rl->getTemplates(), $expected );
+               }
        }
 
        public function testBomConcatenation() {