To simplify this code and avoid using of reflections you can use function assertAttributeEmpty.
http://apidoc.phpunit.de/classes/PHPUnit_Framework_Assert/assertAttributeEmpty.html