The <PERSON> did lock the door sometimes, but not every night.
When <PERSON> was being punished for letting the boa constrictor out at the zoo, he considered sneaking to the kitchen for some food, but knew he’d have to wait for the <PERSON> to be asleep first. That would mean it was nighttime, and even though <PERSON> was in trouble, the door wasn’t locked for the night.
“Uncle <PERSON> waited until <PERSON> was safely out of the house before starting on <PERSON>. He was so angry he could hardly speak. He managed to say, ‘Go – cupboard – stay – no meals,’ before he collapsed into a chair and Aunt <PERSON> had to run and get him a large brandy.
*
<PERSON> lay in his dark cupboard much later, wishing he had a watch. He didn’t know what time it was and he couldn’t be sure the <PERSON> were asleep yet. Until they were, he couldn’t risk sneaking to the kitchen for some food.”
- Harry Potter and the Philosopher's Stone, Chapter 2 (The Vanishing Glass)
They did, however, lock him in the cupboard sometimes, usually it seems as punishment. When he ended on top of his school, he’d been locked in there, though it’s not said how long.
“The <PERSON> had received a very angry letter from <PERSON>’s headmistress telling them <PERSON> had been climbing school buildings. But all he’d tried to do (as he shouted at Uncle <PERSON> through the locked door of his cupboard) was jump behind the big bins outside the kitchen doors. 573
<PERSON> supposed that the wind must have caught him in mid-jump.”
- Harry Potter and the Philosopher's Stone, Chapter 2 (The Vanishing Glass)
In addition, <PERSON> wonders how he could possibly be a wizard if the <PERSON> could lock him in the cupboard.
“He’d spent his life being clouted by <PERSON> and bullied by Aunt <PERSON> and Uncle <PERSON>; if he was really a wizard, why hadn’t they been turned into warty toads every time they’d tried to lock him in his cupboard?”
- Harry Potter and the Philosopher's Stone, Chapter 4 (The Keeper of the Keys)
From that, it’s clear that they have locked him up multiple times, since it’s the first punishment he thinks of.
When they did lock him up all day, he got two bathroom breaks.
Once <PERSON> saw the warning <PERSON> got and realized that <PERSON> wasn’t allowed to do magic outside of school even though he was acting like he could, he got furious and locked <PERSON> in his bedroom all day. <PERSON> was allowed out to use the bathroom twice, once in the morning, once in the evening.
“He was bearing down on <PERSON> like a great bulldog, all his teeth bared. ‘Well, I’ve got news for you, boy … I’m locking you up … you’re never going back to that school … never … and if you try and magic yourself out – they’ll expel you!’ And laughing like a maniac, he dragged <PERSON> back upstairs.
Uncle <PERSON> was as bad as his word. The following morning, he paid a man to fit bars on <PERSON>’s window. He himself fitted the cat-flap in the bedroom door, so that small amounts of food could be pushed inside three times a day. They let <PERSON> out to use the bathroom morning and evening. Otherwise, he was locked in his room around the clock.”
- Harry Potter and the Chamber of Secrets, Chapter 2 (Dobby’s Warning)
He was allowed two bathroom breaks, but it’s not clear if the <PERSON> would have let him out for another one if he needed it. (They were very upset with him, but they also wouldn’t want pee anywhere it shouldn’t be in their nice clean house.) <PERSON> also wasn’t being fed much at that point, he’d get a bit of food but not much (which he had to share between himself and <PERSON>), so that would make him less likely to need additional trips to the bathroom. 573