According to OpenGL wiki:
Also keep in mind that glTexEnvi has no effect when a fragment shader is bound.
According to OpenGL 3.3 specification (in GL2 it's not deprecated yet):
Fixed-function fragment processing - AreTexturesResident, PrioritizeTextures, and TexParameter target TEXTURE_PRIORITY; TexEnv target
TEXTURE_ENV, and all associated parameters; TexEnv target TEXTURE_-
FILTER_CONTROL, and parameter name TEXTURE_LOD_BIAS;
So if it works for a particular driver it doesn't mean it'll work for others.