Page MenuHomeWickedGov Phorge

ContributionsSegmentTest.php
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

ContributionsSegmentTest.php

<?php
namespace MediaWiki\Tests\Revision;
use MediaWiki\Revision\ContributionsSegment;
use MediaWiki\Revision\MutableRevisionRecord;
use MockTitleTrait;
class ContributionsSegmentTest extends \MediaWikiUnitTestCase {
use MockTitleTrait;
public static function provideFlags() {
yield [
[]
];
yield [
[
'newest' => false,
'oldest' => true
]
];
yield [
[
'newest' => true,
'oldest' => false,
]
];
yield [
[
'newest' => false,
'oldest' => false
]
];
yield [
[
'newest' => true,
'oldest' => true,
]
];
yield [
[
'oldest' => true,
]
];
yield [
[
'newest' => true,
]
];
yield [
[
'oldest' => false,
]
];
yield [
[
'newest' => false,
]
];
}
/**
* @dataProvider provideFlags
* @covers \MediaWiki\Revision\ContributionsSegment
*/
public function testFlags( $flags ) {
$contributionsSegment = new ContributionsSegment( [], [], null, null, [], $flags );
$this->assertSame( $flags['newest'] ?? false, $contributionsSegment->isNewest() );
$this->assertSame( $flags['oldest'] ?? false, $contributionsSegment->isOldest() );
}
/**
* @covers \MediaWiki\Revision\ContributionsSegment
*/
public function testConstruction() {
$mockTitle = $this->makeMockTitle( 'Foo', [ 'id' => 1 ] );
$revisionRecords = [ new MutableRevisionRecord( $mockTitle ), new MutableRevisionRecord( $mockTitle ) ];
$before = 'before';
$after = 'after';
$tags = [ 3 => [ 'frob' ] ];
$deltas = [ 3 => -7, 5 => null ];
$contributionsSegment =
new ContributionsSegment( $revisionRecords, $tags, $before, $after, $deltas );
$this->assertSame( $revisionRecords, $contributionsSegment->getRevisions() );
$this->assertSame( $tags[3], $contributionsSegment->getTagsForRevision( 3 ) );
$this->assertSame( [], $contributionsSegment->getTagsForRevision( 17 ) );
$this->assertSame( $before, $contributionsSegment->getBefore() );
$this->assertSame( $after, $contributionsSegment->getAfter() );
$this->assertFalse( $contributionsSegment->isNewest(), 'isNewest' );
$this->assertFalse( $contributionsSegment->isOldest(), 'isOldest' );
$this->assertSame( $deltas[3], $contributionsSegment->getDeltaForRevision( 3 ) );
$this->assertNull( $contributionsSegment->getDeltaForRevision( 5 ) );
$this->assertNull( $contributionsSegment->getDeltaForRevision( 77 ) );
}
}

File Metadata

Mime Type
text/x-php
Expires
Wed, Aug 19, 10:14 (2 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
12/61/d9f200dd6afcf8ded0c1c7e28fa6
Default Alt Text
ContributionsSegmentTest.php (2 KB)

Event Timeline