diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentManagerTests.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentManagerTests.swift index 8f79b47a55..9158b3d74b 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentManagerTests.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentManagerTests.swift @@ -32,7 +32,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { private var mockDependencies: DefaultDataBrokerOperationDependencies! private var mockProfile: DataBrokerProtectionProfile! private var mockAgentStopper: MockAgentStopper! - private var mockFreemiumPIRUserState: MockFreemiumPIRUserState! + private var mockFreemiumPIRUserStateManager: MockFreemiumPIRUserStateManager! override func setUpWithError() throws { @@ -68,7 +68,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { phones: [], birthYear: 1992) - mockFreemiumPIRUserState = MockFreemiumPIRUserState() + mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() } func testWhenAgentStart_andProfileExists_andUserIsNotFreemium_thenActivityIsScheduled_andScheduledAllOperationsRun() async throws { @@ -82,10 +82,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let schedulerStartedExpectation = XCTestExpectation(description: "Scheduler started") var schedulerStarted = false @@ -121,10 +121,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true let schedulerStartedExpectation = XCTestExpectation(description: "Scheduler started") var schedulerStarted = false @@ -156,7 +156,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { entitlementMonitor: DataBrokerProtectionEntitlementMonitor(), authenticationManager: MockAuthenticationManager(), pixelHandler: mockPixelHandler, - stopAction: mockStopAction, freemiumPIRUserStateManager: MockFreemiumPIRUserState()) + stopAction: mockStopAction, freemiumPIRUserStateManager: MockFreemiumPIRUserStateManager()) sut = DataBrokerProtectionAgentManager( userNotificationService: mockNotificationService, activityScheduler: mockActivityScheduler, @@ -166,10 +166,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: agentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockDataManager.profileToReturn = nil - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true let stopAgentExpectation = XCTestExpectation(description: "Stop agent expectation") @@ -200,7 +200,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockDataManager.profileToReturn = nil @@ -238,10 +238,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false var startScheduledScansCalled = false mockQueueManager.startScheduledAllOperationsIfPermittedCalledCompletion = { _ in @@ -266,10 +266,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true var startScheduledScansCalled = false mockQueueManager.startScheduledScanOperationsIfPermittedCalledCompletion = { _ in @@ -294,10 +294,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false var startImmediateScansCalled = false mockQueueManager.startImmediateScanOperationsIfPermittedCalledCompletion = { _ in @@ -322,10 +322,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true var startImmediateScansCalled = false mockQueueManager.startImmediateScanOperationsIfPermittedCalledCompletion = { _ in @@ -350,7 +350,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockNotificationService.reset() @@ -372,7 +372,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockNotificationService.reset() @@ -394,7 +394,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockNotificationService.reset() mockQueueManager.startImmediateScanOperationsIfPermittedCompletionError = DataBrokerProtectionAgentErrorCollection(oneTimeError: NSError(domain: "test", code: 10)) @@ -417,7 +417,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockNotificationService.reset() mockDataManager.shouldReturnHasMatches = true @@ -440,7 +440,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) mockNotificationService.reset() mockDataManager.shouldReturnHasMatches = false @@ -463,9 +463,9 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false var startScheduledScansCalled = false mockQueueManager.startScheduledAllOperationsIfPermittedCalledCompletion = { _ in @@ -490,9 +490,9 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { operationDependencies: mockDependencies, pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true var startScheduledScansCalled = false mockQueueManager.startScheduledScanOperationsIfPermittedCalledCompletion = { _ in diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentStopperTests.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentStopperTests.swift index a605d74d6d..762ead093c 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentStopperTests.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentStopperTests.swift @@ -29,7 +29,7 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { private var mockEntitlementMonitor: DataBrokerProtectionEntitlementMonitor! private var mockDataManager: MockDataBrokerProtectionDataManager! private var mockStopAction: MockDataProtectionStopAction! - private var mockFreemiumPIRUserState: MockFreemiumPIRUserState! + private var mockFreemiumPIRUserStateManager: MockFreemiumPIRUserStateManager! private var fakeProfile: DataBrokerProtectionProfile { let name = DataBrokerProtectionProfile.Name(firstName: "John", lastName: "Doe") @@ -46,8 +46,8 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockDataManager = MockDataBrokerProtectionDataManager(pixelHandler: mockPixelHandler, fakeBrokerFlag: DataBrokerDebugFlagFakeBroker()) mockStopAction = MockDataProtectionStopAction() - mockFreemiumPIRUserState = MockFreemiumPIRUserState() - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() + mockFreemiumPIRUserStateManager.isActiveUser = false } override func tearDown() { @@ -63,14 +63,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = nil - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -80,14 +80,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = nil - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -97,14 +97,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = nil - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -114,14 +114,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = nil - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -131,14 +131,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -148,14 +148,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -165,14 +165,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -182,14 +182,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -199,14 +199,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -216,14 +216,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -239,7 +239,7 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -249,14 +249,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -266,14 +266,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -283,14 +283,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) @@ -307,14 +307,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) @@ -331,14 +331,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) @@ -355,14 +355,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) @@ -385,7 +385,7 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift index fccaf51383..0b186bc61a 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift @@ -1938,7 +1938,7 @@ struct MockMigrationsProvider: DataBrokerProtectionDatabaseMigrationsProvider { } } -final class MockFreemiumPIRUserState: FreemiumPIRUserStateManager { +final class MockFreemiumPIRUserStateManager: FreemiumPIRUserStateManager { var didOnboard = false var isActiveUser = false } diff --git a/UnitTests/DBP/Tests/DataBrokerProtectionFeatureGatekeeperTests.swift b/UnitTests/DBP/Tests/DataBrokerProtectionFeatureGatekeeperTests.swift index dd0f276105..88c2f7280f 100644 --- a/UnitTests/DBP/Tests/DataBrokerProtectionFeatureGatekeeperTests.swift +++ b/UnitTests/DBP/Tests/DataBrokerProtectionFeatureGatekeeperTests.swift @@ -28,7 +28,7 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { private var mockFeatureDisabler: MockFeatureDisabler! private var mockFeatureAvailability: MockFeatureAvailability! private var mockAccountManager: MockAccountManager! - private var mockFreemiumPIRUserState: MockFreemiumPIRUserState! + private var mockFreemiumPIRUserStateManager: MockFreemiumPIRUserStateManager! private func userDefaults() -> UserDefaults { UserDefaults(suiteName: "testing_\(UUID().uuidString)")! @@ -38,8 +38,8 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { mockFeatureDisabler = MockFeatureDisabler() mockFeatureAvailability = MockFeatureAvailability() mockAccountManager = MockAccountManager() - mockFreemiumPIRUserState = MockFreemiumPIRUserState() - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() + mockFreemiumPIRUserStateManager.isActiveUser = false } func testWhenNoAccessTokenIsFound_butEntitlementIs_andIsNotActiveFreemiumUser_thenFeatureIsDisabled() async { @@ -50,7 +50,7 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -63,12 +63,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = "token" mockAccountManager.hasEntitlementResult = .failure(MockError.someError) - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -81,12 +81,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = "token" mockAccountManager.hasEntitlementResult = .failure(MockError.someError) - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -99,12 +99,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = nil mockAccountManager.hasEntitlementResult = .failure(MockError.someError) - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -117,12 +117,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = "token" mockAccountManager.hasEntitlementResult = .success(true) - mockFreemiumPIRUserState.isActiveUser = false + mockFreemiumPIRUserStateManager.isActiveUser = false sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -135,12 +135,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = nil mockAccountManager.hasEntitlementResult = .failure(MockError.someError) - mockFreemiumPIRUserState.isActiveUser = true + mockFreemiumPIRUserStateManager.isActiveUser = true sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserState) + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -154,18 +154,6 @@ private enum MockError: Error { case someError } -private class MockFeatureDisabler: DataBrokerProtectionFeatureDisabling { - var disableAndDeleteWasCalled = false - - func disableAndDelete() { - disableAndDeleteWasCalled = true - } - - func reset() { - disableAndDeleteWasCalled = false - } -} - private class MockFeatureAvailability: SubscriptionFeatureAvailability { var mockFeatureAvailable: Bool = false var mockSubscriptionPurchaseAllowed: Bool = false diff --git a/UnitTests/Menus/MoreOptionsMenuTests.swift b/UnitTests/Menus/MoreOptionsMenuTests.swift index 775ae57226..fe0c8ce65b 100644 --- a/UnitTests/Menus/MoreOptionsMenuTests.swift +++ b/UnitTests/Menus/MoreOptionsMenuTests.swift @@ -41,7 +41,7 @@ final class MoreOptionsMenuTests: XCTestCase { private var mockFreemiumPIRFeatureFlagger = MockFreemiumPIRFeatureFlagger() private var mockFreemiumPIRPresenter = MockFreemiumPIRPresenter() private var freemiumPIRFeature: DefaultFreemiumPIRFeature! - private var mockFreemiumPIRUserState = MockFreemiumPIRUserState() + private var mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() var moreOptionsMenu: MoreOptionsMenu! @@ -68,7 +68,7 @@ final class MoreOptionsMenuTests: XCTestCase { purchasePlatform: .appStore), canPurchase: false) - freemiumPIRFeature = DefaultFreemiumPIRFeature(featureFlagger: mockFreemiumPIRFeatureFlagger, subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager) + freemiumPIRFeature = DefaultFreemiumPIRFeature(featureFlagger: mockFreemiumPIRFeatureFlagger, subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager, freemiumPIRUserStateManager: MockFreemiumPIRUserStateManager(), featureDisabler: MockFeatureDisabler()) } @@ -92,7 +92,7 @@ final class MoreOptionsMenuTests: XCTestCase { sharingMenu: NSMenu(), internalUserDecider: internalUserDecider, subscriptionManager: subscriptionManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserState, + freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, freemiumPIRFeature: freemiumPIRFeature, freemiumPIRPresenter: mockFreemiumPIRPresenter) @@ -284,7 +284,7 @@ final class MoreOptionsMenuTests: XCTestCase { subscriptionManager.canPurchase = true subscriptionManager.currentEnvironment = SubscriptionEnvironment(serviceEnvironment: .production, purchasePlatform: .stripe) mockFreemiumPIRFeatureFlagger.isEnabled = true - mockFreemiumPIRUserState.didOnboard = false + mockFreemiumPIRUserStateManager.didOnboard = false setupMoreOptionsMenu() let freemiumItemIndex = try XCTUnwrap(moreOptionsMenu.indexOfItem(withTitle: UserText.freemiumPIROptionsMenuItem)) @@ -303,7 +303,7 @@ final class MoreOptionsMenuTests: XCTestCase { subscriptionManager.canPurchase = true subscriptionManager.currentEnvironment = SubscriptionEnvironment(serviceEnvironment: .production, purchasePlatform: .stripe) mockFreemiumPIRFeatureFlagger.isEnabled = true - mockFreemiumPIRUserState.didOnboard = true + mockFreemiumPIRUserStateManager.didOnboard = true setupMoreOptionsMenu() let freemiumItemIndex = try XCTUnwrap(moreOptionsMenu.indexOfItem(withTitle: UserText.freemiumPIROptionsMenuItem)) diff --git a/UnitTests/RemoteMessaging/RemoteMessagingClientTests.swift b/UnitTests/RemoteMessaging/RemoteMessagingClientTests.swift index 2a8ed992bf..5066561bcc 100644 --- a/UnitTests/RemoteMessaging/RemoteMessagingClientTests.swift +++ b/UnitTests/RemoteMessaging/RemoteMessagingClientTests.swift @@ -30,8 +30,12 @@ struct MockRemoteMessagingStoreProvider: RemoteMessagingStoreProviding { } } -struct MockFreemiumPIRUserState: FreemiumPIRUserStateManager { - var didOnboard = false +final class MockFreemiumPIRUserStateManager: FreemiumPIRUserStateManager { + var didOnboard = false { + didSet { + print("Here") + } + } var isActiveUser = false }