This is Theorem 8.3.12 (Neyman-Pearson Lemma) in George Casella stat inference. Consider testing $H_0: \theta=\theta_0$ versus $H_1: \theta=\theta_1$, where the pdf pr pmf corresponding to $\theta_i$ is $f(\textbf{x}|\theta_i),i=0,1.$, using a test with rejection region R that satisfies
$$x\in R , if f(\textbf{x}|\theta_1)>kf(\textbf{x}|\theta_0)$$ and $$x\in R^c , if f(\textbf{x}|\theta_1)<kf(\textbf{x}|\theta_0)$$ for some $k \geq 0$, and $$\alpha=P_{\theta_0}(\textbf{x}\in R).$$
Then (Sufficiency): Any test that satisfies the above is a UMP level $\alpha$ test.
In the proof, I understand $$[\phi(\textbf{x})-\phi'(\textbf{x})] [f(\textbf{x}|\theta_1)-kf(\textbf{x}|\theta_0)] \ge 0$$. But I don't stand why it still $\ge 0$ after we add an integral. The accepted answer in this question told me this is not the case. Is it always true that integral of nonnegative function is non negative
So I am confused.