示例#1
0
 public function testDatabaseStorage()
 {
     MySql::executeStatement("TRUNCATE TABLE tblCompany");
     // Check to see if a record can be saved.
     $company = new Company();
     $company->CompanyName = "GCD";
     $company->save();
     $this->assertEquals(1, $company->CompanyID);
     // Check to see if the loaded record matches
     $repository = $company->getRepository();
     $repository->clearObjectCache();
     $company = new Company(1);
     $this->assertEquals("GCD", $company->CompanyName);
     // Check to see if changes are recorded
     $company->CompanyName = "GoatsBoats";
     $company->save();
     $this->assertEquals("GoatsBoats", $company->CompanyName);
     $repository->clearObjectCache();
     $company = new Company(1);
     $this->assertEquals("GoatsBoats", $company->CompanyName);
     MySql::executeStatement("TRUNCATE TABLE tblCompany");
     $repository->clearObjectCache();
     // Check to see if a record can be saved.
     $company = new Company();
     $company->CompanyName = "GCD";
     $company->save();
     $this->assertCount(1, new Collection("Company"));
     $company->delete();
     $this->assertCount(0, new Collection("Company"));
 }