Page MenuHomeWickedGov Phorge

AnonIpBlockTargetTest.php
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

AnonIpBlockTargetTest.php

<?php
use MediaWiki\Block\AnonIpBlockTarget;
use MediaWiki\Block\Block;
use MediaWiki\User\UserIdentity;
/**
* @covers \MediaWiki\Block\AnonIpBlockTarget
*/
class AnonIpBlockTargetTest extends MediaWikiUnitTestCase {
public function testToString() {
$target = new AnonIpBlockTarget( '1.2.3.4', false );
$this->assertSame( '1.2.3.4', $target->toString() );
}
public function testGetType() {
$target = new AnonIpBlockTarget( '1.2.3.4', false );
$this->assertSame( Block::TYPE_IP, $target->getType() );
}
public function testGetSpecificity() {
$target = new AnonIpBlockTarget( '1.2.3.4', false );
$this->assertSame( 2, $target->getSpecificity() );
}
public function testGetLogPage() {
$target = new AnonIpBlockTarget( '1.2.3.4', false );
$logPage = $target->getLogPage();
$this->assertSame( NS_USER, $logPage->getNamespace() );
$this->assertSame( '1.2.3.4', $logPage->getDBkey() );
}
public function testGetUserPage() {
$target = new AnonIpBlockTarget( '1.2.3.4', false );
$page = $target->getUserPage();
$this->assertSame( NS_USER, $page->getNamespace() );
$this->assertSame( '1.2.3.4', $page->getDBkey() );
}
public function testGetUserIdentity() {
$target = new AnonIpBlockTarget( '1.2.3.4', 'enwiki' );
$user = $target->getUserIdentity();
$this->assertSame( 'enwiki', $user->getWikiId() );
$this->assertSame( '1.2.3.4', $user->getName() );
$this->assertSame( 0, $user->getId( 'enwiki' ) );
}
public function testValidateForCreation() {
$target = new AnonIpBlockTarget( '1.2.3.4', 'enwiki' );
$this->assertStatusGood( $target->validateForCreation() );
}
public function testToHex() {
$target = new AnonIpBlockTarget( '1.2.3.4', 'enwiki' );
$this->assertSame( '01020304', $target->toHex() );
}
public function testToHexRange() {
$target = new AnonIpBlockTarget( '1.2.3.4', 'enwiki' );
$this->assertSame( [ '01020304', '01020304' ], $target->toHexRange() );
}
public function testGetLegacyTuple() {
$target = new AnonIpBlockTarget( '1.2.3.4', 'enwiki' );
[ $resTarget, $resType ] = $target->getLegacyTuple();
$this->assertSame( Block::TYPE_IP, $resType );
$this->assertInstanceOf( UserIdentity::class, $resTarget );
$this->assertSame( 0, $resTarget->getId( 'enwiki' ) );
$this->assertSame( '1.2.3.4', $resTarget->getName() );
}
public function testGetWikiId() {
$target = new AnonIpBlockTarget( '1.2.3.4', 'enwiki' );
$this->assertSame( 'enwiki', $target->getWikiId() );
}
}

File Metadata

Mime Type
text/x-php
Expires
Aug 17 2026, 05:18 (11 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
57/1d/f09efbf13b8f44da73bc42ddf805
Default Alt Text
AnonIpBlockTargetTest.php (2 KB)

Event Timeline