I am not sure, but I have seen plenty of problems in these forums of people trying to run sudo scripts through PHP. Perhaps you can have a search and see if any of them have been resolved.
Perhaps it is also a permissions issue. Does apache have permission to access /home/<user>/bin/test.sh? Typically your home directory is chmod 700, so apache will not be able to access the script.
As an aside, it is probably better to rewrite whatever code is in this script into pure PHP if possible.
I originally had nologin as apache user shell so I put /bin/sh
Please do change that back. apache does _not_ need a login shell to run a script.