/** * @covers RecordsMan\RecordSet::add */ public function testAdd() { /** @var Item $item */ $item = Item::load(1); $subsCount = $item->subItems->count(); $item->subItems->add(SubItem::create(['title' => 'New subitem'])); $this->assertEquals($subsCount + 1, $item->subItems->count()); /** @var SubItem $createdItem */ $createdItem = SubItem::findFirst(null, ['id' => 'DESC']); $this->assertEquals($createdItem->item_id, $item->id); $this->assertEquals('New subitem', $createdItem->title); //TODO: Test counters updating, through relations, etc. }
public function testGetRawFieldValue() { /** @var Item $item */ $item = Item::load(1); $this->assertEquals('Item7 (top level)', $item->getRawFieldValue('title')); $this->assertNull($item->getRawFieldValue('test')); }