Imam al-Shafi'i (may Allah have mercy on him) said: "Whoever drinks anything of wine (khamr), while knowing that it is khamr, his testimony is to be rejected, whether he became intoxicated or not, because its prohibition is a nass (explicit text) in the Book of Allah."
And regarding drinks other than khamr, a large amount of which intoxicates, he said: "Such a person, in our view, is in error by drinking it and sinful because of it, but his testimony is not rejected because of it." That is, because there is a difference of opinion about it.
Imam al-Shafi'i (may Allah have mercy on him) said: "(This ruling holds) as long as he does not become intoxicated by it; then when he becomes intoxicated by it, his testimony is rejected, because intoxication is forbidden according to all the people of Islam."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الشهادات / Q20947