@@ -29,7 +29,26 @@ - (void)testInstallationObjectIdCannotBeChanged {
2929 PFAssertThrowsInvalidArgumentException (installation[@" objectId" ] = @" abc" );
3030}
3131
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 {
3352
3453 // enable LDS
3554 [[Parse _currentManager ]loadOfflineStoreWithOptions:0 ];
@@ -46,11 +65,17 @@ - (void)testReSaveInstallation {
4665
4766 BFTask *mockedTask = [BFTask taskWithError: [NSError errorWithDomain: @" " code: kPFErrorObjectNotFound userInfo: nil ]];
4867
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+ });
5074
5175 installation.deviceToken = @" 11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306" ;
5276 [installation save ];
5377 OCMVerifyAll (commandRunner);
78+ XCTAssertEqual (2 , callCount);
5479}
5580
5681- (void )testInstallationImmutableFieldsCannotBeChanged {
0 commit comments