MacBook Pro stuck on Apple logo, Disk Utility first aid and fsck ok My laptop (mid-2012) won't boot past the Apple logo. Safe boot won't work either. 

Disk utility in recovery mode and fsck in single-user mode both say the hard disk is fine. Verbose mode report has several lines of disk1s1 I/O error, however. 

This machine apparently does not have the diagnostic tools on it, as booting while holding down the 'D' key takes me to Internet recovery. I tried that to see if the online diagnostics would run but it gets stuck on the spinning globe screen after I enter my wifi password.

I'm thinking this could be the hard disk, the hard disk cable, or the main board. How do I tell for sure so I don't spend money unnecessarily?
Your thinking is correct.  It’s likely the hard drive, however it could also be SATA cable. Given that it’s inexpensive, it makes sense to charge it out with the replacement drive.

However, to know for certain, connect your drive to a USB to SATA adapter, if the drive works properly, then you have proof positive it’s the cable.

Doing diagnostics on a drive with an “unknown” working Component could give you erroneous results.