Example #1
0
 public function testDelete()
 {
     $entity = new TestEntity();
     $entity->set("name", "testname");
     $entity->set("key", "key_123456");
     // insert
     $pdoStub = $this->getMock("TestPDO");
     $pdoStub->method("prepare")->will($this->returnCallback([$this, 'pdoPrepareInsert']));
     $pdoStub->method("lastInsertId")->willReturn("1");
     $database = new Database($pdoStub);
     $database->save($entity);
     $this->assertTrue($entity->isPersisted);
     $this->assertEquals(1, $entity->get("id"));
     // delete
     $pdoStub = $this->getMock("TestPDO");
     $pdoStub->method("prepare")->will($this->returnCallback([$this, 'pdoPrepareDelete']));
     $database = new Database($pdoStub);
     $database->delete($entity);
 }