public function testDefaultFkColVal()
 {
     BookstoreDataPopulator::populate();
     $sale = new BookstoreSale();
     $this->assertEquals(1, $sale->getBookstoreId(), "Expected BookstoreSale object to have a default bookstore_id of 1.");
     $bookstore = BookstorePeer::doSelectOne(new Criteria());
     $sale->setBookstore($bookstore);
     $this->assertEquals($bookstore->getId(), $sale->getBookstoreId(), "Expected FK id to have changed when assigned a valid FK.");
     $sale->setBookstore(null);
     $this->assertEquals(1, $sale->getBookstoreId(), "Expected BookstoreSale object to have reset to default ID.");
     $sale->setPublisher(null);
     $this->assertEquals(null, $sale->getPublisherId(), "Expected BookstoreSale object to have reset to NULL publisher ID.");
 }
示例#2
0
 /**
  * Tests the overriding reloadOnUpdate at runtime.
  *
  * @link       http://propel.phpdb.org/trac/ticket/378
  * @link       http://propel.phpdb.org/trac/ticket/555
  */
 public function testDefaultExpressions_ReloadOnUpdate_Override()
 {
     $b = new Bookstore();
     $b->setStoreName("Foo!");
     $b->save();
     $sale = new BookstoreSale();
     $sale->setBookstore(BookstoreQuery::create()->findOne());
     $sale->setSaleName("Spring Sale");
     $sale->save();
     // Expect that default values are set, but not default expressions
     $this->assertNull($sale->getDiscount(), "Expected discount to be NULL.");
     $sale->setSaleName("Winter Clearance");
     $sale->save(null, $skipReload = true);
     // Since reloadOnUpdate = true, we expect the discount to be set now.
     $this->assertNull($sale->getDiscount(), "Expected NULL value for discount after save.");
 }