예제 #1
0
 public function testSaveExistingObject()
 {
     $obj = new LeanObject("TestObject");
     $obj->set("foo", "bar");
     $obj->save();
     $this->assertNotEmpty($obj->getObjectId());
     $this->assertNotEmpty($obj->getCreatedAt());
     $obj->set("name", "Alice in wonderland");
     $obj->set("score", 81);
     $obj->save();
     $this->assertNotEmpty($obj->getUpdatedAt());
     $obj2 = new LeanObject("TestObject", $obj->getObjectId());
     $obj2->fetch();
     $this->assertEquals($obj2->get("name"), "Alice in wonderland");
     $this->assertEquals($obj2->get("score"), 81);
     $obj->destroy();
 }
예제 #2
0
 public function testGetCreatedAtAndUpdatedAt()
 {
     $obj = new LeanObject("TestObject");
     $obj->set("foo", "bar");
     $obj->save();
     $this->assertNotEmpty($obj->getCreatedAt());
     $this->assertTrue($obj->getCreatedAt() instanceof \DateTime);
     $obj->set("foo", "baz");
     $obj->save();
     $this->assertNotEmpty($obj->getUpdatedAt());
     $this->assertTrue($obj->getUpdatedAt() instanceof \DateTime);
     $obj->destroy();
 }