Skip to content

Commit 19a9ec4

Browse files
committed
Fix Database Fake App Tests
+ Added container property + Added an Auth fake in the container + Added the Shared utils files to the necessary targets + Added a missing XCTest reference in a test that didn't compile for me
1 parent f89357d commit 19a9ec4

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

Example/Database/Tests/Helpers/FDevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
@class FIRDatabaseReference;
2020
@class SenTest;
21+
@class XCTest;
2122

2223
@interface FDevice : NSObject
2324
- (id)initOnline;

Example/Database/Tests/Helpers/FIRFakeApp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19+
@class FIRComponentContainer;
1920
@class FIRFakeOptions;
2021

2122
@interface FIRFakeApp : NSObject
@@ -24,4 +25,5 @@
2425

2526
@property(nonatomic, readonly) FIRFakeOptions *options;
2627
@property(nonatomic, copy, readonly) NSString *name;
28+
@property(nonatomic, readonly) FIRComponentContainer *container;
2729
@end

Example/Database/Tests/Helpers/FIRFakeApp.m

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,39 @@
1616

1717
#import "FIRFakeApp.h"
1818

19+
#import "FIRAuthInteropFake.h"
20+
#import "FIRComponentTestUtilities.h"
21+
1922
@interface FIRFakeOptions: NSObject
2023
@property(nonatomic, readonly, copy) NSString *databaseURL;
21-
- (instancetype) initWithURL:(NSString *)url;
24+
- (instancetype)initWithURL:(NSString *)url;
2225
@end
2326

2427
@implementation FIRFakeOptions
25-
- (instancetype) initWithURL:(NSString *)url {
26-
self = [super init];
27-
if (self) {
28-
self->_databaseURL = url;
29-
}
30-
return self;
28+
- (instancetype)initWithURL:(NSString *)url {
29+
self = [super init];
30+
if (self) {
31+
_databaseURL = url;
32+
}
33+
return self;
3134
}
3235
@end
3336

3437
@implementation FIRFakeApp
3538

36-
- (instancetype) initWithName:(NSString *)name URL:(NSString *)url {
37-
self = [super init];
38-
if (self) {
39-
self->_name = name;
40-
self->_options = [[FIRFakeOptions alloc] initWithURL:url];
41-
}
42-
return self;
43-
}
44-
45-
- (void)getTokenForcingRefresh:(BOOL)forceRefresh withCallback:(void (^)(NSString *_Nullable token, NSError *_Nullable error))callback {
46-
callback(nil, nil);
39+
- (instancetype)initWithName:(NSString *)name URL:(NSString *)url {
40+
self = [super init];
41+
if (self) {
42+
_name = name;
43+
_options = [[FIRFakeOptions alloc] initWithURL:url];
44+
_Nullable id (^creationBlock)(FIRComponentContainer *, BOOL *) =
45+
^(FIRComponentContainer *container, BOOL *isCacheable) {
46+
return [[FIRAuthInteropFake alloc] initWithToken:nil userID:nil error:nil];
47+
};
48+
NSDictionary<NSString *, FIRComponentCreationBlock> *components =
49+
@{NSStringFromProtocol(@protocol(FIRAuthInterop)) : creationBlock};
50+
_container = [[FIRComponentContainer alloc] initWithApp:(FIRApp *)self components:components];
51+
}
52+
return self;
4753
}
4854
@end

Example/Firebase.xcodeproj/project.pbxproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@
130130
AFAF36F71EC28C25004BDEE5 /* Shared.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AFAF36F41EC28C25004BDEE5 /* Shared.xcassets */; };
131131
AFAF36F81EC28C25004BDEE5 /* Shared.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AFAF36F41EC28C25004BDEE5 /* Shared.xcassets */; };
132132
AFAF36F91EC28C25004BDEE5 /* Shared.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AFAF36F41EC28C25004BDEE5 /* Shared.xcassets */; };
133+
C852AA112158606000EF7E2D /* FIRComponentTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E28211B08A300376BFF /* FIRComponentTestUtilities.m */; };
134+
C852AA122158606000EF7E2D /* FIRAuthInteropFake.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E24211A442D00376BFF /* FIRAuthInteropFake.m */; };
135+
C852AA132158606100EF7E2D /* FIRComponentTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E28211B08A300376BFF /* FIRComponentTestUtilities.m */; };
136+
C852AA142158606100EF7E2D /* FIRAuthInteropFake.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E24211A442D00376BFF /* FIRAuthInteropFake.m */; };
137+
C852AA152158607600EF7E2D /* FIRComponentTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E28211B08A300376BFF /* FIRComponentTestUtilities.m */; };
138+
C852AA162158607600EF7E2D /* FIRAuthInteropFake.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E24211A442D00376BFF /* FIRAuthInteropFake.m */; };
133139
D01853721EDAD084003A645C /* Shared.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AFAF36F41EC28C25004BDEE5 /* Shared.xcassets */; };
134140
D01853831EDAD113003A645C /* FIRAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D018537E1EDAD0E6003A645C /* FIRAppDelegate.m */; };
135141
D01853841EDAD113003A645C /* FIRViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D01853801EDAD0E6003A645C /* FIRViewController.m */; };
@@ -607,10 +613,8 @@
607613
EDD43AA620BF7C7B005EBB36 /* FIRAnalyticsConfigurationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD43AA320BF7C7B005EBB36 /* FIRAnalyticsConfigurationTest.m */; };
608614
EDD53E25211A442D00376BFF /* FIRAuthInteropFake.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E24211A442D00376BFF /* FIRAuthInteropFake.m */; };
609615
EDD53E26211A442D00376BFF /* FIRAuthInteropFake.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E24211A442D00376BFF /* FIRAuthInteropFake.m */; };
610-
EDD53E27211A442D00376BFF /* FIRAuthInteropFake.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E24211A442D00376BFF /* FIRAuthInteropFake.m */; };
611616
EDD53E2A211B08A300376BFF /* FIRComponentTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E28211B08A300376BFF /* FIRComponentTestUtilities.m */; };
612617
EDD53E2B211B08A300376BFF /* FIRComponentTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E28211B08A300376BFF /* FIRComponentTestUtilities.m */; };
613-
EDD53E2C211B08A300376BFF /* FIRComponentTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD53E28211B08A300376BFF /* FIRComponentTestUtilities.m */; };
614618
/* End PBXBuildFile section */
615619

616620
/* Begin PBXContainerItemProxy section */
@@ -3976,7 +3980,9 @@
39763980
buildActionMask = 2147483647;
39773981
files = (
39783982
D0FE8A941ED9CAAE003F6722 /* FIRAppDelegate.m in Sources */,
3983+
C852AA122158606000EF7E2D /* FIRAuthInteropFake.m in Sources */,
39793984
D0FE8A951ED9CAAE003F6722 /* FIRViewController.m in Sources */,
3985+
C852AA112158606000EF7E2D /* FIRComponentTestUtilities.m in Sources */,
39803986
D0FE8A961ED9CAAE003F6722 /* main.m in Sources */,
39813987
);
39823988
runOnlyForDeploymentPostprocessing = 0;
@@ -4269,7 +4275,9 @@
42694275
buildActionMask = 2147483647;
42704276
files = (
42714277
DE7B8DCB1E8EF23A009EB6DF /* FIRViewController.m in Sources */,
4278+
C852AA142158606100EF7E2D /* FIRAuthInteropFake.m in Sources */,
42724279
DE7B8DCC1E8EF23A009EB6DF /* main.m in Sources */,
4280+
C852AA132158606100EF7E2D /* FIRComponentTestUtilities.m in Sources */,
42734281
DE7B8DCA1E8EF23A009EB6DF /* FIRAppDelegate.m in Sources */,
42744282
);
42754283
runOnlyForDeploymentPostprocessing = 0;
@@ -4453,16 +4461,16 @@
44534461
files = (
44544462
DEAAD4251FBA49ED0053BF48 /* FIRStoragePathTests.m in Sources */,
44554463
DEAAD42A1FBA49ED0053BF48 /* FIRStorageUpdateMetadataTests.m in Sources */,
4456-
EDD53E27211A442D00376BFF /* FIRAuthInteropFake.m in Sources */,
44574464
DEAAD4221FBA49ED0053BF48 /* FIRStorageDeleteTests.m in Sources */,
44584465
DEAAD4291FBA49ED0053BF48 /* FIRStorageTokenAuthorizerTests.m in Sources */,
44594466
DEAAD4231FBA49ED0053BF48 /* FIRStorageGetMetadataTests.m in Sources */,
44604467
DEAAD42B1FBA49ED0053BF48 /* FIRStorageUtilsTests.m in Sources */,
4468+
C852AA162158607600EF7E2D /* FIRAuthInteropFake.m in Sources */,
44614469
DEAAD4261FBA49ED0053BF48 /* FIRStorageReferenceTests.m in Sources */,
44624470
ED981887211A2E4800EDEBF4 /* FIRStorageComponentTests.m in Sources */,
4463-
EDD53E2C211B08A300376BFF /* FIRComponentTestUtilities.m in Sources */,
44644471
DEAAD4271FBA49ED0053BF48 /* FIRStorageTestHelpers.m in Sources */,
44654472
DEAAD4281FBA49ED0053BF48 /* FIRStorageTests.m in Sources */,
4473+
C852AA152158607600EF7E2D /* FIRComponentTestUtilities.m in Sources */,
44664474
DEAAD4241FBA49ED0053BF48 /* FIRStorageMetadataTests.m in Sources */,
44674475
);
44684476
runOnlyForDeploymentPostprocessing = 0;

0 commit comments

Comments
 (0)