public function testBelongsToWithImmediate() { $t = new Thing(); $t->name = "sean"; $t->save(); $f = new Foo(); $f->name = "kate"; $t->associateWith($f); $t1 = new Thing($t->id); $t1->retrieve(); $f1 = new Foo($f->id); $f1->retrieve(array('with' => array('thing' => array('join_strategy' => 'Immediate')))); $this->assertTrue($t1->equals($f1->thing)); }
} function indirect($other) { echo __METHOD__ . "\n"; $this = $other; $result = $this = $other; print $result->prop; print $this->prop; } function retrieve(&$other) { echo __METHOD__ . "\n"; $other = $this; } } $object = new Foo(); $object->prop = "Hello\n"; $other = new Foo(); $other->prop = "World\n"; $object->replace($other); $object->indirect($other); print $object->prop; // still shows 'Hello' $object->retrieve($other); print $other->prop; // shows 'Hello' ?> ===DONE=== --EXPECTF-- Fatal error: Cannot re-assign $this in %s on line %d, position %d
public function testTxInsertRollback() { $tx_cnx = $this->getCnxForTxn(); # begin a new cnx $tx_cnx->beginTxn(); # create and save a foo on our new cnx $foo = new Foo(); $foo->_setDb($tx_cnx); $foo->name = "joe"; $foo->save(); # should be visible from txn $tx_foo = new Foo($foo->id); $tx_foo->_setDb($tx_cnx); $ex = null; try { $tx_foo->retrieve(); } catch (Exception $e) { $ex = $e; } $this->assertTrue(is_null($ex)); $this->assertEquals($foo->name, $tx_foo->name); # rollback $tx_cnx->rollbackTxn(); # should no longer be visible in txn $tx_foo = new Foo($foo->id); $tx_foo->_setDb($tx_cnx); $ex = null; try { $tx_foo->retrieve(); } catch (Exception $e) { $ex = $e; } $this->assertTrue(is_a($ex, 'Pfw_Exception_NotFound')); }