Ryan10145 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/403576 )
Change subject: Unit test NewsletterDb::getNewsletterFromName ...................................................................... Unit test NewsletterDb::getNewsletterFromName Bug: T183811 Change-Id: Ic4fad58dc18f1916bb910c2eeb20690c53a1f4d4 --- M tests/NewsletterDbTest.php 1 file changed, 33 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Newsletter refs/changes/76/403576/1 diff --git a/tests/NewsletterDbTest.php b/tests/NewsletterDbTest.php index dcd4a27..e7b1a34 100644 --- a/tests/NewsletterDbTest.php +++ b/tests/NewsletterDbTest.php @@ -24,6 +24,9 @@ $mock->expects( $this->any() ) ->method( 'getConnection' ) ->will( $this->returnValue( $db ) ); + $mock->expects( $this->any() ) + ->method( 'getConnectionRef' ) + ->will( $this->returnValue( $db ) ); return $mock; } @@ -326,4 +329,34 @@ $this->assertTrue( $result ); } + /** + * @covers NewsletterDb::getNewsletterFromName + */ + public function testGetNewsletterFromName() { + $mockWriteDb = $this->getMockIDatabase(); + $newsletter = $this->getTestNewsletter(); + + $mockWriteDb + ->expects( $this->once() ) + ->method( 'selectRow' ) + ->with( + 'nl_newsletters', + [ 'nl_id', 'nl_name', 'nl_desc', 'nl_main_page_id' ], + [ 'nl_name' => $newsletter->getName(), 'nl_active' => 1 ] + ) + ->will( $this->returnValue( + (Object)[ + 'nl_id' => $newsletter->getId(), + 'nl_name' => $newsletter->getName(), + 'nl_desc' => $newsletter->getDescription(), + 'nl_main_page_id' => $newsletter->getPageId(), + ] + ) ); + + $table = new NewsletterDb( $this->getMockLoadBalancer( $mockWriteDb ) ); + + $result = $table->getNewsletterFromName( $newsletter->getName() ); + $this->assertEquals( $newsletter, $result ); + } + } -- To view, visit https://gerrit.wikimedia.org/r/403576 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic4fad58dc18f1916bb910c2eeb20690c53a1f4d4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Newsletter Gerrit-Branch: master Gerrit-Owner: Ryan10145 <chang.ryan10...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits