The original duplicate was intended to be a 'special' toy for Spike. He wanted to vent his frustrations (in several forms) and was presumably capable of a wide range of activities.
Spike is hundreds of years old, and has likely explored many facets of sexuality (given that humans invariably acclimate to many different stimuli, and studies have shown that this is one facet of behavior where acclimation is possible).
It's therefore not surprising that 'she' would be capable of such an action. Spike could easily have many reasons to want the robot to be capable of this, given his complicated and evolving feelings towards Buffy. He could have wanted the ability to terrify her, and see the expected physical responses.
In short, there is no in-universe answer outside of "apparently, yes, she can and does urinate because she must have to take the test," but it is not unreasonable to assume it would have been a 'feature' of the original.
As to how the test was able to read as positive, that is harder to determine. Modern tests (such as the one used) test for the presence of hCG, a hormone found in human blood and urine after implantation.
We can only assume that in their attempts to make the Buffybot more realistic and able to fool more and more types of examinations, they accidentally caused her blood/urine analogs to contain a protien sufficiently similar to hCG that it triggered the reaction on the test.