2use Wikimedia\ScopedCallback;
17 $this->title = Title::newFromText(
'SomeTitle' );
18 $this->target = Title::newFromText(
'TestTarget' );
21 $this->user_comment =
'<User comment about action>';
31 $actorId = $user->getActorId();
33 $row =
new stdClass();
35 $row->rc_timestamp =
'20150921134808';
36 $row->rc_deleted =
'bar';
37 $row->rc_comment_text =
'comment';
38 $row->rc_comment_data =
null;
39 $row->rc_user = $user->getId();
41 $rc = RecentChange::newFromRow( $row );
45 'rc_timestamp' =>
'20150921134808',
46 'rc_deleted' =>
'bar',
47 'rc_comment' =>
'comment',
48 'rc_comment_text' =>
'comment',
49 'rc_comment_data' =>
null,
50 'rc_user' => $user->getId(),
51 'rc_user_text' => $user->getName(),
52 'rc_actor' => $actorId,
54 $this->assertEquals( $expected, $rc->getAttributes() );
56 $row =
new stdClass();
58 $row->rc_timestamp =
'20150921134808';
59 $row->rc_deleted =
'bar';
60 $row->rc_comment =
'comment';
61 $row->rc_user = $user->getId();
63 Wikimedia\suppressWarnings();
64 $rc = RecentChange::newFromRow( $row );
65 Wikimedia\restoreWarnings();
69 'rc_timestamp' =>
'20150921134808',
70 'rc_deleted' =>
'bar',
71 'rc_comment' =>
'comment',
72 'rc_comment_text' =>
'comment',
73 'rc_comment_data' =>
null,
74 'rc_user' => $user->getId(),
75 'rc_user_text' => $user->getName(),
76 'rc_actor' => $actorId,
78 $this->assertEquals( $expected, $rc->getAttributes() );
94 'a:1:{s:4:"root";a:2:{s:1:"A";i:1;s:1:"B";s:3:"two";}}'
119 $rc->
setAttribs( [
'rc_params' => $rawRcParams ] );
121 $actualParseParams = $rc->parseParams();
123 $this->assertEquals( $expectedParseParams, $actualParseParams );
131 [ 6000, -3000, 0,
true ],
132 [ 3000, -6000, 0,
false ],
133 [ 6000, -3000, 6000,
true ],
134 [ 3000, -6000, 6000,
true ],
147 $timestamp = time() + $offset;
148 $this->assertEquals( $expected, RecentChange::isInRCLifespan( $timestamp, $tolerance ) );
166 $this->assertEquals(
$type, RecentChange::parseFromRCType( $rcType ) );
174 $this->assertEquals( $rcType, RecentChange::parseToRCType(
$type ) );
181 return $this->getMockBuilder( PageProps::class )
182 ->disableOriginalConstructor()
198 $categoryTitle = Title::newFromText(
'CategoryPage',
NS_CATEGORY );
201 $pageProps->expects( $this->once() )
202 ->method(
'getProperties' )
203 ->with( $categoryTitle,
'hiddencat' )
204 ->will( $this->returnValue( $isHidden ? [ $categoryTitle->getArticleID() =>
'' ] : [] ) );
208 $rc = RecentChange::newForCategorization(
214 $categoryTitle->getLatestRevID(),
215 $categoryTitle->getLatestRevID(),
220 $this->assertEquals( $isHidden, $rc->getParam(
'hidden-cat' ) );
222 ScopedCallback::consume( $scopedOverride );
static overrideInstance(PageProps $store=null)
Overrides the default instance of this class This is intended for use while testing and will fail if ...
testParseFromRCType( $rcType, $type)
provideRCTypes RecentChange::parseFromRCType
testNewFromRow()
RecentChange::newFromRow RecentChange::loadFromRow.
testParseParams()
RecentChange::parseParams.
testHiddenCategoryChange( $isHidden)
provideCategoryContent RecentChange::newForCategorization
testParseToRCType( $rcType, $type)
provideRCTypes RecentChange::parseToRCType
testIsInRCLifespan( $maxAge, $offset, $tolerance, $expected)
RecentChange::isInRCLifespan provideIsInRCLifespan.
assertParseParams( $expectedParseParams, $rawRcParams)
Utility class for creating new RC entries.
static newExtraneousContext(Title $title, $request=[])
Create a new extraneous context.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
processing should stop and the error should be shown to the user * false