public function testPreSave() { $t1 = new Table2(); $this->assertNull($t1->getUpdatedAt()); $tsave = time(); $t1->save(); $this->assertEquals($t1->getUpdatedAt('U'), $tsave, 'Timestampable sets updated_column to time() on creation'); sleep(1); $tupdate = time(); $t1->save(); $this->assertEquals($t1->getUpdatedAt('U'), $tupdate, 'Timestampable changes updated_column to time() on update'); }
/** * @depends testPreSave * @depends testPreSaveManuallyUpdated */ public function testObjectKeepUpdateDateUnchanged() { $tsave = time() - 10; $t1 = new Table2(); $t1->setUpdatedAt($tsave); $t1->save(); $t1->keepUpdateDateUnchanged(); $t1->setTitle('foo'); $t1->save(); $this->assertEquals($tsave, $t1->getUpdatedAt('U'), 'keepUpdateDateUnchanged() prevents the behavior from updating the update date'); }
public function testObjectKeepUpdateDateUnchanged() { $t1 = new Table2(); $t1->setUpdatedAt(time() - 10); $tsave = time(); $t1->save(); $this->assertNotEquals($t1->getUpdatedAt('U'), $tsave); // let's save it a second time; the updated_at should be changed $t1->setTitle('foo'); $tsave = time(); $t1->save(); $this->assertEquals($t1->getUpdatedAt('U'), $tsave); // now let's do this a second time $t1 = new Table2(); $t1->setUpdatedAt(time() - 10); $tsave = time(); $t1->save(); $this->assertNotEquals($t1->getUpdatedAt('U'), $tsave); // let's save it a second time; the updated_at should be changed $t1->keepUpdateDateUnchanged(); $t1->setTitle('foo'); $tsave = time(); $t1->save(); $this->assertNotEquals($t1->getUpdatedAt('U'), $tsave, 'keepUpdateDateUnchanged() prevents the behavior from updating the update date'); }