From 3a7e655229e5886e7faa097dd21b78b4f026a8b8 Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Fri, 19 Apr 2019 14:05:57 -0400 Subject: [PATCH] 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 --- tests/phpunit/TalkPageFunctionalTest.php | 27 +++++------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/tests/phpunit/TalkPageFunctionalTest.php b/tests/phpunit/TalkPageFunctionalTest.php index 789f047f0..56de83307 100644 --- a/tests/phpunit/TalkPageFunctionalTest.php +++ b/tests/phpunit/TalkPageFunctionalTest.php @@ -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"; - } - }