Tweaks to EchoTalkPageFunctionalTest

* Fix off-by-one counting
* Fix asserting properties on the wrong event (first one instead of
  last one), luckily they are identical

Change-Id: Ib1a02476554b29b2a1d0bfdfa89859d71d7691b1
This commit is contained in:
Bartosz Dziewoński 2021-07-21 22:06:25 +02:00
parent 8823aa15cd
commit 762a2e192a

View file

@ -20,10 +20,11 @@ class EchoTalkPageFunctionalTest extends ApiTestCase {
public function testAddCommentsToTalkPage() {
$talkPage = self::$users['uploader']->getUser()->getName();
$messageCount = 0;
$this->assertCount( $messageCount, $this->fetchAllEvents() );
$expectedMessageCount = 0;
$this->assertCount( $expectedMessageCount, $this->fetchAllEvents() );
// Start a talkpage
$expectedMessageCount++;
$content = "== Section 8 ==\n\nblah blah ~~~~\n";
$this->editPage(
$talkPage,
@ -35,14 +36,13 @@ class EchoTalkPageFunctionalTest extends ApiTestCase {
// Ensure the proper event was created
$events = $this->fetchAllEvents();
// +1 is due to 0 index
$this->assertCount( 1 + $messageCount, $events, 'After initial edit a single event must exist.' );
$row = array_shift( $events );
$this->assertCount( $expectedMessageCount, $events, 'After initial edit a single event must exist.' );
$row = array_pop( $events );
$this->assertEquals( 'edit-user-talk', $row->event_type );
$this->assertEventSectionTitle( 'Section 8', $row );
// Add another message to the talk page
$messageCount++;
$expectedMessageCount++;
$content .= "More content ~~~~\n";
$this->editPage(
$talkPage,
@ -54,13 +54,13 @@ class EchoTalkPageFunctionalTest extends ApiTestCase {
// Ensure another event was created
$events = $this->fetchAllEvents();
$this->assertCount( 1 + $messageCount, $events );
$row = array_shift( $events );
$this->assertCount( $expectedMessageCount, $events );
$row = array_pop( $events );
$this->assertEquals( 'edit-user-talk', $row->event_type );
$this->assertEventSectionTitle( 'Section 8', $row );
// Add a new section and a message within it
$messageCount++;
$expectedMessageCount++;
$content .= "\n\n== EE ==\n\nhere we go with a new section ~~~~\n";
$this->editPage(
$talkPage,
@ -72,7 +72,7 @@ class EchoTalkPageFunctionalTest extends ApiTestCase {
// Ensure this event has the new section title
$events = $this->fetchAllEvents();
$this->assertCount( 1 + $messageCount, $events );
$this->assertCount( $expectedMessageCount, $events );
$row = array_pop( $events );
$this->assertEquals( 'edit-user-talk', $row->event_type );
$this->assertEventSectionTitle( 'EE', $row );