Jeroen De Dauw has submitted this change and it was merged.
Change subject: Fixed title construction in EPArticle and added regression test
......................................................................
Fixed title construction in EPArticle and added regression test
You know that code is bad when you need to write more test code
then the code being tested to make a simple assertion :)
This fixes bug 48223
Change-Id: I13338cbd9674602462570a0aeac396128018c9e2
---
M includes/rows/EPArticle.php
M tests/phpunit/EPArticleTest.php
2 files changed, 36 insertions(+), 1 deletion(-)
Approvals:
Jeroen De Dauw: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/rows/EPArticle.php b/includes/rows/EPArticle.php
index 52977fc..d7e0d04 100644
--- a/includes/rows/EPArticle.php
+++ b/includes/rows/EPArticle.php
@@ -303,9 +303,12 @@
protected function log( User $actionUser, $subType, $comment = false ) {
$articleOwner = $this->getUser();
+ $title = Title::newFromID( $this->pageId );
+ $title = $title === null ? Title::newFromText( $this->pageTitle
) : $title;
+
$logData = array(
'user' => $actionUser,
- 'title' => Title::newFromID( $this->pageId ),
+ 'title' => $title,
'type' => 'eparticle',
'subtype' => $subType,
'parameters' => array(
diff --git a/tests/phpunit/EPArticleTest.php b/tests/phpunit/EPArticleTest.php
index 624087d..6a0ae5d 100644
--- a/tests/phpunit/EPArticleTest.php
+++ b/tests/phpunit/EPArticleTest.php
@@ -2,6 +2,7 @@
namespace EducationProgram\Tests;
+use EducationProgram\Course;
use EducationProgram\EPArticle;
/**
@@ -272,4 +273,35 @@
);
}
+ public function testLogAdditionNonExistingPage() {
+ $course = $this->getMock( 'EducationProgram\Course' );
+
+ $course->expects( $this->any() )
+ ->method( 'getTitle' )
+ ->will( $this->returnValue( \Title::newFromText(
'Foobar' ) ) );
+
+ $article = $this->getMock(
+ 'EducationProgram\EPArticle',
+ array( 'getCourse', 'getUser' ),
+ array( 1, 2, 3, 0, 'sdncjsdhbfkdhbgsfxdfg', array() )
+ );
+
+ $article->expects( $this->any() )
+ ->method( 'getCourse' )
+ ->will( $this->returnValue( $course ) );
+
+ $user = new MockSuperUser();
+
+ $article->expects( $this->any() )
+ ->method( 'getUser' )
+ ->will( $this->returnValue( $user ) );
+
+ $article->logAdittion(
+ $user,
+ false
+ );
+
+ $this->assertTrue( true );
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/62663
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I13338cbd9674602462570a0aeac396128018c9e2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/EducationProgram
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Ragesoss <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits