Skip to content

Commit

Permalink
Merge branch 'master' of github.com:erikdoe/ocmock
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdoe committed May 11, 2020
2 parents 31c0871 + 2d83520 commit 10a7545
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Source/OCMock/OCClassMockObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ - (void)prepareClassForClassMethodMocking

/* adding forwarder for most class methods (instance methods on meta class) to allow for verify after run */
NSArray *methodBlackList = @[@"class", @"forwardingTargetForSelector:", @"methodSignatureForSelector:", @"forwardInvocation:", @"isBlock",
@"instanceMethodForwarderForSelector:", @"instanceMethodSignatureForSelector:"];
@"instanceMethodForwarderForSelector:", @"instanceMethodSignatureForSelector:", @"resolveClassMethod:"];
[NSObject enumerateMethodsInClass:originalMetaClass usingBlock:^(Class cls, SEL sel) {
if((cls == object_getClass([NSObject class])) || (cls == [NSObject class]) || (cls == object_getClass(cls)))
return;
Expand Down
27 changes: 27 additions & 0 deletions Source/OCMockTests/OCMockObjectRuntimeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ - (id)initMethodWithNestedInit

@end

@interface TestClassWithResolveMethods : NSObject
@end

@implementation TestClassWithResolveMethods

- (void)instanceMethod {
}

+ (BOOL)resolveInstanceMethod:(SEL)sel
{
return [super resolveInstanceMethod:sel];
}

+ (void)classMethod {
}

+ (BOOL)resolveClassMethod:(SEL)sel
{
return [super resolveClassMethod:sel];
}

@end

#pragma mark Tests for interaction with runtime and foundation conventions

Expand Down Expand Up @@ -283,6 +305,11 @@ - (void)testDynamicSubclassesShouldBeDisposed
XCTAssertEqual(numClassesBefore, numClassesAfter, @"Should have disposed dynamically generated classes.");
}

- (void)testClassesWithResolveMethodsCanBeMocked
{
// If this test fails it will crash due to recursion.
__unused id mock = OCMClassMock([TestClassWithResolveMethods class]);
}

#pragma mark verify mocks work properly when mocking init

Expand Down

0 comments on commit 10a7545

Please sign in to comment.