Purity Tests have been a common part of many belief systems in our world, which the world of Golarion is based on.
It is therefore logical to assume that many religions, states, or even individuals would have their own trials of ‘goodness’, which could range from elaborate ruses to test character traits, debates or trials, arbitrary tests (length of middle vs index finger say), tests of fortitude (torture), tests of endurance (climb the mountain to prove you didn’t commit the murder, god will make you fall off if you are guilty), so on.
Golarion has things our world lacks, like provable extraterrestrial beings (planar beings), magic, and ‘monsters’. Those could, or would, easily be used in many types of purity test. Whether those tests are actually accurate (using alignment mechanics in some way, or some other form of divination) would depend on the circumstance, and whether the potential testee would know that such a test is accurate (rather than bullshit) would depend on their arcane (or potentially religious) knowledge.
I’m unaware of any specific use of alignment damage in pf1e or pf2e sourcebooks to determine alignment, although my knowledge of the various adventure paths/modules is not encyclopedic. As it is a common negative fantasy trope, i’d imagine the ‘unfair test/trial’ would be the most likely form to find it in.
n.b. Alignment is one of the most argued-about things in the entirety of DnD since always. It tends to work better the less it is examined. I have personally had great success making it ‘unreliable’, such as having Lawful Good angels killing off innocents because the Divine Law requiring it outweighs the (brief) suffering of the innocents. And i’ve seen people have terrible times trying to play it ‘straight’, as it often leads to weird situations (such as this one) and odd contradictions.
Therefore my basic advice for this specific circumstance would be to allow players to use this spell, and then have the target not show any pain or damage from the spell, later turn out to be Evil (or Lawful or whatever) and simply have hidden the signs of pain/damage from the spell in some manner (which the party can roll against as normal ofc).