Yes, it has.
It was tested in 1939 in the infamous Miller case, a total set-up, one of the worst cases in Supreme Court history.
The decision upheld the individual right of the Second Amendment, but was very muddy. Read about it here.
Miller didn’t even show up and defend himself.
Of course (smack forehead).
And the opinion of the court was pretty plain, if they had been presented any evidence that a short barreled shot had a military purpose the tax would be invalid. And every lower court since has misrepresented the SCOTUS decision.