How to assert parameter attribute sub-structures in PHPUnit mock call expectations



PHP Snippet 1:

    $this->callback(function($subject){
        $b = true;
        // I tried using this constraint but can't access (autoload) this class? So is it not supposed to be used directly?
        //$c = new PHPUnit_Framework_Constraint_IsInstanceOf('\MyApp\MyEvents\MyEventData');
        // return $c->matches(subject);

        // this is the right assert, but it doesn't return the result, so I cannot use it in a callback constraint.
        \PHPUnit_Framework_Assert::assertAttributeInstanceOf('\MyApp\MyEvents\MyEventData', 'data', $subject);

        // This works but seems very "Manual"
        $b = $b && get_class($subject->data) == '\MyApp\MyEvents\MyEventData';
        $b = $b && $subject->data->thing1 == 1;
        $b = $b && $subject->data->thing2 == 1;
        return $b;
    })