There is no specific law which states that a café or restaurant has to provide toilets. Some local authorities impose such a condition when planning permission is sought to create a new food service facility, but such conditions can't be imposed retrospectively. (so long-established cafés in such areas still won't be under any obligation to provide toilet facilities for their customers)
The majority of the smaller cafés in central London (under the control of Westminster council), for example, don't have customer toilet facilities. (Some don't even have facilities for their staff. They have to use public toilets or come to an arrangement with neighbouring premises. As long as there are adequate hand-washing facilities for the staff the law is complied with). Unless things have changed recently, there are still a couple of pubs in England where customers have to walk down the road to use the public toilets, as they're not available in those pubs.
Chris