how early can I take a test?

Okay I had intercourse on Tuesday, and he ejaculated in me (sorry tmi), but my period ended like two days before I had sex, so my period shouldn't be coming until like the end of July. I took a morning after pill, but it doesn't have that much good ratings. So, how early can I take a pregnancy test