resourceloader: Add missing (string) cast to ClientHtml tests
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 6 Apr 2019 23:02:28 +0000 (00:02 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sat, 6 Apr 2019 23:14:22 +0000 (00:14 +0100)
One of the assertions already did this, but the others not yet.

The reason we do this is because the return value is a WrappedString
object. The assertEquals() method is able to satisfy the expected
value because of loose comparison casting it to a string for the
case where it matches.

But, when it fails during development, PHPUnit was still printing
the object as "Actual" and the string as "Expected" which makes
it difficult to understand what's going on, and also no diff.

Change-Id: Ice9fe5061fb76867e9bee2f34c88d3ddac3144f9

tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php

index 825c9b9..9ab3a2d 100644 (file)
@@ -120,7 +120,7 @@ Deprecation message.' ]
                // phpcs:enable
                $expected = self::expandVariables( $expected );
 
-               $this->assertEquals( $expected, $client->getHeadHtml() );
+               $this->assertSame( $expected, (string)$client->getHeadHtml() );
        }
 
        /**
@@ -137,7 +137,7 @@ Deprecation message.' ]
                        . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts&amp;skin=fallback&amp;target=example"></script>';
                // phpcs:enable
 
-               $this->assertEquals( $expected, $client->getHeadHtml() );
+               $this->assertSame( $expected, (string)$client->getHeadHtml() );
        }
 
        /**
@@ -154,7 +154,7 @@ Deprecation message.' ]
                        . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts&amp;safemode=1&amp;skin=fallback"></script>';
                // phpcs:enable
 
-               $this->assertEquals( $expected, $client->getHeadHtml() );
+               $this->assertSame( $expected, (string)$client->getHeadHtml() );
        }
 
        /**
@@ -171,7 +171,7 @@ Deprecation message.' ]
                        . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts&amp;skin=fallback"></script>';
                // phpcs:enable
 
-               $this->assertEquals( $expected, $client->getHeadHtml() );
+               $this->assertSame( $expected, (string)$client->getHeadHtml() );
        }
 
        public function testGetBodyHtml() {
@@ -193,7 +193,7 @@ Deprecation message.' ]
                        . '});</script>';
                // phpcs:enable
 
-               $this->assertEquals( $expected, $client->getBodyHtml() );
+               $this->assertSame( $expected, (string)$client->getBodyHtml() );
        }
 
        public static function provideMakeLoad() {
@@ -339,7 +339,7 @@ Deprecation message.' ]
                $context->getResourceLoader()->register( self::makeSampleModules() );
                $actual = ResourceLoaderClientHtml::makeLoad( $context, $modules, $type, $extraQuery, false );
                $expected = self::expandVariables( $expected );
-               $this->assertEquals( $expected, (string)$actual );
+               $this->assertSame( $expected, (string)$actual );
        }
 
        public function testGetDocumentAttributes() {