createMock(Authenticator::class); $user = new User(); $auth->expects($this->exactly(2)) ->method('user') ->willReturnOnConsecutiveCalls( null, $user ); $extension = new Globals($auth); $globals = $extension->getGlobals(); $this->assertGlobalsExists('user', [], $globals); $globals = $extension->getGlobals(); $this->assertGlobalsExists('user', $user, $globals); } }