@@ -29,7 +29,26 @@ - (void)testInstallationObjectIdCannotBeChanged {
29
29
PFAssertThrowsInvalidArgumentException (installation[@" objectId" ] = @" abc" );
30
30
}
31
31
32
- - (void )testReSaveInstallation {
32
+ - (void )testMissingRequiredFieldWhenSave {
33
+ // mocking installation was deleted on the server
34
+ id commandRunner = PFStrictProtocolMock (@protocol (PFCommandRunning));
35
+ [Parse _currentManager ].commandRunner = commandRunner;
36
+ BFTask *mockedTask = [BFTask taskWithError: [NSError errorWithDomain: @" " code: kPFErrorMissingRequiredField userInfo: nil ]];
37
+ __block int callCount = 0 ;
38
+ OCMStub ([commandRunner runCommandAsync: [OCMArg any ] withOptions: PFCommandRunningOptionRetryIfFailed])
39
+ .andReturn (mockedTask)
40
+ .andDo (^(NSInvocation *invocation) {
41
+ callCount++;
42
+ });
43
+
44
+ PFInstallation *installation = [PFInstallation currentInstallation ];
45
+ installation.deviceToken = @" 11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306" ;
46
+ [installation save ];
47
+ OCMVerifyAll (commandRunner);
48
+ XCTAssertEqual (2 , callCount);
49
+ }
50
+
51
+ - (void )testObjectNotFoundWhenSave {
33
52
34
53
// enable LDS
35
54
[[Parse _currentManager ]loadOfflineStoreWithOptions:0 ];
@@ -46,11 +65,17 @@ - (void)testReSaveInstallation {
46
65
47
66
BFTask *mockedTask = [BFTask taskWithError: [NSError errorWithDomain: @" " code: kPFErrorObjectNotFound userInfo: nil ]];
48
67
49
- OCMStub ([commandRunner runCommandAsync: [OCMArg any ] withOptions: PFCommandRunningOptionRetryIfFailed]).andReturn (mockedTask);
68
+ __block int callCount = 0 ;
69
+ OCMStub ([commandRunner runCommandAsync: [OCMArg any ] withOptions: PFCommandRunningOptionRetryIfFailed])
70
+ .andReturn (mockedTask)
71
+ .andDo (^(NSInvocation *invocation) {
72
+ callCount++;
73
+ });
50
74
51
75
installation.deviceToken = @" 11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306" ;
52
76
[installation save ];
53
77
OCMVerifyAll (commandRunner);
78
+ XCTAssertEqual (2 , callCount);
54
79
}
55
80
56
81
- (void )testInstallationImmutableFieldsCannotBeChanged {
0 commit comments