erikdoe / ocmock

Mock objects for Objective-C
http://ocmock.org
Apache License 2.0
2.16k stars 606 forks source link

Wrong implementation of conformsToProtocol in OCClassMockObject #324

Closed werner77 closed 7 years ago

werner77 commented 7 years ago

The method class_conformsToProtocol doesn't take superclasses into account, so the correct implementation of conformsToProtocol in OCClassMockObject would be along the following lines:

- (BOOL)conformsToProtocol:(Protocol *)aProtocol
{
    Class clazz = mockedClass;
    while (clazz != nil) {
        if (class_conformsToProtocol(clazz, aProtocol)) {
            return YES;
        }
        clazz = class_getSuperclass(clazz);
    }
    return NO;
}
werner77 commented 7 years ago

I created a pull request to fix this bug here

erikdoe commented 7 years ago

Will close this issue as the PR has been merged.