5use InvalidArgumentException;
24 yield
'not an array or callable' => [
27 yield
'array of the wrong thing' => [
40 $this->setExpectedException( InvalidArgumentException::class );
49 $mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
53 $this->assertSame( $mainSlot, $slots->getSlot( SlotRecord::MAIN ) );
54 $this->assertSame( $auxSlot, $slots->getSlot(
'aux' ) );
55 $this->setExpectedException( RevisionAccessException::class );
56 $slots->getSlot(
'nothere' );
63 $mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
67 $this->assertTrue( $slots->hasSlot( SlotRecord::MAIN ) );
68 $this->assertTrue( $slots->hasSlot(
'aux' ) );
69 $this->assertFalse( $slots->hasSlot(
'AUX' ) );
70 $this->assertFalse( $slots->hasSlot(
'xyz' ) );
79 $mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN, $mainContent );
80 $auxSlot = SlotRecord::newUnsaved(
'aux', $auxContent );
83 $this->assertSame( $mainContent, $slots->getContent( SlotRecord::MAIN ) );
84 $this->assertSame( $auxContent, $slots->getContent(
'aux' ) );
85 $this->setExpectedException( RevisionAccessException::class );
86 $slots->getContent(
'nothere' );
93 $mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
97 $this->assertSame( [
'main',
'aux' ], $slots->getSlotRoles() );
106 $this->assertSame( [], $slots->getSlotRoles() );
113 $mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
114 $auxSlot = SlotRecord::newUnsaved(
'aux',
new WikitextContent(
'B' ) );
115 $slotsArray = [ $mainSlot, $auxSlot ];
118 $this->assertEquals( [
'main' => $mainSlot,
'aux' => $auxSlot ], $slots->getSlots() );
125 $mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
126 $auxSlot = SlotRecord::newInherited(
127 SlotRecord::newSaved(
132 $slotsArray = [ $mainSlot, $auxSlot ];
135 $this->assertEquals( [
'aux' => $auxSlot ], $slots->getInheritedSlots() );
142 $mainSlot = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
143 $auxSlot = SlotRecord::newInherited(
144 SlotRecord::newSaved(
149 $slotsArray = [ $mainSlot, $auxSlot ];
152 $this->assertEquals( [
'main' => $mainSlot ], $slots->getOriginalSlots() );
156 yield [ 1, [
'A' ] ];
157 yield [ 2, [
'AA' ] ];
158 yield [ 4, [
'AA',
'X',
'H' ] ];
167 foreach ( $contentStrings as $key => $contentString ) {
168 $slotsArray[] = SlotRecord::newUnsaved( strval( $key ),
new WikitextContent( $contentString ) );
172 $this->assertSame( $expected, $slots->computeSize() );
176 yield [
'ctqm7794fr2dp1taki8a88ovwnvmnmj', [
'A' ] ];
177 yield [
'eyq8wiwlcofnaiy4eid97gyfy60uw51', [
'AA' ] ];
178 yield [
'lavctqfpxartyjr31f853drgfl4kj1g', [
'AA',
'X',
'H' ] ];
189 foreach ( $contentStrings as $key => $contentString ) {
190 $slotsArray[] = SlotRecord::newUnsaved( strval( $key ),
new WikitextContent( $contentString ) );
194 $this->assertSame( $expected, $slots->computeSha1() );
198 $fooX = SlotRecord::newUnsaved(
'x',
new TextContent(
'Foo' ) );
199 $barZ = SlotRecord::newUnsaved(
'z',
new TextContent(
'Bar' ) );
200 $fooY = SlotRecord::newUnsaved(
'y',
new TextContent(
'Foo' ) );
201 $barZS = SlotRecord::newSaved( 7, 7,
'xyz', $barZ );
202 $barZ2 = SlotRecord::newUnsaved(
'z',
new TextContent(
'Baz' ) );
210 yield
'same instance' => [ $a, $a,
true ];
211 yield
'same slots' => [ $a, $a2,
true ];
212 yield
'same content' => [ $a, $a3,
true ];
214 yield
'different roles' => [ $a, $b,
false ];
215 yield
'different content' => [ $a, $c,
false ];
223 $this->assertSame( $same, $a->hasSameContent( $b ) );
224 $this->assertSame( $same, $b->hasSameContent( $a ) );
228 $fooX = SlotRecord::newUnsaved(
'x',
new TextContent(
'Foo' ) );
229 $barZ = SlotRecord::newUnsaved(
'z',
new TextContent(
'Bar' ) );
230 $fooY = SlotRecord::newUnsaved(
'y',
new TextContent(
'Foo' ) );
231 $barZS = SlotRecord::newSaved( 7, 7,
'xyz', $barZ );
232 $barZ2 = SlotRecord::newUnsaved(
'z',
new TextContent(
'Baz' ) );
240 yield
'same instance' => [ $a, $a, [] ];
241 yield
'same slots' => [ $a, $a2, [] ];
242 yield
'same content' => [ $a, $a3, [] ];
244 yield
'different roles' => [ $a, $b, [
'x',
'y' ] ];
245 yield
'different content' => [ $a, $c, [
'z' ] ];
Content object implementation for representing flat text.
Content object for wiki text pages.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
processing should stop and the error should be shown to the user * false