Deprecating something means to say something nasty about it, or to draw its character into question. For example, "this function is lazy and good for nothing". Deprecatory remarks by a developer are generally taken as a warning that violence will soon be done against the function in question. Other developers are thus warned to avoid associating with the deprecated function. However, since wfDeprecated() was introduced, it has become obvious that the targets of deprecation are not limited to functions. Developers can deprecate literally anything: a parameter, a return value, a file format, Mondays, the concept of being, etc. wfDeprecated() requires every deprecatory statement to begin with "use of", leading to some awkward sentences. For example, one might say: "Use of your mouth to cough without it being covered by your arm is deprecated since 2020." So, introduce wfDeprecatedMsg(), which allows deprecation messages to be specified in plain text, with the caller description being optionally appended. Migrate incorrect or gramatically awkward uses of wfDeprecated() to wfDeprecatedMsg(). Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
class ArticleTest extends \MediaWikiTestCase {
|
|
|
|
/**
|
|
* @var Title
|
|
*/
|
|
private $title;
|
|
/**
|
|
* @var Article
|
|
*/
|
|
private $article;
|
|
|
|
/** creates a title object and its article object */
|
|
protected function setUp() : void {
|
|
parent::setUp();
|
|
$this->title = Title::makeTitle( NS_MAIN, 'SomePage' );
|
|
$this->article = new Article( $this->title );
|
|
}
|
|
|
|
/** cleanup title object and its article object */
|
|
protected function tearDown() : void {
|
|
parent::tearDown();
|
|
$this->title = null;
|
|
$this->article = null;
|
|
}
|
|
|
|
/**
|
|
* @covers Article::__get
|
|
*/
|
|
public function testImplementsGetMagic() {
|
|
$this->filterDeprecated( '/Accessing Article::\$mLatest/' );
|
|
$this->assertFalse( $this->article->mLatest, "Article __get magic" );
|
|
}
|
|
|
|
/**
|
|
* @depends testImplementsGetMagic
|
|
* @covers Article::__set
|
|
*/
|
|
public function testImplementsSetMagic() {
|
|
$this->filterDeprecated( '/Accessing Article::\$mLatest/' );
|
|
$this->filterDeprecated( '/Setting Article::\$mLatest/' );
|
|
$this->article->mLatest = 2;
|
|
$this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
|
|
}
|
|
|
|
/**
|
|
* @covers Article::__get
|
|
* @covers Article::__set
|
|
*/
|
|
public function testGetOrSetOnNewProperty() {
|
|
$this->filterDeprecated(
|
|
'/Accessing Article::\$ext_someNewProperty/'
|
|
);
|
|
$this->filterDeprecated(
|
|
'/Setting Article::\$ext_someNewProperty/'
|
|
);
|
|
$this->article->ext_someNewProperty = 12;
|
|
$this->assertEquals( 12, $this->article->ext_someNewProperty,
|
|
"Article get/set magic on new field" );
|
|
$this->assertEquals( 12, $this->article->getPage()->ext_someNewProperty,
|
|
"Article get/set magic on new field" );
|
|
$this->article->ext_someNewProperty = -8;
|
|
$this->assertEquals( -8, $this->article->ext_someNewProperty,
|
|
"Article get/set magic on update to new field" );
|
|
$this->assertEquals( -8, $this->article->getPage()->ext_someNewProperty,
|
|
"Article get/set magic on new field" );
|
|
}
|
|
}
|