Merge "Fix more UnitTests for databases that do not use integer timestamps"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 8 Mar 2013 22:54:28 +0000 (22:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 8 Mar 2013 22:54:28 +0000 (22:54 +0000)
1  2 
tests/phpunit/includes/EditPageTest.php
tests/phpunit/includes/api/ApiEditPageTest.php

@@@ -48,7 -48,7 +48,7 @@@ class EditPageTest extends MediaWikiTes
                $dbw = wfGetDB( DB_MASTER );
  
                $dbw->update( 'revision',
-                       array( 'rev_timestamp' => $timestamp ),
+                       array( 'rev_timestamp' => $dbw->timestamp( $timestamp ) ),
                        array( 'rev_id' => $page->getLatest() ) );
  
                $page->clear();
@@@ -59,8 -59,8 +59,8 @@@
         * wrapper around assertEquals() which calls rrtrim() to normalize the
         * expected and actual texts.
         */
 -      function assertEditedTextEquals( $expected, $actual, $msg='' ) {
 -              return $this->assertEquals( rtrim($expected), rtrim($actual), $msg );
 +      function assertEditedTextEquals( $expected, $actual, $msg = '' ) {
 +              return $this->assertEquals( rtrim( $expected ), rtrim( $actual ), $msg );
        }
  
        /**
        }
  
        public static function provideSectionEdit() {
 -              $text =
 -'Intro
 +              $text = 'Intro
  
  == one ==
  first section.
  second section.
  ';
  
 -              $sectionOne =
 -'== one ==
 +              $sectionOne = '== one ==
  hello
  ';
  
 -              $newSection =
 -'== new section ==
 +              $newSection = '== new section ==
  
  hello
  ';
  
 -              $textWithNewSectionOne = preg_replace( '/== one ==.*== two ==/ms',
 -                                                                              "$sectionOne\n== two ==", $text );
 +              $textWithNewSectionOne = preg_replace(
 +                      '/== one ==.*== two ==/ms',
 +                      "$sectionOne\n== two ==", $text
 +              );
  
                $textWithNewSectionAdded = "$text\n$newSection";
  
                );
  
                // see whether it makes a difference who did the base edit
 -              $testsWithAdam = array_map( function( $test ) {
 +              $testsWithAdam = array_map( function ( $test ) {
                        $test[0] = 'Adam'; // change base edit user
                        return $test;
                }, $tests );
  
 -              $testsWithBerta = array_map( function( $test ) {
 +              $testsWithBerta = array_map( function ( $test ) {
                        $test[0] = 'Berta'; // change base edit user
                        return $test;
                }, $tests );
         * @dataProvider provideAutoMerge
         */
        public function testAutoMerge( $baseUser, $text, $adamsEdit, $bertasEdit,
 -                              $expectedCode, $expectedText, $message = null
 +              $expectedCode, $expectedText, $message = null
        ) {
                $this->checkHasDiff3();
  
                );
  
                $page = $this->assertEdit( 'EditPageTest_testAutoMerge', null,
 -                                      $baseUser, $baseEdit, null, null, __METHOD__ );
 +                      $baseUser, $baseEdit, null, null, __METHOD__ );
  
                $this->forceRevisionDate( $page, '20120101000000' );
  
@@@ -43,15 -43,14 +43,15 @@@ class ApiEditPageTest extends ApiTestCa
                parent::teardown();
        }
  
 -      function testEdit( ) {
 +      function testEdit() {
                $name = 'Help:ApiEditPageTest_testEdit'; // assume Help namespace to default to wikitext
  
                // -- test new page --------------------------------------------
                $apiResult = $this->doApiRequestWithToken( array(
 -                              'action' => 'edit',
 -                              'title' => $name,
 -                              'text' => 'some text', ) );
 +                      'action' => 'edit',
 +                      'title' => $name,
 +                      'text' => 'some text',
 +              ) );
                $apiResult = $apiResult[0];
  
                // Validate API result data
  
                // -- test existing page, no change ----------------------------
                $data = $this->doApiRequestWithToken( array(
 -                              'action' => 'edit',
 -                              'title' => $name,
 -                              'text' => 'some text', ) );
 +                      'action' => 'edit',
 +                      'title' => $name,
 +                      'text' => 'some text',
 +              ) );
  
                $this->assertEquals( 'Success', $data[0]['edit']['result'] );
  
  
                // -- test existing page, with change --------------------------
                $data = $this->doApiRequestWithToken( array(
 -                              'action' => 'edit',
 -                              'title' => $name,
 -                              'text' => 'different text' ) );
 +                      'action' => 'edit',
 +                      'title' => $name,
 +                      'text' => 'different text'
 +              ) );
  
                $this->assertEquals( 'Success', $data[0]['edit']['result'] );
  
@@@ -97,7 -94,7 +97,7 @@@
                );
        }
  
 -      function testNonTextEdit( ) {
 +      function testNonTextEdit() {
                $name = 'Dummy:ApiEditPageTest_testNonTextEdit';
                $data = serialize( 'some bla bla text' );
  
                if ( $text !== null ) {
                        if ( $text === '' ) {
                                // can't create an empty page, so create it with some content
 -                              list( $re,, ) = $this->doApiRequestWithToken( array(
 +                              list( $re, , ) = $this->doApiRequestWithToken( array(
                                        'action' => 'edit',
                                        'title' => $name,
                                        'text' => '(dummy)', ) );
                        }
  
 -                      list( $re,, ) = $this->doApiRequestWithToken( array(
 +                      list( $re, , ) = $this->doApiRequestWithToken( array(
                                'action' => 'edit',
                                'title' => $name,
                                'text' => $text, ) );
                }
  
                // -- try append/prepend --------------------------------------------
 -              list( $re,, ) = $this->doApiRequestWithToken( array(
 +              list( $re, , ) = $this->doApiRequestWithToken( array(
                        'action' => 'edit',
                        'title' => $name,
                        $op . 'text' => $append, ) );
  
                // try to save edit, expect conflict
                try {
 -                      list( $re,, ) = $this->doApiRequestWithToken( array(
 +                      list( $re, , ) = $this->doApiRequestWithToken( array(
                                'action' => 'edit',
                                'title' => $name,
                                'text' => 'nix bar!',
                                'basetimestamp' => $baseTime,
 -                              ), null, self::$users['sysop']->user );
 +                      ), null, self::$users['sysop']->user );
  
                        $this->fail( 'edit conflict expected' );
                } catch ( UsageException $ex ) {
                $this->forceRevisionDate( $rpage, '20120101020202' );
  
                // try to save edit; should work, because we follow the redirect
 -              list( $re,, ) = $this->doApiRequestWithToken( array(
 +              list( $re, , ) = $this->doApiRequestWithToken( array(
                        'action' => 'edit',
                        'title' => $rname,
                        'text' => 'nix bar!',
  
                // try again, without following the redirect. Should fail.
                try {
 -                      list( $re,, ) = $this->doApiRequestWithToken( array(
 +                      list( $re, , ) = $this->doApiRequestWithToken( array(
                                'action' => 'edit',
                                'title' => $rname,
                                'text' => 'nix bar!',
                $this->forceRevisionDate( $rpage, '20120101020202' );
  
                // try to save edit; should work, following the redirect.
 -              list( $re,, ) = $this->doApiRequestWithToken( array(
 +              list( $re, , ) = $this->doApiRequestWithToken( array(
                        'action' => 'edit',
                        'title' => $rname,
                        'text' => 'nix bar!',
                $dbw = wfGetDB( DB_MASTER );
  
                $dbw->update( 'revision',
-                       array( 'rev_timestamp' => $timestamp ),
+                       array( 'rev_timestamp' => $dbw->timestamp( $timestamp ) ),
                        array( 'rev_id' => $page->getLatest() ) );
  
                $page->clear();