[MCR] Introduce RevisionSlotsUpdate.
[lhc/web/wiklou.git] / tests / phpunit / includes / Storage / MutableRevisionSlotsTest.php
index c2a275f..f19be3b 100644 (file)
@@ -2,16 +2,44 @@
 
 namespace MediaWiki\Tests\Storage;
 
+use InvalidArgumentException;
 use MediaWiki\Storage\MutableRevisionSlots;
 use MediaWiki\Storage\RevisionAccessException;
+use MediaWiki\Storage\RevisionSlots;
 use MediaWiki\Storage\SlotRecord;
-use MediaWikiTestCase;
 use WikitextContent;
 
 /**
  * @covers \MediaWiki\Storage\MutableRevisionSlots
  */
-class MutableRevisionSlotsTest extends MediaWikiTestCase {
+class MutableRevisionSlotsTest extends RevisionSlotsTest {
+
+       /**
+        * @param SlotRecord[] $slots
+        * @return RevisionSlots
+        */
+       protected function newRevisionSlots( $slots = [] ) {
+               return new MutableRevisionSlots( $slots );
+       }
+
+       public function provideConstructorFailue() {
+               yield 'array or the wrong thing' => [
+                       [ 1, 2, 3 ]
+               ];
+       }
+
+       /**
+        * @dataProvider provideConstructorFailue
+        * @param $slots
+        *
+        * @covers \MediaWiki\Storage\RevisionSlots::__construct
+        * @covers \MediaWiki\Storage\RevisionSlots::setSlotsInternal
+        */
+       public function testConstructorFailue( $slots ) {
+               $this->setExpectedException( InvalidArgumentException::class );
+
+               new MutableRevisionSlots( $slots );
+       }
 
        public function testSetMultipleSlots() {
                $slots = new MutableRevisionSlots();
@@ -20,11 +48,13 @@ class MutableRevisionSlotsTest extends MediaWikiTestCase {
 
                $slotA = SlotRecord::newUnsaved( 'some', new WikitextContent( 'A' ) );
                $slots->setSlot( $slotA );
+               $this->assertTrue( $slots->hasSlot( 'some' ) );
                $this->assertSame( $slotA, $slots->getSlot( 'some' ) );
                $this->assertSame( [ 'some' => $slotA ], $slots->getSlots() );
 
                $slotB = SlotRecord::newUnsaved( 'other', new WikitextContent( 'B' ) );
                $slots->setSlot( $slotB );
+               $this->assertTrue( $slots->hasSlot( 'other' ) );
                $this->assertSame( $slotB, $slots->getSlot( 'other' ) );
                $this->assertSame( [ 'some' => $slotA, 'other' => $slotB ], $slots->getSlots() );
        }