/** * @covers ::withDb * @covers ::getDb */ public function testWithDb() { $db1 = self::getNewDb(); $db2 = self::getNewDb(); $this->assertNull(Compiler::getDb()); $self = $this; Compiler::withDb($db1, function () use($db1, $db2, $self) { $self->assertSame($db1, Compiler::getDb()); Compiler::withDb($db2, function () use($db2, $self) { $self->assertSame($db2, Compiler::getDb()); }); $self->assertSame($db1, Compiler::getDb()); }); $this->assertNull(Compiler::getDb()); }