mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Merge "Hygiene: Remove unused method on EchoTargetPageMapper"
This commit is contained in:
commit
7be4aad14c
|
@ -45,39 +45,6 @@ class EchoTargetPageMapper extends EchoAbstractMapper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch EchoTargetPage records by user and set of event_id
|
||||
*
|
||||
* @param User $user
|
||||
* @param int[] $eventIds
|
||||
* @return EchoTargetPage[]|boolean
|
||||
*/
|
||||
public function fetchByUserEventIds( User $user, array $eventIds ) {
|
||||
if ( !$eventIds ) {
|
||||
return array();
|
||||
}
|
||||
$dbr = $this->dbFactory->getEchoDb( DB_SLAVE );
|
||||
|
||||
$res = $dbr->select(
|
||||
array( 'echo_target_page' ),
|
||||
self::$fields,
|
||||
array(
|
||||
'etp_user' => $user->getId(),
|
||||
'etp_event' => $eventIds
|
||||
),
|
||||
__METHOD__
|
||||
);
|
||||
if ( $res ) {
|
||||
$targetPages = array();
|
||||
foreach ( $res as $row ) {
|
||||
$targetPages[] = EchoTargetPage::newFromRow( $row );
|
||||
}
|
||||
return $targetPages;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert an EchoTargetPage instance into the database
|
||||
*
|
||||
|
|
|
@ -28,32 +28,6 @@ class EchoTargetPageMapperTest extends MediaWikiTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public function testFetchByUserEventIds() {
|
||||
$targetMapper = new EchoTargetPageMapper( $this->mockMWEchoDbFactory( array ( 'select' => false ) ) );
|
||||
$res = $targetMapper->fetchByUserEventIds( User::newFromId( 1 ), array( 1, 2, 3 ) );
|
||||
$this->assertFalse( $res );
|
||||
|
||||
$dbResult = array (
|
||||
(object)array (
|
||||
'etp_user' => 1,
|
||||
'etp_page' => 2,
|
||||
'etp_event' => 2
|
||||
),
|
||||
(object)array (
|
||||
'etp_user' => 1,
|
||||
'etp_page' => 2,
|
||||
'etp_event' => 3,
|
||||
)
|
||||
);
|
||||
$targetMapper = new EchoTargetPageMapper( $this->mockMWEchoDbFactory( array ( 'select' => $dbResult ) ) );
|
||||
$res = $targetMapper->fetchByUserEventIds( User::newFromId( 1 ), array( 1, 2, 3 ) );
|
||||
$this->assertTrue( is_array( $res ) );
|
||||
$this->assertCount( 2, $res );
|
||||
foreach ( $res as $row ) {
|
||||
$this->assertInstanceOf( 'EchoTargetPage', $row );
|
||||
}
|
||||
}
|
||||
|
||||
public function provideDataTestInsert() {
|
||||
return array (
|
||||
array (
|
||||
|
|
Loading…
Reference in a new issue