ItSpiderman has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371001 )

Change subject: VisualEditor: API unittest and fix for deprecated function
......................................................................

VisualEditor: API unittest and fix for deprecated function

Change-Id: I547af55ccfad8a6e01fa596cbfdd34f703eed784
ERM: #6639
---
M VisualEditor/includes/api/BSApiVisualEditorTasks.php
A VisualEditor/tests/phpunit/BSApiVisualEditorTasksTest.php
2 files changed, 61 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/01/371001/1

diff --git a/VisualEditor/includes/api/BSApiVisualEditorTasks.php 
b/VisualEditor/includes/api/BSApiVisualEditorTasks.php
index 7c1052a..150e0c6 100644
--- a/VisualEditor/includes/api/BSApiVisualEditorTasks.php
+++ b/VisualEditor/includes/api/BSApiVisualEditorTasks.php
@@ -165,7 +165,8 @@
                }
 
                if ( $iSection ) {
-                       $sText = $oArticle->replaceSection( $iSection, $sText );
+                       $oSectionContent = ContentHandler::makeContent( $sText, 
$oArticle->getTitle() );
+                       $sText = $oArticle->replaceSectionAtRev( $iSection, 
$oSectionContent )->getNativeData();
                }
 
                $oSaveResult = $oArticle->doEditContent(
diff --git a/VisualEditor/tests/phpunit/BSApiVisualEditorTasksTest.php 
b/VisualEditor/tests/phpunit/BSApiVisualEditorTasksTest.php
new file mode 100644
index 0000000..35938f1
--- /dev/null
+++ b/VisualEditor/tests/phpunit/BSApiVisualEditorTasksTest.php
@@ -0,0 +1,59 @@
+<?php
+
+/**
+ * @group medium
+ * @group API
+ * @group Database
+ * @group BlueSpice
+ * @group BlueSpiceReadConfirmation
+ */
+class BSApiVisualEditorTasksTest extends BSApiTasksTestBase {
+       protected function getModuleName() {
+               return 'bs-visualeditor-tasks';
+       }
+
+       public function setUp() {
+               parent::setUp();
+               $this->insertPage( 'Dummy', 'Some random text' );
+               $this->insertPage( 'File:Test' );
+       }
+
+       public function testCheckLinks() {
+               $aData = array(
+                       'Dummy' => true,
+                       'Idontexist' => false,
+                       'Media:Test' => true,
+                       'File:Test' => true
+               );
+
+               $oResponse = $this->executeTask(
+                       'checkLinks',
+                       array_keys( $aData )
+               );
+
+               $this->assertTrue( $oResponse->success, 'checkLinks task 
failed' );
+               $aPayload = $oResponse->payload;
+               $this->assertEquals( array_values( $aData ), $aPayload, 
'Response is not as expected' );
+       }
+
+       public function testSaveArticle() {
+               $oTitle = Title::newFromText( 'Dummy' );
+               $iArticleID = $oTitle->getArticleID();
+
+               $oResponse = $this->executeTask(
+                       'saveArticle',
+                       [
+                               'articleId' => $iArticleID,
+                               'text' => 'Sample text',
+                               'pageName' => 'Dummy',
+                               'summary' => 'API test change',
+                               'editsection' => false
+                       ]
+               );
+
+               $this->assertTrue( $oResponse->success, 'checkLinks task 
failed' );
+               $oWikiPage = WikiPage::factory( $oTitle );
+               $sText = $oWikiPage->getText();
+               $this->assertEquals( 'Sample text', $sText );
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/371001
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I547af55ccfad8a6e01fa596cbfdd34f703eed784
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: ItSpiderman <d.savulje...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to