$record = new SlotRecord( $row, new WikitextContent( 'A' ) );
$this->assertTrue( $record->hasAddress() );
+ $this->assertTrue( $record->hasContentId() );
$this->assertTrue( $record->hasRevision() );
$this->assertTrue( $record->isInherited() );
$this->assertSame( 'A', $record->getContent()->getNativeData() );
},
'slot_revision_id' => '2',
'slot_origin' => '2',
+ 'slot_content_id' => function () {
+ return null;
+ },
] );
$content = function () {
$this->assertTrue( $record->hasAddress() );
$this->assertTrue( $record->hasRevision() );
+ $this->assertFalse( $record->hasContentId() );
$this->assertFalse( $record->isInherited() );
$this->assertSame( 'A', $record->getContent()->getNativeData() );
$this->assertSame( 1, $record->getSize() );
$this->assertSame( 2, $record->getRevision() );
$this->assertSame( 2, $record->getRevision() );
$this->assertSame( 'tt:456', $record->getAddress() );
- $this->assertSame( 33, $record->getContentId() );
$this->assertSame( CONTENT_FORMAT_WIKITEXT, $record->getFormat() );
$this->assertSame( 'myRole', $record->getRole() );
}
$record = SlotRecord::newUnsaved( 'myRole', new WikitextContent( 'A' ) );
$this->assertFalse( $record->hasAddress() );
+ $this->assertFalse( $record->hasContentId() );
$this->assertFalse( $record->hasRevision() );
$this->assertFalse( $record->isInherited() );
+ $this->assertFalse( $record->hasOrigin() );
$this->assertSame( 'A', $record->getContent()->getNativeData() );
$this->assertSame( 1, $record->getSize() );
$this->assertNotNull( $record->getSha1() );
}
public function testGetContentId_fails() {
- $record = SlotRecord::newUnsaved( 'main', new WikitextContent( 'A' ) );
+ $record = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
$this->setExpectedException( IncompleteRevisionException::class );
$record->getContentId();
}
public function testGetAddress_fails() {
- $record = SlotRecord::newUnsaved( 'main', new WikitextContent( 'A' ) );
+ $record = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
$this->setExpectedException( IncompleteRevisionException::class );
$record->getAddress();
}
public function provideIncomplete() {
- $unsaved = SlotRecord::newUnsaved( 'main', new WikitextContent( 'A' ) );
+ $unsaved = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
yield 'unsaved' => [ $unsaved ];
$parent = new SlotRecord( $this->makeRow(), new WikitextContent( 'A' ) );
* @dataProvider provideIncomplete
*/
public function testGetRevision_fails( SlotRecord $record ) {
- $record = SlotRecord::newUnsaved( 'main', new WikitextContent( 'A' ) );
+ $record = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
$this->setExpectedException( IncompleteRevisionException::class );
$record->getRevision();
* @dataProvider provideIncomplete
*/
public function testGetOrigin_fails( SlotRecord $record ) {
- $record = SlotRecord::newUnsaved( 'main', new WikitextContent( 'A' ) );
+ $record = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
$this->setExpectedException( IncompleteRevisionException::class );
$record->getOrigin();
$this->assertSame( $hash, SlotRecord::base36Sha1( $text ) );
- $record = SlotRecord::newUnsaved( 'main', new WikitextContent( $text ) );
+ $record = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( $text ) );
$this->assertSame( $hash, $record->getSha1() );
}
$this->assertSame( $parent->getAddress(), $inherited->getAddress() );
$this->assertSame( $parent->getContent(), $inherited->getContent() );
$this->assertTrue( $inherited->isInherited() );
+ $this->assertTrue( $inherited->hasOrigin() );
$this->assertFalse( $inherited->hasRevision() );
// make sure we didn't mess with the internal state of $parent
public function testNewSaved() {
// This would happen while doing an edit, before saving revision meta-data.
- $unsaved = SlotRecord::newUnsaved( 'main', new WikitextContent( 'A' ) );
+ $unsaved = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
// This would happen while doing an edit, after saving the revision meta-data
// and content meta-data.
$saved = SlotRecord::newSaved( 10, 20, 'theNewAddress', $unsaved );
$this->assertFalse( $saved->isInherited() );
+ $this->assertTrue( $saved->hasOrigin() );
$this->assertTrue( $saved->hasRevision() );
$this->assertTrue( $saved->hasAddress() );
+ $this->assertTrue( $saved->hasContentId() );
$this->assertSame( 'theNewAddress', $saved->getAddress() );
$this->assertSame( 20, $saved->getContentId() );
$this->assertSame( 'A', $saved->getContent()->getNativeData() );
// make sure we didn't mess with the internal state of $unsaved
$this->assertFalse( $unsaved->hasAddress() );
+ $this->assertFalse( $unsaved->hasContentId() );
$this->assertFalse( $unsaved->hasRevision() );
}
}
public function provideNewSaved_InvalidArgumentException() {
- $unsaved = SlotRecord::newUnsaved( 'main', new WikitextContent( 'A' ) );
+ $unsaved = SlotRecord::newUnsaved( SlotRecord::MAIN, new WikitextContent( 'A' ) );
yield 'bad revision id' => [ 'xyzzy', 5, 'address', $unsaved ];
yield 'bad content id' => [ 7, 'xyzzy', 'address', $unsaved ];