summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/logging/UploadLogFormatterTest.php
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:32:59 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:32:59 -0400
commit6dc1997577fab2c366781fd7048144935afa0012 (patch)
tree8918d28c7ab4342f0738985e37af1dfc42d0e93a /tests/phpunit/includes/logging/UploadLogFormatterTest.php
parent150f94f051128f367bc89f6b7e5f57eb2a69fc62 (diff)
parentfa89acd685cb09cdbe1c64cbb721ec64975bbbc1 (diff)
Merge commit 'fa89acd'
# Conflicts: # .gitignore # extensions/ArchInterWiki.sql
Diffstat (limited to 'tests/phpunit/includes/logging/UploadLogFormatterTest.php')
-rw-r--r--tests/phpunit/includes/logging/UploadLogFormatterTest.php166
1 files changed, 166 insertions, 0 deletions
diff --git a/tests/phpunit/includes/logging/UploadLogFormatterTest.php b/tests/phpunit/includes/logging/UploadLogFormatterTest.php
new file mode 100644
index 00000000..12f51613
--- /dev/null
+++ b/tests/phpunit/includes/logging/UploadLogFormatterTest.php
@@ -0,0 +1,166 @@
+<?php
+
+class UploadLogFormatterTest extends LogFormatterTestCase {
+
+ /**
+ * Provide different rows from the logging table to test
+ * for backward compatibility.
+ * Do not change the existing data, just add a new database row
+ */
+ public static function provideUploadLogDatabaseRows() {
+ return array(
+ // Current format
+ array(
+ array(
+ 'type' => 'upload',
+ 'action' => 'upload',
+ 'comment' => 'upload comment',
+ 'namespace' => NS_FILE,
+ 'title' => 'File.png',
+ 'params' => array(
+ 'img_sha1' => 'hash',
+ 'img_timestamp' => '20150101000000',
+ ),
+ ),
+ array(
+ 'text' => 'User uploaded File:File.png',
+ 'api' => array(
+ 'img_sha1' => 'hash',
+ 'img_timestamp' => '2015-01-01T00:00:00Z',
+ ),
+ ),
+ ),
+
+ // Old format without params
+ array(
+ array(
+ 'type' => 'upload',
+ 'action' => 'upload',
+ 'comment' => 'upload comment',
+ 'namespace' => NS_FILE,
+ 'title' => 'File.png',
+ 'params' => array(),
+ ),
+ array(
+ 'text' => 'User uploaded File:File.png',
+ 'api' => array(),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider provideUploadLogDatabaseRows
+ */
+ public function testUploadLogDatabaseRows( $row, $extra ) {
+ $this->doTestLogFormatter( $row, $extra );
+ }
+
+ /**
+ * Provide different rows from the logging table to test
+ * for backward compatibility.
+ * Do not change the existing data, just add a new database row
+ */
+ public static function provideOverwriteLogDatabaseRows() {
+ return array(
+ // Current format
+ array(
+ array(
+ 'type' => 'upload',
+ 'action' => 'overwrite',
+ 'comment' => 'upload comment',
+ 'namespace' => NS_FILE,
+ 'title' => 'File.png',
+ 'params' => array(
+ 'img_sha1' => 'hash',
+ 'img_timestamp' => '20150101000000',
+ ),
+ ),
+ array(
+ 'text' => 'User uploaded a new version of File:File.png',
+ 'api' => array(
+ 'img_sha1' => 'hash',
+ 'img_timestamp' => '2015-01-01T00:00:00Z',
+ ),
+ ),
+ ),
+
+ // Old format without params
+ array(
+ array(
+ 'type' => 'upload',
+ 'action' => 'overwrite',
+ 'comment' => 'upload comment',
+ 'namespace' => NS_FILE,
+ 'title' => 'File.png',
+ 'params' => array(),
+ ),
+ array(
+ 'text' => 'User uploaded a new version of File:File.png',
+ 'api' => array(),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider provideOverwriteLogDatabaseRows
+ */
+ public function testOverwriteLogDatabaseRows( $row, $extra ) {
+ $this->doTestLogFormatter( $row, $extra );
+ }
+
+ /**
+ * Provide different rows from the logging table to test
+ * for backward compatibility.
+ * Do not change the existing data, just add a new database row
+ */
+ public static function provideRevertLogDatabaseRows() {
+ return array(
+ // Current format
+ array(
+ array(
+ 'type' => 'upload',
+ 'action' => 'revert',
+ 'comment' => 'upload comment',
+ 'namespace' => NS_FILE,
+ 'title' => 'File.png',
+ 'params' => array(
+ 'img_sha1' => 'hash',
+ 'img_timestamp' => '20150101000000',
+ ),
+ ),
+ array(
+ 'text' => 'User uploaded File:File.png',
+ 'api' => array(
+ 'img_sha1' => 'hash',
+ 'img_timestamp' => '2015-01-01T00:00:00Z',
+ ),
+ ),
+ ),
+
+ // Old format without params
+ array(
+ array(
+ 'type' => 'upload',
+ 'action' => 'revert',
+ 'comment' => 'upload comment',
+ 'namespace' => NS_FILE,
+ 'title' => 'File.png',
+ 'params' => array(),
+ ),
+ array(
+ 'text' => 'User uploaded File:File.png',
+ 'api' => array(),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider provideRevertLogDatabaseRows
+ */
+ public function testRevertLogDatabaseRows( $row, $extra ) {
+ $this->doTestLogFormatter( $row, $extra );
+ }
+}