I understand that a commonly applied step (see Wikipedia for an example) in quantizing the electromagnetic field is "enclosing the field in a cubic box" and later taking a limit of that box to infinity. This allows working in a discrete countable basis of eigenvectors of momentum, finite energy per mode, number states, etc., and is used to to derive partial results an easier way than in a full-blown continuous field theory, assuming that one can defer taking the limit to generalizing these.
I'm confused by this step. It's said that in the "box", the wave vectors can only take particular discrete values. However, this would be a result of boundary conditions. (A box without boundary conditions is just an imaginary window into the entire space and doesn't pose any other restrictions than the the latter would.) It's important to specify properly what these are, which is what all the sources I've seen so far neglect silently.
If the walls of the box were, for example, reflective, this would be a major problem because this does not permit running waves at all. They always come in linear combinations resulting in a standing wave. Mathematically, their amplitudes are not independent and the canonical commutator wouldn't be true.
It seems to me that what is indeed assumed are periodic boundary conditions. This would mean the system is not enclosed in a box, but rather lives in a 3-torus! Such "box" couldn't even be constructed in our space! What's the motivation to consider something so unphysical for a model and expect the results to generalize correctly? Or, if this is not the case, what am I missing?