示例#1
0
 public function test_empty_value()
 {
     $model = Jam::build('test_position');
     $field = new Jam_Field_Timestamp(array('timezone' => new Jam_Timezone()));
     $value = $field->set($model, '', FALSE);
     $this->assertNull($value);
 }
示例#2
0
 /**
  * Tests that timestamp auto create and auto update work as expected.
  */
 public function test_auto_create_and_update()
 {
     $normal = new Jam_Field_Timestamp(array('timezone' => new Jam_Timezone()));
     $auto_create = new Jam_Field_Timestamp(array('auto_now_create' => TRUE, 'timezone' => new Jam_Timezone()));
     $auto_update = new Jam_Field_Timestamp(array('auto_now_update' => TRUE, 'timezone' => new Jam_Timezone()));
     $default_date = 1268657100;
     $model = Jam::build('test_position');
     $this->assertEquals($default_date, $normal->convert($model, $default_date, TRUE), 'Should not generate a new date on normal timestamp');
     $this->assertEquals($default_date, $normal->convert($model, $default_date, FALSE), 'Should not generate a new date on normal timestamp');
     $this->assertGreaterThan($default_date, $auto_create->convert($model, $default_date, FALSE), 'Should generate a new date on create');
     $this->assertEquals($default_date, $auto_create->convert($model, $default_date, TRUE), 'Should not generate a new date on update');
     $this->assertEquals($default_date, $auto_update->convert($model, $default_date, FALSE), 'Should generate a new date on create');
     $this->assertGreaterThan($default_date, $auto_update->convert($model, $default_date, TRUE), 'Should not generate a new date on update');
 }