X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiComparePagesTest.php;h=04283357c68e9e16a98336040605fbfc81f7cc12;hb=a93cf8f4eee40a448bcd99b8fe1c32dc80775b6b;hp=9399ef8ea8519faa4fa025f3bb5bb68b3567cd14;hpb=e863401c716bdd574d307357576e8b77707b7c9d;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/api/ApiComparePagesTest.php b/tests/phpunit/includes/api/ApiComparePagesTest.php index 9399ef8ea8..04283357c6 100644 --- a/tests/phpunit/includes/api/ApiComparePagesTest.php +++ b/tests/phpunit/includes/api/ApiComparePagesTest.php @@ -70,6 +70,9 @@ class ApiComparePagesTest extends ApiTestCase { 'page', [ 'page_latest' => 0 ], [ 'page_id' => self::$repl['pageE'] ] ); + self::$repl['revF1'] = $this->addPage( 'F', "== Section 1 ==\nF 1.1\n\n== Section 2 ==\nF 1.2" ); + self::$repl['pageF'] = Title::newFromText( 'ApiComparePagesTest F' )->getArticleId(); + WikiPage::factory( Title::newFromText( 'ApiComparePagesTest C' ) ) ->doDeleteArticleReal( 'Test for ApiComparePagesTest' ); @@ -110,7 +113,7 @@ class ApiComparePagesTest extends ApiTestCase { $value = self::$repl[$m[1]]; } else { $value = preg_replace_callback( '/{{REPL:(.+?)}}/', function ( $m ) { - return isset( self::$repl[$m[1]] ) ? self::$repl[$m[1]] : $m[0]; + return self::$repl[$m[1]] ?? $m[0]; }, $value ); } } elseif ( is_array( $value ) || is_object( $value ) ) { @@ -151,8 +154,8 @@ class ApiComparePagesTest extends ApiTestCase { } public static function provideDiff() { + // phpcs:disable Generic.Files.LineLength.TooLong return [ - // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong 'Basic diff, titles' => [ [ 'fromtitle' => 'ApiComparePagesTest A', @@ -372,6 +375,26 @@ class ApiComparePagesTest extends ApiTestCase { ], false, true ], + 'Basic diff, test with sections' => [ + [ + 'fromtitle' => 'ApiComparePagesTest F', + 'fromsection' => 1, + 'totext' => "== Section 1 ==\nTo text\n\n== Section 2 ==\nTo text?", + 'tosection' => 2, + ], + [ + 'compare' => [ + 'body' => '