Every test method is executed on a new instance of the test case class. There is indeed a setup method that is called before each test, and it's called setUp.
public function setUp() {
$this->object = newBar();
}
public function testFoo() {
// use $this->object here
}
public function testBar() {
// use $this->object here too, though it's a *different* instance of newBar
}
If you need to share state across all tests for a test case--often ill-advised--you can use the static setUpBeforeClass method.
public static function setUpBeforeClass() {
self::$object = newBar();
}
public function testFoo() {
// use self::$object here
}
public function testBar() {
// use self::$object here too, same instance as above
}