Example #1
0
 /**
  * Tests the use of default expressions and the reloadOnInsert and reloadOnUpdate attributes.
  *
  * @link       http://propel.phpdb.org/trac/ticket/378
  * @link       http://propel.phpdb.org/trac/ticket/555
  */
 public function testDefaultExpressions()
 {
     if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeeTableMap::DATABASE_NAME) instanceof DBSqlite) {
         $this->markTestSkipped("Cannot test default expressions with SQLite");
     }
     BookstoreEmployeeAccountTableMap::doDeleteAll();
     $b = new Bookstore();
     $b->setStoreName("Foo!");
     $b->save();
     $employee = new BookstoreEmployee();
     $employee->setName("Johnny Walker");
     $acct = new BookstoreEmployeeAccount();
     $acct->setBookstoreEmployee($employee);
     $acct->setLogin("test-login");
     $this->assertNull($acct->getCreated(), "Expected created column to be NULL.");
     $this->assertNull($acct->getAuthenticator(), "Expected authenticator column to be NULL.");
     $acct->save();
     $acct = BookstoreEmployeeAccountQuery::create()->findPk($acct->getEmployeeId());
     $this->assertNotNull($acct->getAuthenticator(), "Expected a valid (non-NULL) authenticator column after save.");
     $this->assertEquals('Password', $acct->getAuthenticator(), "Expected authenticator='Password' after save.");
     $this->assertNotNull($acct->getCreated(), "Expected a valid date after retrieving saved object.");
     $now = new DateTime("now");
     $this->assertEquals($now->format("Y-m-d"), $acct->getCreated("Y-m-d"));
     $acct->setCreated($now);
     $this->assertEquals($now->format("Y-m-d"), $acct->getCreated("Y-m-d"));
     // Unfortunately we can't really test the conjunction of reloadOnInsert and reloadOnUpdate when using just
     // default values. (At least not in a cross-db way.)
 }