/**
  * This is a test for expected exceptions when saving UNIQUE.
  * See http://propel.phpdb.org/trac/ticket/2
  */
 public function testSaveUnique()
 {
     // The whole test is in a transaction, but this test needs real transactions
     $this->con->commit();
     $emp = new BookstoreEmployee();
     $emp->setName(md5(microtime()));
     $acct = new BookstoreEmployeeAccount();
     $acct->setBookstoreEmployee($emp);
     $acct->setLogin("foo");
     $acct->setPassword("bar");
     $acct->save();
     // now attempt to create a new acct
     $acct2 = $acct->copy();
     try {
         $acct2->save();
         $this->fail("Expected PropelException in first attempt to save object with duplicate value for UNIQUE constraint.");
     } catch (\Exception $x) {
         try {
             // attempt to save it again
             $acct3 = $acct->copy();
             $acct3->save();
             $this->fail("Expected PropelException in second attempt to save object with duplicate value for UNIQUE constraint.");
         } catch (\Exception $x) {
             // this is expected.
         }
         // now let's double check that it can succeed if we're not violating the constraint.
         $acct3->setLogin("foo2");
         $acct3->save();
     }
     $this->con->beginTransaction();
 }