function testSaveNewRecord() { $object = new TestOneTableObject(); $object->set('annotation', $annotation = 'Super annotation'); $object->set('content', $content = 'Super content'); $object->set('news_date', $news_date = '2005-01-10'); $this->assertTrue($object->isNew()); $id = $object->save(); $this->assertFalse($object->isNew()); $this->assertNotNull($object->getId()); $this->assertEqual($object->getId(), $id); $this->assertEqual($this->db->count('test_one_table_object'), 1); $record = $this->db->selectRecord('test_one_table_object'); $this->assertEqual($record->get('id'), $id); $this->assertEqual($record->get('annotation'), $annotation); $this->assertEqual($record->get('content'), $content); $this->assertEqual($record->get('news_date'), $news_date); $this->assertEqual($record->get('id'), $object->getId()); }
function initOneTableObject($ordr = '') { $object = new TestOneTableObject(); $object->set('annotation', 'Annotation ' . rand(0, 1000)); $object->set('content', 'Content ' . rand(0, 1000)); $object->set('news_date', date("Y-m-d", time())); $ordr = $ordr ?: rand(0, 1000); $object->set('ordr', $ordr); return $object; }
function testDestroyRecordForGlobalListener() { $object = new TestOneTableObject(); $object->set('annotation', 'Super annotation'); $object->set('content', 'Super content'); $object->set('news_date', '2005-01-10'); $object->save(); $delegate = new lmbActiveRecordEventHaldlerStubDelegate(); $delegate->subscribeGloballyForEvents($object); $object->destroy(); $this->assertEqual($delegate->getCallsOrder(), '|onBeforeDestroy TestOneTableObject||onAfterDestroy TestOneTableObject|'); }