try {
$sha1 = $this->getStringField( 'content_sha1' );
} catch ( IncompleteRevisionException $ex ) {
+ $sha1 = null;
+ }
+
+ // Compute if missing. Missing could mean null or empty.
+ if ( $sha1 === null || $sha1 === '' ) {
$format = $this->hasField( 'format_name' )
? $this->getStringField( 'format_name' )
: null;
$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() );
$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() );
}
$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 );