mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Unbreak TalkPageFunctionalTest
* Clear echo_event before the test. Otherwise it contains a 'thank-you-edit' event that offsets everything. * Use standard $this->db * Use standard ~~~~ signature Bug: T67336 Change-Id: Idd09aa107d01038d03b689d9086f65a9fb7b653a
This commit is contained in:
parent
5796d46565
commit
3a7e655229
|
@ -7,37 +7,24 @@
|
|||
*/
|
||||
class EchoTalkPageFunctionalTest extends ApiTestCase {
|
||||
|
||||
/**
|
||||
* @var \Wikimedia\Rdbms\IDatabase
|
||||
*/
|
||||
protected $dbr;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->dbr = MWEchoDbFactory::getDB( DB_REPLICA );
|
||||
$this->db->delete( 'echo_event', '*' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and updates a user talk page a few times to ensure proper events are
|
||||
* created. The user performing the edits is self::$users['sysop'].
|
||||
* @group Broken
|
||||
* @covers \EchoDiscussionParser
|
||||
*/
|
||||
public function testAddCommentsToTalkPage() {
|
||||
$editor = self::$users['sysop']->getUser()->getName();
|
||||
$talkPage = self::$users['uploader']->getUser()->getName();
|
||||
// A set of messages which will be inserted
|
||||
$messages = [
|
||||
'Moar Cowbell',
|
||||
"I can haz test\n\nplz?", // checks that the parser allows multi-line comments
|
||||
'blah blah',
|
||||
];
|
||||
|
||||
$messageCount = 0;
|
||||
$this->assertCount( $messageCount, $this->fetchAllEvents() );
|
||||
|
||||
// Start a talkpage
|
||||
$content = "== Section 8 ==\n\n" . $this->signedMessage( $editor, $messages[$messageCount] );
|
||||
$content = "== Section 8 ==\n\nblah blah ~~~~\n";
|
||||
$this->editPage( $talkPage, $content, '', NS_USER_TALK );
|
||||
|
||||
// Ensure the proper event was created
|
||||
|
@ -49,7 +36,7 @@ class EchoTalkPageFunctionalTest extends ApiTestCase {
|
|||
|
||||
// Add another message to the talk page
|
||||
$messageCount++;
|
||||
$content .= $this->signedMessage( $editor, $messages[$messageCount] );
|
||||
$content .= "More content ~~~~\n";
|
||||
$this->editPage( $talkPage, $content, '', NS_USER_TALK );
|
||||
|
||||
// Ensure another event was created
|
||||
|
@ -61,7 +48,7 @@ class EchoTalkPageFunctionalTest extends ApiTestCase {
|
|||
|
||||
// Add a new section and a message within it
|
||||
$messageCount++;
|
||||
$content .= "\n\n== EE ==\n\n" . $this->signedMessage( $editor, $messages[$messageCount] );
|
||||
$content .= "\n\n== EE ==\n\nhere we go with a new section ~~~~\n";
|
||||
$this->editPage( $talkPage, $content, '', NS_USER_TALK );
|
||||
|
||||
// Ensure this event has the new section title
|
||||
|
@ -83,13 +70,9 @@ class EchoTalkPageFunctionalTest extends ApiTestCase {
|
|||
* @return \stdClass[] All events in db sorted from oldest to newest
|
||||
*/
|
||||
protected function fetchAllEvents() {
|
||||
$res = $this->dbr->select( 'echo_event', EchoEvent::selectFields(), [], __METHOD__, [ 'ORDER BY' => 'event_id ASC' ] );
|
||||
$res = $this->db->select( 'echo_event', EchoEvent::selectFields(), [], __METHOD__, [ 'ORDER BY' => 'event_id ASC' ] );
|
||||
|
||||
return iterator_to_array( $res );
|
||||
}
|
||||
|
||||
protected function signedMessage( $name, $content = 'Moar cowbell', $depth = 1 ) {
|
||||
return str_repeat( ':', $depth ) . " $content [[User:$name|$name]] ([[User talk:$name|$name]]) 00:17, 7 May 2013 (UTC)\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue