Added test. In some cases $result is null

Replaces https://github.com/owncloud/core/pull/7375 by adding also a check whether the value is empty

@MorrisJobke @schiesbn 
On second thought, it is also easy to see that the `isset($result)` is pointless, because the variable will obviously always be defined, even if it is null.