We introduce a scheme for a self-testing quantum random-number generator and demonstrate it experimentally. Compared to the fully device-independent model, our scheme requires an extra natural assumption, namely, that the mean number of photons of the signal optical modes is bounded. The scheme is self-testing, as it allows the user to verify in real time the correct functioning of the setup, hence guaranteeing the continuous generation of certified random bits. The scheme is based on a prepare-and-measure setup, which we implement in a proof-of-principle experiment using only off-the-shelf optical components. The randomness generation rate is 1.25 Mbits/s, comparable to commercial solutions. Overall, we believe that this scheme achieves a promising trade-off between the required assumptions, ease of implementation and performance.