function testMake() { $m = $this->getManager(); $c = new Repository($m, 'pages'); $this->assertInstanceOf('SQRT\\DB\\Item', $c->make(), 'Объект Item по-умолчанию'); $c = new Repository($m, 'pages', '\\TestItem'); $p = $c->make(); $this->assertInstanceOf('\\TestItem', $p, 'Объект \\TestItem'); $this->assertTrue($p->isNew(), 'Новый объект'); $this->assertFalse($p->get('id'), 'ID не задан'); }
function testFieldsSave() { $m = $this->getManager(); $c = new Repository($m); $c->setTable('pages'); $p = $c->make(); $p->setPrimaryKey('id'); $p->setFields(array('id', 'name', 'created_at')); $p->set('id', 12); $p->set('name', 'Hello'); $p->set('hello', 'there'); $p->save(); }