Let `is_attachment()` accept an $attachment parameter, similar to `is_page()` and `is_single()`. Adds Unit Tests for all 3.

Props alex-ye for the initial patch.
Fixes #24257.



git-svn-id: https://develop.svn.wordpress.org/trunk@27016 602fd350-edb4-49c9-b593-d223f7449a82