'model_name' => CONTENT_MODEL_WIKITEXT,
'format_name' => CONTENT_FORMAT_WIKITEXT,
'slot_revision_id' => '2',
- 'slot_inherited' => '1',
+ 'slot_origin' => '1',
'role_name' => 'myRole',
];
return (object)$data;
$this->assertSame( 'someHash', $record->getSha1() );
$this->assertSame( CONTENT_MODEL_WIKITEXT, $record->getModel() );
$this->assertSame( 2, $record->getRevision() );
+ $this->assertSame( 1, $record->getOrigin() );
$this->assertSame( 'tt:456', $record->getAddress() );
$this->assertSame( 33, $record->getContentId() );
$this->assertSame( CONTENT_FORMAT_WIKITEXT, $record->getFormat() );
'format_name' => function () {
return CONTENT_FORMAT_WIKITEXT;
},
- 'slot_inherited' => '0'
+ 'slot_revision_id' => '2',
+ 'slot_origin' => '2',
] );
$content = function () {
$this->assertNotNull( $record->getSha1() );
$this->assertSame( CONTENT_MODEL_WIKITEXT, $record->getModel() );
$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() );
$record->getAddress();
}
- public function testGetRevision_fails() {
+ public function provideIncomplete() {
+ $unsaved = SlotRecord::newUnsaved( 'main', new WikitextContent( 'A' ) );
+ yield 'unsaved' => [ $unsaved ];
+
+ $parent = new SlotRecord( $this->makeRow(), new WikitextContent( 'A' ) );
+ $inherited = SlotRecord::newInherited( $parent );
+ yield 'inherited' => [ $inherited ];
+ }
+
+ /**
+ * @dataProvider provideIncomplete
+ */
+ public function testGetRevision_fails( SlotRecord $record ) {
$record = SlotRecord::newUnsaved( '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' ) );
+ $this->setExpectedException( IncompleteRevisionException::class );
+
+ $record->getOrigin();
+ }
+
public function provideHashStability() {
yield [ '', 'phoiac9h4m842xq45sp7s6u21eteeq1' ];
yield [ 'Lorem ipsum', 'hcr5u40uxr81d3nx89nvwzclfz6r9c5' ];
}
public function testNewInherited() {
- $row = $this->makeRow( [ 'slot_revision_id' => 7, 'slot_inherited' => 0 ] );
+ $row = $this->makeRow( [ 'slot_revision_id' => 7, 'slot_origin' => 7 ] );
$parent = new SlotRecord( $row, new WikitextContent( 'A' ) );
// This would happen while doing an edit, before saving revision meta-data.
$this->assertSame( 20, $saved->getContentId() );
$this->assertSame( 'A', $saved->getContent()->getNativeData() );
$this->assertSame( 10, $saved->getRevision() );
+ $this->assertSame( 10, $saved->getOrigin() );
// make sure we didn't mess with the internal state of $unsaved
$this->assertFalse( $unsaved->hasAddress() );
$freshRow = $this->makeRow( [
'content_id' => 10,
'content_address' => 'address:1',
- 'slot_inherited' => 0,
+ 'slot_origin' => 1,
'slot_revision_id' => 1,
] );
$inheritedRow = $this->makeRow( [
'content_id' => null,
'content_address' => null,
- 'slot_inherited' => 1
+ 'slot_origin' => 0,
+ 'slot_revision_id' => 1,
] );
$inheritedSlot = new SlotRecord( $inheritedRow, new WikitextContent( 'A' ) );