Merge "Permit case independent unit test directories"
[lhc/web/wiklou.git] / tests / phpunit / unit / includes / Revision / SlotRecordTest.php
index 58c1035..aab430a 100644 (file)
@@ -7,12 +7,13 @@ use LogicException;
 use MediaWiki\Revision\IncompleteRevisionException;
 use MediaWiki\Revision\SlotRecord;
 use MediaWiki\Revision\SuppressedDataException;
+use MediaWikiUnitTestCase;
 use WikitextContent;
 
 /**
  * @covers \MediaWiki\Revision\SlotRecord
  */
-class SlotRecordTest extends \MediaWikiUnitTestCase {
+class SlotRecordTest extends MediaWikiUnitTestCase {
 
        private function makeRow( $data = [] ) {
                $data = $data + [
@@ -76,7 +77,7 @@ class SlotRecordTest extends \MediaWikiUnitTestCase {
                $this->assertFalse( $record->isInherited() );
                $this->assertSame( 'A', $record->getContent()->getText() );
                $this->assertSame( 1, $record->getSize() );
-               $this->assertNotNull( $record->getSha1() );
+               $this->assertNotEmpty( $record->getSha1() );
                $this->assertSame( CONTENT_MODEL_WIKITEXT, $record->getModel() );
                $this->assertSame( 2, $record->getRevision() );
                $this->assertSame( 2, $record->getRevision() );
@@ -95,7 +96,7 @@ class SlotRecordTest extends \MediaWikiUnitTestCase {
                $this->assertFalse( $record->hasOrigin() );
                $this->assertSame( 'A', $record->getContent()->getText() );
                $this->assertSame( 1, $record->getSize() );
-               $this->assertNotNull( $record->getSha1() );
+               $this->assertNotEmpty( $record->getSha1() );
                $this->assertSame( CONTENT_MODEL_WIKITEXT, $record->getModel() );
                $this->assertSame( 'myRole', $record->getRole() );
        }
@@ -176,6 +177,14 @@ class SlotRecordTest extends \MediaWikiUnitTestCase {
                $this->assertSame( $hash, $record->getSha1() );
        }
 
+       public function testHashComputed() {
+               $row = $this->makeRow();
+               $row->content_sha1 = '';
+
+               $rec = new SlotRecord( $row, new WikitextContent( 'A' ) );
+               $this->assertNotEmpty( $rec->getSha1() );
+       }
+
        public function testNewWithSuppressedContent() {
                $input = new SlotRecord( $this->makeRow(), new WikitextContent( 'A' ) );
                $output = SlotRecord::newWithSuppressedContent( $input );