Variant 1: Harmonic functions have the mean value property,
$$f(z) = \frac{1}{2\pi} \int_0^{2\pi} f(z + re^{i\varphi})\,d\varphi$$
if $f$ is harmonic in $\Omega$ and $\overline{D_r(z)} \subset \Omega$.
$u$ is an entire harmonic function, hence
$$u(0) = \frac{1}{2\pi}\int_0^{2\pi} u(e^{i\varphi})\,d\varphi = \frac{1}{2\pi}\int_0^{2\pi} \cos(\varphi)e^{\cos\varphi}\cos (\sin\varphi) - \sin(\varphi)e^{\cos\varphi}\sin(\sin\varphi)\,d\varphi.$$
Whether we write $z$ and $re^{i\varphi}$ or $(x,y)$ and $(r\cos \varphi, r\sin\varphi)$ is completely immaterial. The complex notation is just more convenient sometimes.
Variant 2: Consider the analytic function $f = u+iv$.
Since $u$ and $v$ are both real, and $d\varphi$ is also real, we have
$$\begin{align}
\int_0^{2\pi} u(\cos\varphi,\sin\varphi)\,d\varphi &= \operatorname{Re}\left(\int_0^{2\pi} u(\cos\varphi,\sin\varphi)\,d\varphi + i\int_0^{2\pi} v(\cos\varphi,\sin\varphi)\,d\varphi\right)\\
&= \operatorname{Re} \int_0^{2\pi} f(e^{i\varphi})\,d\varphi.
\end{align}$$
Now,
The path integral over some closed curve is zero, over an analytic function.
is not correct as stated. On the one hand, the closed curve must not wind around any point in the complement of the function's domain - but since we have an entire function, that is vacuously satisfied here. More pertinent in the case at hand is that the integral theorem concerns only integrals with respect to $dz$ (it's a theorem about holomorphic differential forms), but here the integrand is $f(z)\,d\varphi$, not $f(z)\,dz$. Thus Cauchy's integral theorem does not apply.
However, for integrals over a circle, we have a simple correspondence between $dz$ and $d\varphi$. If we parametrise the circle as $\gamma(\varphi) = z_0 + r e^{i\varphi}$, then we have
$$dz = \gamma'(\varphi)\,d\varphi = ire^{i\varphi}\,d\varphi = i(z-z_0)\,d\varphi,$$
so we get
$$\int_0^{2\pi} f(e^{i\varphi})\,d\varphi = \int_{\lvert z\rvert = 1} f(z)\frac{dz}{iz},$$
and we see that that leads to Cauchy's integral formula,
$$\frac{1}{i} \int_{\lvert z\rvert = 1} \frac{f(z)}{z}\,dz = 2\pi\: f(0).$$
This problem appears in Paul J. Nahin, Inside Interesting Integrals, Springer, 2015, p. 60. I'll write the full details later.
Let $$I_n(\theta_0) = \int_0^\pi \frac{\cos(n\theta)}{\cos \theta - \cos \theta_0} \;\mathrm{d}\theta$$
Then using trigonometric identities one can show that
$$I_{n + 1}(\theta_0) - 2\cos\theta_0 \cdot I_n(\theta_0) + I_{n - 1}(\theta_0) = \int_0^\pi \frac{2\cos(n\theta) \cdot (\cos\theta - \cos\theta_0)}{\cos\theta - \cos\theta_0} \;\mathrm{d}\theta = \frac{\sin(n\pi)}{n} = 0$$
since $n$ is integer.
The conclusion now easily follows by induction.
Best Answer
Are those integrals even well-defined? Let $\theta_0$ be such that $\cos(\theta_0)=1/2$. For instance let $\theta_0=\frac{\pi}{3}$. Take $n=1$. Now $$\int_0^\pi\frac{\cos(n\theta_0)}{\cos\theta-\cos(\theta_0)}\;d\theta=\int_0^\pi\frac{1/2}{\cos\theta-1/2}\;d\theta.$$ This integral is actually an improper one, as $\pi/3$ is a singularity. And it does not converge.
Similarly, $$\int_0^\pi\frac{\cos(n\theta)}{\cos(\theta)-\cos(n\theta_0)}\;d\theta=\int_0^\pi\frac{\cos(\theta)}{\cos(\theta)-1/2}\;d\theta$$ fails to converge.