33 'wgExtraNamespaces' => [
35 12313 =>
'Dummy_talk',
37 'wgNamespaceContentModels' => [ 12312 =>
'DUMMY' ],
42 [
'DUMMY' =>
'DummyContentHandlerForTesting' ]
45 if ( !$this->the_properties ) {
46 $this->the_properties = [
47 "property1" =>
"value1",
48 "property2" =>
"value2",
49 "property3" =>
"value3",
50 "property4" =>
"value4"
54 if ( !$this->title1 ) {
56 'PagePropsTest_page_1',
60 $this->title1 = $page->getTitle();
61 $page1ID = $this->title1->getArticleID();
65 if ( !$this->title2 ) {
67 'PagePropsTest_page_2',
71 $this->title2 = $page->getTitle();
72 $page2ID = $this->title2->getArticleID();
83 $page1ID = $this->title1->getArticleID();
84 $result = $pageProps->getProperties( $this->title1,
"property1" );
85 $this->assertArrayHasKey( $page1ID,
$result,
"Found property" );
86 $this->assertEquals(
$result[$page1ID],
"value1",
"Get property" );
95 $page1ID = $this->title1->getArticleID();
96 $page2ID = $this->title2->getArticleID();
102 $this->assertArrayHasKey( $page1ID,
$result,
"Found page 1 property" );
103 $this->assertArrayHasKey( $page2ID,
$result,
"Found page 2 property" );
104 $this->assertEquals(
$result[$page1ID],
"value1",
"Get property page 1" );
105 $this->assertEquals(
$result[$page2ID],
"value1",
"Get property page 2" );
114 $page1ID = $this->title1->getArticleID();
115 $page2ID = $this->title2->getArticleID();
125 $this->assertArrayHasKey( $page1ID,
$result,
"Found page 1 property" );
126 $this->assertArrayHasKey(
"property1",
$result[$page1ID],
"Found page 1 property 1" );
127 $this->assertArrayHasKey(
"property2",
$result[$page1ID],
"Found page 1 property 2" );
128 $this->assertArrayHasKey( $page2ID,
$result,
"Found page 2 property" );
129 $this->assertArrayHasKey(
"property1",
$result[$page2ID],
"Found page 2 property 1" );
130 $this->assertArrayHasKey(
"property2",
$result[$page2ID],
"Found page 2 property 2" );
131 $this->assertEquals(
$result[$page1ID][
"property1"],
"value1",
"Get page 1 property 1" );
132 $this->assertEquals(
$result[$page1ID][
"property2"],
"value2",
"Get page 1 property 2" );
133 $this->assertEquals(
$result[$page2ID][
"property1"],
"value1",
"Get page 2 property 1" );
134 $this->assertEquals(
$result[$page2ID][
"property2"],
"value2",
"Get page 2 property 2" );
150 $page1ID = $this->title1->getArticleID();
151 $result = $pageProps->getAllProperties( $this->title1 );
152 $this->assertArrayHasKey( $page1ID,
$result,
"Found properties" );
153 $properties =
$result[$page1ID];
154 $patched = array_replace_recursive( $properties, $this->the_properties );
155 $this->assertEquals( $patched, $properties,
"Get all properties" );
164 $page1ID = $this->title1->getArticleID();
165 $page2ID = $this->title2->getArticleID();
171 $this->assertArrayHasKey( $page1ID,
$result,
"Found page 1 properties" );
172 $this->assertArrayHasKey( $page2ID,
$result,
"Found page 2 properties" );
173 $properties1 =
$result[$page1ID];
174 $patched = array_replace_recursive( $properties1, $this->the_properties );
175 $this->assertEquals( $patched, $properties1,
"Get all properties page 1" );
176 $properties2 =
$result[$page2ID];
177 $patched = array_replace_recursive( $properties2, $this->the_properties );
178 $this->assertEquals( $patched, $properties2,
"Get all properties page 2" );
189 $page1ID = $this->title1->getArticleID();
190 $value1 = $pageProps->getProperties( $this->title1,
"property1" );
191 $this->
setProperty( $page1ID,
"property1",
"another value" );
192 $value2 = $pageProps->getProperties( $this->title1,
"property1" );
193 $this->assertEquals( $value1, $value2,
"Single cache" );
204 $page1ID = $this->title1->getArticleID();
205 $properties1 = $pageProps->getAllProperties( $this->title1 );
206 $this->
setProperty( $page1ID,
"property1",
"another value" );
207 $properties2 = $pageProps->getAllProperties( $this->title1 );
208 $this->assertEquals( $properties1, $properties2,
"Multi Cache" );
221 $page1ID = $this->title1->getArticleID();
222 $pageProps->getProperties( $this->title1,
"property1" );
223 $new_value =
"another value";
224 $this->
setProperty( $page1ID,
"property1", $new_value );
225 $pageProps->getAllProperties( $this->title1 );
226 $result = $pageProps->getProperties( $this->title1,
"property1" );
227 $this->assertArrayHasKey( $page1ID,
$result,
"Found property" );
228 $this->assertEquals(
$result[$page1ID],
"another value",
"Clear cache" );
231 protected function createPage( $page, $text, $model =
null ) {
232 if ( is_string( $page ) ) {
233 if ( !preg_match(
'/:/', $page ) &&
243 if ( $page instanceof
Title ) {
247 if ( $page->exists() ) {
248 $page->doDeleteArticle(
"done" );
260 foreach ( $properties
as $propertyName => $propertyValue ) {
262 'pp_page' => $pageID,
263 'pp_propname' => $propertyName,
264 'pp_value' => $propertyValue
284 protected function setProperty( $pageID, $propertyName, $propertyValue ) {
286 $properties[$propertyName] = $propertyValue;