[guided]Assume that $u$ is a classical solution. This means that the residual function $G: Q \to \mathbb{R}$ defined by
\begin{align*}
G(t,x)=\partial_t u(t,x)+\sum_{i=1}^n f_i'(u(t,x))\partial_{x_i}u(t,x)
\end{align*}
satisfies $G(t,x)=0$ for every $(t,x)\in Q$.
Let $\phi \in C_c^\infty(Q;\mathbb{R})$ be a test function. The compact support condition is the reason no boundary terms appear: there is a compact set $K:=\operatorname{supp}\phi\subset Q$, so $\phi$ vanishes outside $K$ and in particular vanishes near $t=0$, near $t=T$, and near the spatial boundary of $U$. Multiplying the pointwise equation by $\phi$ and integrating over spacetime gives
\begin{align*}
0 = \int_0^{\,T} \int_U G(t,x)\phi(t,x)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t).
\end{align*}
Expanding $G$ gives
\begin{align*}
0 = \int_0^{\,T} \int_U \partial_t u(t,x)\phi(t,x)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t) + \sum_{i=1}^n \int_0^{\,T} \int_U f_i'(u(t,x))\partial_{x_i}u(t,x)\phi(t,x)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t).
\end{align*}
We now move the derivatives from the smooth solution onto the test function. For the time derivative, choose $a,b \in \mathbb{R}$ with $0<a<b<T$ such that $\phi(t,x)=0$ whenever $t\notin(a,b)$. Integration by parts is performed on the compact interval $[a,b]$, where $u$ is $C^1$ and $\phi$ is smooth. The boundary term is
\begin{align*}
\int_U u(b,x)\phi(b,x)\,d\mathcal{L}^n(x)-\int_U u(a,x)\phi(a,x)\,d\mathcal{L}^n(x),
\end{align*}
and it is zero because $\phi(a,x)=\phi(b,x)=0$ for every $x\in U$. Therefore
\begin{align*}
\int_0^{\,T} \int_U \partial_t u(t,x)\phi(t,x)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t)
=
-\int_0^{\,T} \int_U u(t,x)\partial_t\phi(t,x)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t).
\end{align*}
For the spatial terms, fix $i\in\{1,\dots,n\}$. The chain rule applies because $f_i\in C^1(\mathbb{R};\mathbb{R})$ and $u\in C^1(Q;\mathbb{R})$, giving
\begin{align*}
\partial_{x_i}\bigl(f_i(u(t,x))\bigr)=f_i'(u(t,x))\partial_{x_i}u(t,x).
\end{align*}
Thus the $i$th spatial integral is
\begin{align*}
\int_0^{\,T} \int_U \partial_{x_i}\bigl(f_i(u(t,x))\bigr)\phi(t,x)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t).
\end{align*}
Integration by parts in $x_i$ moves $\partial_{x_i}$ onto $\phi$. The spatial boundary term vanishes because $\phi(t,\cdot)$ has compact support in $U$ for each $t$. Hence
\begin{align*}
\int_0^{\,T} \int_U f_i'(u(t,x))\partial_{x_i}u(t,x)\phi(t,x)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t)
=
-\int_0^{\,T} \int_U f_i(u(t,x))\partial_{x_i}\phi(t,x)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t).
\end{align*}
Summing this identity over $i=1,\dots,n$ converts the spatial terms into
\begin{align*}
-\int_0^{\,T} \int_U f(u(t,x))\cdot\nabla_x\phi(t,x)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t).
\end{align*}
Combining the time and spatial integrations by parts gives
\begin{align*}
0 =
-\int_0^{\,T} \int_U \left(u(t,x)\partial_t\phi(t,x)+f(u(t,x))\cdot\nabla_x\phi(t,x)\right)\,d\mathcal{L}^n(x)\,d\mathcal{L}^1(t).
\end{align*}
Multiplying by $-1$ proves the weak formulation.[/guided]