mediawiki-extensions-Echo/tests/phpunit/model/TargetPageTest.php
Stephane Bisson b3c07eedeb Remove etp_user
Target page entries used to exist for each user
that was notified for an event. They were
removed as the notifications were marked as read.

Now they remain so that the association between
pages and events can be used for moderation
regardless of the notifications read status.

This patch removes everything about
echo_target_page.etp_user from sql and php code.

Bug: T143959
Change-Id: Ib57510e6b0e9202a7e035f8ea59955dca8a0b24a
2016-09-09 09:32:28 -04:00

87 lines
1.8 KiB
PHP

<?php
class EchoTargetPageTest extends MediaWikiTestCase {
public function testCreate() {
$this->assertNull(
EchoTargetPage::create(
$this->mockTitle( 0 ),
$this->mockEchoEvent()
)
);
$this->assertInstanceOf(
'EchoTargetPage',
EchoTargetPage::create(
$this->mockTitle( 1 ),
$this->mockEchoEvent()
)
);
}
public function testNewFromRow() {
$row = (object)array(
'etp_page' => 2,
'etp_event' => 3
);
$obj = EchoTargetPage::newFromRow( $row );
$this->assertInstanceOf( 'EchoTargetPage', $obj );
return $obj;
}
/**
* @expectedException MWException
*/
public function testNewFromRowWithException() {
$row = (object)array(
'etp_event' => 3
);
$this->assertInstanceOf( 'EchoTargetPage', EchoTargetPage::newFromRow( $row ) );
}
/**
* @depends testNewFromRow
*/
public function testToDbArray( $obj ) {
$row = $obj->toDbArray();
$this->assertTrue( is_array( $row ) );
// Not very common to assert that a field does _not_ exist
// but since we are explicitly removing it, it seems to make sense.
$this->assertArrayNotHasKey( 'etp_user', $row );
$this->assertArrayHasKey( 'etp_page', $row );
$this->assertArrayHasKey( 'etp_event', $row );
}
/**
* Mock object of Title
*/
protected function mockTitle( $pageId ) {
$event = $this->getMockBuilder( 'Title' )
->disableOriginalConstructor()
->getMock();
$event->expects( $this->any() )
->method( 'getArticleID' )
->will( $this->returnValue( $pageId ) );
return $event;
}
/**
* Mock object of EchoEvent
*/
protected function mockEchoEvent( $eventId = 1 ) {
$event = $this->getMockBuilder( 'EchoEvent' )
->disableOriginalConstructor()
->getMock();
$event->expects( $this->any() )
->method( 'getId' )
->will( $this->returnValue( $eventId ) );
return $event;
}
}