PHPUnit builds a fresh instance of the test class for every test method, so anything assigned in setUp() is rebuilt each time. That isolation is the point, and it is also why an expensive fixture created there makes the suite slow.
public static function setUpBeforeClass()
{
self::$pdo = new PDO('sqlite::memory:'); // once for the class
self::migrate(self::$pdo);
}
public function setUp()
{
self::$pdo->beginTransaction(); // per test
}
public function tearDown()
{
self::$pdo->rollBack(); // per test
}
The combination above is the useful one: build the schema once, then wrap each test in a transaction that is rolled back, so tests stay isolated without paying for migration every time. Anything static must be reset in tearDownAfterClass(), because it outlives the class and will leak into whatever runs next.