112 $this->
assertEquals( [
'A' ], $update->getModifiedRoles() );
117 $this->
assertEquals( [
'A' ], $update->getModifiedRoles() );
118 $this->
assertEquals( [
'X' ], $update->getRemovedRoles() );
124 $this->
assertSame( [], $slots->getModifiedRoles() );
125 $this->
assertSame( [], $slots->getRemovedRoles() );
128 $slots->modifySlot( $slotA );
129 $this->
assertTrue( $slots->isModifiedSlot(
'some' ) );
130 $this->
assertFalse( $slots->isRemovedSlot(
'some' ) );
131 $this->
assertSame( $slotA, $slots->getModifiedSlot(
'some' ) );
132 $this->
assertSame( [
'some' ], $slots->getModifiedRoles() );
133 $this->
assertSame( [], $slots->getRemovedRoles() );
135 $slotB = SlotRecord::newUnsaved(
'other',
new WikitextContent(
'B' ) );
136 $slots->modifySlot( $slotB );
137 $this->
assertTrue( $slots->isModifiedSlot(
'other' ) );
138 $this->
assertFalse( $slots->isRemovedSlot(
'other' ) );
139 $this->
assertSame( $slotB, $slots->getModifiedSlot(
'other' ) );
140 $this->
assertSame( [
'some',
'other' ], $slots->getModifiedRoles() );
141 $this->
assertSame( [], $slots->getRemovedRoles() );
144 $slots->modifySlot( $slotA );
148 $slots->removeSlot(
'some' );
149 $this->
assertSame( [
'other' ], $slots->getModifiedRoles() );
150 $this->
assertSame( [
'some' ], $slots->getRemovedRoles() );
153 $slots->modifySlot( $slotA );
155 $this->
assertSame( [], $slots->getRemovedRoles() );
161 $slotA = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
162 $slots->modifySlot( $slotA );
164 $this->
assertSame( [
'main' ], $slots->getModifiedRoles() );
166 $slots->removeSlot( SlotRecord::MAIN );
167 $slots->removeSlot(
'other' );
168 $this->
assertSame( [], $slots->getModifiedRoles() );
169 $this->
assertSame( [
'main',
'other' ], $slots->getRemovedRoles() );
170 $this->
assertTrue( $slots->isRemovedSlot( SlotRecord::MAIN ) );
171 $this->
assertTrue( $slots->isRemovedSlot(
'other' ) );
172 $this->
assertFalse( $slots->isModifiedSlot( SlotRecord::MAIN ) );
175 $slots->removeSlot( SlotRecord::MAIN );
179 $slots->getModifiedSlot( SlotRecord::MAIN );
185 $this->
assertSame( [], $slots->getModifiedRoles() );
189 $this->
assertSame( [
'main',
'foo' ], $slots->getModifiedRoles() );
191 $slots->removeSlot( SlotRecord::MAIN );
192 $this->
assertSame( [
'foo' ], $slots->getModifiedRoles() );
196 $slotA = SlotRecord::newUnsaved( SlotRecord::MAIN,
new WikitextContent(
'A' ) );
199 $this->
assertSame( [], $slots->getRemovedRoles() );
204 $this->
assertSame( [
'main',
'foo' ], $slots->getRemovedRoles() );
207 $this->
assertSame( [
'foo' ], $slots->getRemovedRoles() );
259 'X' => $this->
newSavedSlot(
'X',
new WikitextContent(
'X' ) ),
260 'Y' => $this->
newSavedSlot(
'Y',
new WikitextContent(
'Y' ) ),
261 'Z' => $this->
newSavedSlot(
'Z',
new WikitextContent(
'Z' ) ),
263 $slots = MutableRevisionSlots::newFromParentRevisionSlots( $parentSlots );
264 $update = RevisionSlotsUpdate::newFromContent( [
269 $update->removeSlot(
'Z' );
271 $update->apply( $slots );
272 $this->
assertSame( [
'X',
'Y',
'A' ], $slots->getSlotRoles() );
273 $this->
assertSame( $update->getModifiedSlot(
'A' ), $slots->getSlot(
'A' ) );
274 $this->
assertSame( $update->getModifiedSlot(
'Y' ), $slots->getSlot(
'Y' ) );