Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/94588
Change subject: More tests for CSSMin::remap
......................................................................
More tests for CSSMin::remap
Also added commented-out tests which should work, but don't.
Making them work in subsequent patch If9082f55.
Change-Id: I65f62493e6d10e7e90af8844f8a26e3982d75f51
---
A tests/phpunit/data/media/green.gif
A tests/phpunit/data/media/mediawiki.png
A tests/phpunit/data/media/red.gif
M tests/phpunit/includes/libs/CSSMinTest.php
4 files changed, 100 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/88/94588/1
diff --git a/tests/phpunit/data/media/green.gif
b/tests/phpunit/data/media/green.gif
new file mode 100644
index 0000000..f9e7531
--- /dev/null
+++ b/tests/phpunit/data/media/green.gif
Binary files differ
diff --git a/tests/phpunit/data/media/mediawiki.png
b/tests/phpunit/data/media/mediawiki.png
new file mode 100644
index 0000000..a398c4e
--- /dev/null
+++ b/tests/phpunit/data/media/mediawiki.png
Binary files differ
diff --git a/tests/phpunit/data/media/red.gif b/tests/phpunit/data/media/red.gif
new file mode 100644
index 0000000..13c43e9
--- /dev/null
+++ b/tests/phpunit/data/media/red.gif
Binary files differ
diff --git a/tests/phpunit/includes/libs/CSSMinTest.php
b/tests/phpunit/includes/libs/CSSMinTest.php
index 43df5eb..356a7fc 100644
--- a/tests/phpunit/includes/libs/CSSMinTest.php
+++ b/tests/phpunit/includes/libs/CSSMinTest.php
@@ -69,6 +69,8 @@
}
/**
+ * This tests funky parameters to CSSMin::remap. testRemapRemapping
tests the basic functionality.
+ *
* @dataProvider provideRemapCases
* @covers CSSMin::remap
*/
@@ -112,6 +114,104 @@
}
/**
+ * This tests basic functionality of CSSMin::remap. testRemapRemapping
tests funky parameters.
+ *
+ * @dataProvider provideRemapRemappingCases
+ * @covers CSSMin::remap
+ */
+ public function testRemapRemapping( $message, $input, $expectedOutput )
{
+ $localPath = __DIR__ . '/../../data/media/';
+ $remotePath = 'http://localhost/w/';
+
+ $realOutput = CSSMin::remap( $input, $localPath, $remotePath );
+
+ $this->assertEquals(
+ $expectedOutput,
+ preg_replace( '/\d+-\d+-\d+T\d+:\d+:\d+Z/',
'timestamp', $realOutput ),
+ "CSSMin::remap: $message"
+ );
+ }
+
+ public static function provideRemapRemappingCases() {
+ // red.gif and green.gif are one-pixel 35-byte GIFs.
+ // mediawiki.png is a 30K PNG that should be non-embeddable.
+ // Full paths start with http://localhost/w/.
+ // Timestamps in output are replaced with 'timestamp'.
+
+ // data: URIs for red.gif and green.gif
+ $red =
'data:image/gif;base64,R0lGODlhAQABAIAAAP8AADAAACwAAAAAAQABAAACAkQBADs=';
+ $green =
'data:image/gif;base64,R0lGODlhAQABAIAAAACAADAAACwAAAAAAQABAAACAkQBADs=';
+
+ return array(
+ array(
+ 'Regular file',
+ 'foo { background: url(red.gif); }',
+ 'foo { background:
url(http://localhost/w/red.gif?timestamp); }',
+ ),
+ array(
+ 'Remote URL',
+ 'foo { background:
url(http://example.org/w/foo.png); }',
+ 'foo { background:
url(http://example.org/w/foo.png); }',
+ ),
+ array(
+ 'Embedded file',
+ 'foo { /* @embed */ background: url(red.gif);
}',
+ "foo { background: url($red);background:
url(http://localhost/w/red.gif?timestamp)!ie; }",
+ ),
+ array(
+ 'Can not embed remote URLs',
+ 'foo { /* @embed */ background:
url(http://example.org/w/foo.png); }',
+ 'foo { background:
url(http://example.org/w/foo.png); }',
+ ),
+ // array( // Not supported :(
+ // 'Embedded file (inline @embed)',
+ // 'foo { background: /* @embed */ url(red.gif);
}',
+ // "foo { background: url($red);background:
url(http://localhost/w/red.gif?timestamp)!ie; }",
+ // ),
+ array(
+ 'Can not embed large files',
+ 'foo { /* @embed */ background:
url(mediawiki.png); }',
+ "foo { background:
url(http://localhost/w/mediawiki.png?timestamp); }",
+ ),
+ // array( // Not supported :(
+ // 'Two regular files in one rule',
+ // 'foo { background: url(red.gif),
url(green.gif); }',
+ // 'foo { background:
url(http://localhost/w/red.gif?timestamp),
url(http://localhost/w/green.gif?timestamp); }',
+ // ),
+ // array( // Not supported :(
+ // 'Two embedded files in one rule',
+ // 'foo { /* @embed */ background: url(red.gif),
url(green.gif); }',
+ // "foo { background: url($red),
url($green);background: url(http://localhost/w/red.gif?timestamp),
url(http://localhost/w/green.gif?timestamp)!ie; }",
+ // ),
+ // array( // Not supported :(
+ // 'Two embedded files in one rule (inline
@embed)',
+ // 'foo { background: /* @embed */ url(red.gif),
/* @embed */ url(green.gif); }',
+ // "foo { background: url($red),
url($green);background: url(http://localhost/w/red.gif?timestamp),
url(http://localhost/w/green.gif?timestamp)!ie; }",
+ // ),
+ // array( // Not supported :(
+ // 'Two embedded files in one rule (inline
@embed), one too large',
+ // 'foo { background: /* @embed */ url(red.gif),
/* @embed */ url(mediawiki.png); }',
+ // "foo { background: url($red),
url(http://localhost/w/mediawiki.png?timestamp);background:
url(http://localhost/w/red.gif?timestamp),
url(http://localhost/w/mediawiki.png?timestamp)!ie; }",
+ // ),
+ array(
+ 'Practical example with some noise',
+ 'foo { /* @embed */ background: #f9f9f9
url(red.gif) 0 0 no-repeat; }',
+ 'foo { background: #f9f9f9 url($red) 0 0
no-repeat;background: #f9f9f9 url(http://localhost/w/red.gif?timestamp) 0 0
no-repeat!ie; }',
+ ),
+ array(
+ 'Does not mess with other properties',
+ 'foo { color: red; background: url(red.gif);
font-size: small; }',
+ 'foo { color: red; background:
url(http://localhost/w/red.gif?timestamp); font-size: small; }',
+ ),
+ array(
+ 'Spacing and miscellanea not changed',
+ 'foo { background: url( red.gif ) }',
+ 'foo { background:
url(http://localhost/w/red.gif?timestamp) }',
+ ),
+ );
+ }
+
+ /**
* Seperated because they are currently broken (bug 35492)
*
* @group Broken
--
To view, visit https://gerrit.wikimedia.org/r/94588
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I65f62493e6d10e7e90af8844f8a26e3982d75f51
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits