/** * Test that setting the auto-increment primary key will result in exception. */ public function testSettingAutoIncrementPK() { // The whole test is in a transaction, but this test needs real transactions $this->con->commit(); $b = new Bookstore(); $b->setId(1); $b->setStoreName("Test"); try { $b->save(); $this->fail("Expected setting auto-increment primary key to result in Exception"); } catch (Exception $x) { $this->assertInstanceOf('PropelException', $x); } // ... but we should silently ignore NULL values, since these are really // the same as "not set" in PHP world. $b = new Bookstore(); $b->setId(null); $b->setStoreName("Test2"); try { $b->save(); } catch (Exception $x) { $this->fail("Expected no exception when setting auto-increment primary key to NULL"); } // success ... $this->con->beginTransaction(); }
/** * Test that setting the auto-increment primary key will result in exception. */ public function testSettingAutoIncrementPK() { $b = new Bookstore(); $b->setId(1); $b->setStoreName("Test"); try { $b->save(); $this->fail("Expected setting auto-increment primary key to result in Exception"); } catch (Exception $x) { $this->assertType('PropelException', $x); } // ... but we should silently ignore NULL values, since these are really // the same as "not set" in PHP world. $b = new Bookstore(); $b->setId(null); $b->setStoreName("Test2"); try { $b->save(); } catch (Exception $x) { $this->fail("Expected no exception when setting auto-increment primary key to NULL"); } // success ... }