2011-06-29 22:09:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
2020-06-30 15:09:24 +00:00
|
|
|
class ArticleTest extends \MediaWikiIntegrationTestCase {
|
2011-06-29 22:09:51 +00:00
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
|
|
|
|
private $title;
|
|
|
|
|
/**
|
|
|
|
|
* @var Article
|
|
|
|
|
*/
|
|
|
|
|
private $article;
|
2011-07-03 17:51:11 +00:00
|
|
|
|
|
|
|
|
/** creates a title object and its article object */
|
2019-10-20 18:11:08 +00:00
|
|
|
protected function setUp() : void {
|
2012-10-23 17:02:36 +00:00
|
|
|
parent::setUp();
|
2012-10-08 10:56:20 +00:00
|
|
|
$this->title = Title::makeTitle( NS_MAIN, 'SomePage' );
|
2011-07-03 17:51:11 +00:00
|
|
|
$this->article = new Article( $this->title );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** cleanup title object and its article object */
|
2019-10-20 18:11:08 +00:00
|
|
|
protected function tearDown() : void {
|
2012-10-23 17:02:36 +00:00
|
|
|
parent::tearDown();
|
2012-10-08 10:56:20 +00:00
|
|
|
$this->title = null;
|
2011-07-03 17:51:11 +00:00
|
|
|
$this->article = null;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-24 10:54:02 +00:00
|
|
|
/**
|
|
|
|
|
* @covers Article::__get
|
|
|
|
|
*/
|
2013-10-23 22:51:31 +00:00
|
|
|
public function testImplementsGetMagic() {
|
Introduce wfDeprecatedMsg()
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
2020-06-12 04:18:35 +00:00
|
|
|
$this->filterDeprecated( '/Accessing Article::\$mLatest/' );
|
2019-09-17 14:19:26 +00:00
|
|
|
$this->assertFalse( $this->article->mLatest, "Article __get magic" );
|
2011-07-03 17:51:11 +00:00
|
|
|
}
|
2011-06-29 22:09:51 +00:00
|
|
|
|
2011-07-03 17:51:11 +00:00
|
|
|
/**
|
|
|
|
|
* @depends testImplementsGetMagic
|
2013-10-24 10:54:02 +00:00
|
|
|
* @covers Article::__set
|
2011-07-03 17:51:11 +00:00
|
|
|
*/
|
2013-10-23 22:51:31 +00:00
|
|
|
public function testImplementsSetMagic() {
|
Introduce wfDeprecatedMsg()
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
2020-06-12 04:18:35 +00:00
|
|
|
$this->filterDeprecated( '/Accessing Article::\$mLatest/' );
|
|
|
|
|
$this->filterDeprecated( '/Setting Article::\$mLatest/' );
|
2011-12-11 13:29:21 +00:00
|
|
|
$this->article->mLatest = 2;
|
|
|
|
|
$this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
|
2011-07-03 17:51:11 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 10:54:02 +00:00
|
|
|
/**
|
|
|
|
|
* @covers Article::__get
|
|
|
|
|
* @covers Article::__set
|
|
|
|
|
*/
|
2013-10-23 22:51:31 +00:00
|
|
|
public function testGetOrSetOnNewProperty() {
|
Introduce wfDeprecatedMsg()
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
2020-06-12 04:18:35 +00:00
|
|
|
$this->filterDeprecated(
|
|
|
|
|
'/Accessing Article::\$ext_someNewProperty/'
|
2020-03-19 03:23:43 +00:00
|
|
|
);
|
Introduce wfDeprecatedMsg()
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
2020-06-12 04:18:35 +00:00
|
|
|
$this->filterDeprecated(
|
|
|
|
|
'/Setting Article::\$ext_someNewProperty/'
|
2020-03-19 03:23:43 +00:00
|
|
|
);
|
2011-07-03 17:51:11 +00:00
|
|
|
$this->article->ext_someNewProperty = 12;
|
|
|
|
|
$this->assertEquals( 12, $this->article->ext_someNewProperty,
|
|
|
|
|
"Article get/set magic on new field" );
|
2020-03-19 03:23:43 +00:00
|
|
|
$this->assertEquals( 12, $this->article->getPage()->ext_someNewProperty,
|
|
|
|
|
"Article get/set magic on new field" );
|
2011-07-03 17:51:11 +00:00
|
|
|
$this->article->ext_someNewProperty = -8;
|
|
|
|
|
$this->assertEquals( -8, $this->article->ext_someNewProperty,
|
|
|
|
|
"Article get/set magic on update to new field" );
|
2020-03-19 03:23:43 +00:00
|
|
|
$this->assertEquals( -8, $this->article->getPage()->ext_someNewProperty,
|
|
|
|
|
"Article get/set magic on new field" );
|
2011-07-03 17:51:11 +00:00
|
|
|
}
|
2020-09-07 09:30:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers Article::__sleep
|
|
|
|
|
*/
|
|
|
|
|
public function testSerialization_fails() {
|
|
|
|
|
$this->expectException( LogicException::class );
|
|
|
|
|
serialize( $this->article );
|
|
|
|
|
}
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|