41 if ( !$this->the_properties ) {
42 $this->the_properties = [
43 "property1" =>
"value1",
44 "property2" =>
"value2",
45 "property3" =>
"value3",
46 "property4" =>
"value4"
50 if ( !$this->title1 ) {
52 'PagePropsTest_page_1',
56 $this->title1 = $page->getTitle();
57 $page1ID = $this->title1->getArticleID();
61 if ( !$this->title2 ) {
63 'PagePropsTest_page_2',
67 $this->title2 = $page->getTitle();
68 $page2ID = $this->title2->getArticleID();
94 $page1ID = $this->title1->getArticleID();
95 $result = $pageProps->getProperties( $this->title1,
"property1" );
96 $this->assertArrayHasKey( $page1ID,
$result,
"Found property" );
97 $this->assertEquals(
$result[$page1ID],
"value1",
"Get property" );
106 $page1ID = $this->title1->getArticleID();
107 $page2ID = $this->title2->getArticleID();
113 $this->assertArrayHasKey( $page1ID,
$result,
"Found page 1 property" );
114 $this->assertArrayHasKey( $page2ID,
$result,
"Found page 2 property" );
115 $this->assertEquals(
$result[$page1ID],
"value1",
"Get property page 1" );
116 $this->assertEquals(
$result[$page2ID],
"value1",
"Get property page 2" );
125 $page1ID = $this->title1->getArticleID();
126 $page2ID = $this->title2->getArticleID();
136 $this->assertArrayHasKey( $page1ID,
$result,
"Found page 1 property" );
137 $this->assertArrayHasKey(
"property1",
$result[$page1ID],
"Found page 1 property 1" );
138 $this->assertArrayHasKey(
"property2",
$result[$page1ID],
"Found page 1 property 2" );
139 $this->assertArrayHasKey( $page2ID,
$result,
"Found page 2 property" );
140 $this->assertArrayHasKey(
"property1",
$result[$page2ID],
"Found page 2 property 1" );
141 $this->assertArrayHasKey(
"property2",
$result[$page2ID],
"Found page 2 property 2" );
142 $this->assertEquals(
$result[$page1ID][
"property1"],
"value1",
"Get page 1 property 1" );
143 $this->assertEquals(
$result[$page1ID][
"property2"],
"value2",
"Get page 1 property 2" );
144 $this->assertEquals(
$result[$page2ID][
"property1"],
"value1",
"Get page 2 property 1" );
145 $this->assertEquals(
$result[$page2ID][
"property2"],
"value2",
"Get page 2 property 2" );
161 $page1ID = $this->title1->getArticleID();
162 $result = $pageProps->getAllProperties( $this->title1 );
163 $this->assertArrayHasKey( $page1ID,
$result,
"Found properties" );
164 $properties =
$result[$page1ID];
165 $patched = array_replace_recursive( $properties, $this->the_properties );
166 $this->assertEquals( $patched, $properties,
"Get all properties" );
175 $page1ID = $this->title1->getArticleID();
176 $page2ID = $this->title2->getArticleID();
182 $this->assertArrayHasKey( $page1ID,
$result,
"Found page 1 properties" );
183 $this->assertArrayHasKey( $page2ID,
$result,
"Found page 2 properties" );
184 $properties1 =
$result[$page1ID];
185 $patched = array_replace_recursive( $properties1, $this->the_properties );
186 $this->assertEquals( $patched, $properties1,
"Get all properties page 1" );
187 $properties2 =
$result[$page2ID];
188 $patched = array_replace_recursive( $properties2, $this->the_properties );
189 $this->assertEquals( $patched, $properties2,
"Get all properties page 2" );
200 $page1ID = $this->title1->getArticleID();
201 $value1 = $pageProps->getProperties( $this->title1,
"property1" );
202 $this->
setProperty( $page1ID,
"property1",
"another value" );
203 $value2 = $pageProps->getProperties( $this->title1,
"property1" );
204 $this->assertEquals( $value1, $value2,
"Single cache" );
215 $page1ID = $this->title1->getArticleID();
216 $properties1 = $pageProps->getAllProperties( $this->title1 );
217 $this->
setProperty( $page1ID,
"property1",
"another value" );
218 $properties2 = $pageProps->getAllProperties( $this->title1 );
219 $this->assertEquals( $properties1, $properties2,
"Multi Cache" );
232 $page1ID = $this->title1->getArticleID();
233 $pageProps->getProperties( $this->title1,
"property1" );
234 $new_value =
"another value";
235 $this->
setProperty( $page1ID,
"property1", $new_value );
236 $pageProps->getAllProperties( $this->title1 );
237 $result = $pageProps->getProperties( $this->title1,
"property1" );
238 $this->assertArrayHasKey( $page1ID,
$result,
"Found property" );
239 $this->assertEquals(
$result[$page1ID],
"another value",
"Clear cache" );
242 protected function createPage( $page, $text, $model =
null ) {
243 if ( is_string( $page ) ) {
244 if ( !preg_match(
'/:/', $page ) &&
254 if ( $page instanceof
Title ) {
258 if ( $page->exists() ) {
259 $page->doDeleteArticle(
"done" );
263 $page->doEditContent( $content,
"testing",
EDIT_NEW );
271 foreach ( $properties
as $propertyName => $propertyValue ) {
273 'pp_page' => $pageID,
274 'pp_propname' => $propertyName,
275 'pp_value' => $propertyValue
295 protected function setProperty( $pageID, $propertyName, $propertyValue ) {
297 $properties[$propertyName] = $propertyValue;