] );
}
+ /**
+ * @dataProvider providesReferencedFiles
+ * @covers CSSMin::getLocalFileReferences
+ */
+ public function testGetLocalFileReferences( $input, $expected ) {
+ $output = CSSMin::getLocalFileReferences( $input, '/' );
+ $this->assertEquals(
+ $expected,
+ $output,
+ 'getLocalFileReferences() must find the local file properly'
+ );
+ }
+
+ public static function providesReferencedFiles() {
+ // input, array of expected local file names
+ return [
+ [ 'url("//example.org")', [] ],
+ [ 'url("https://example.org")', [] ],
+ [ 'url("#default#")', [] ],
+ [ 'url("WikiFont-Glyphs.svg#wikiglyph")', [ '/WikiFont-Glyphs.svg' ] ],
+ [ 'url("#some-anchor")', [] ],
+ ];
+ }
+
/**
* @dataProvider provideSerializeStringValue
* @covers CSSMin::serializeStringValue
* @covers CSSMin::getMimeType
*/
public function testGetMimeType( $fileContents, $fileExtension, $expected ) {
- $fileName = wfTempDir() . DIRECTORY_SEPARATOR . uniqid( 'MW_PHPUnit_CSSMinTest_' ) . '.'
- . $fileExtension;
- $this->addTmpFiles( $fileName );
+ // Automatically removed when it falls out of scope (including if the test fails)
+ $file = TempFSFile::factory( 'PHPUnit_CSSMinTest_', $fileExtension, wfTempDir() );
+ $fileName = $file->getPath();
file_put_contents( $fileName, $fileContents );
$this->assertSame( $expected, CSSMin::getMimeType( $fileName ) );
}
[ 'foo { behavior: url(#default#bar); }', false, '/w/', false ],
'foo { behavior: url("#default#bar"); }',
],
+ [
+ 'Keeps anchors',
+ [ 'url(#other)', false, '/', false ],
+ 'url("#other")'
+ ],
+ [
+ 'Keeps anchors after a path',
+ [ 'url(images/file.svg#id)', false, '/', false ],
+ 'url("/images/file.svg#id")'
+ ],
];
}
}
/**
- * Seperated because they are currently broken (T37492)
+ * Separated because they are currently broken (T37492)
*
* @group Broken
* @dataProvider provideStringCases