Those two values have to remain in sync with constants already defined in the same file; specifically, the service name (mongo) and the container-side port number in the port mapping (27107). Technically, the port mapping is irrelevant here — the port is defined in the vendor Dockerfile.
Another consequence of having the Docker Compose file propagate the environment variables from the host to the container (for those two environment variables) is that, now, developers will have to override one or both when running the tests locally, since, for example, the hostname will be localhost in that case, whereas it'll be mongo from the perspective of things running in the Docker Compose stack.
Oops!