/**
  * Tests the use of default expressions and the reloadOnInsert and reloadOnUpdate attributes.
  *
  * @link       http://trac.propelorm.org/ticket/378
  * @link       http://trac.propelorm.org/ticket/555
  */
 public function testDefaultExpressions()
 {
     if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) {
         $this->markTestSkipped("Cannot test default expressions with SQLite");
     }
     BookstoreEmployeeAccountPeer::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 = BookstoreEmployeeAccountPeer::retrieveByPK($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.)
 }
Exemplo n.º 2
0
 /**
  * Test setting TIMESTAMP columns w/ unix int timestamp.
  */
 public function testTemporalValues_Unix()
 {
     $store = new Bookstore();
     $store->setStoreName("test");
     $store->setStoreOpenTime(strtotime('12:55'));
     $store->save();
     $this->assertEquals('12:55', $store->getStoreOpenTime(null)->format('H:i'));
     $acct = new BookstoreEmployeeAccount();
     $acct->setCreated(time());
     $this->assertEquals(date('Y-m-d H:i'), $acct->getCreated('Y-m-d H:i'));
     $review = new Review();
     $review->setReviewDate(time());
     $this->assertEquals(date('Y-m-d'), $review->getReviewDate('Y-m-d'));
 }