Skip to content

Commit

Permalink
Moving TwintSpy to Test target
Browse files Browse the repository at this point in the history
  • Loading branch information
goergisn committed Mar 5, 2024
1 parent 8b48062 commit 745d888
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 32 deletions.
26 changes: 21 additions & 5 deletions Adyen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@
81825CC22AC59C6400F91912 /* XCTestCase+RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CC02AC59C6400F91912 /* XCTestCase+RootViewController.swift */; };
81825CC42AC59C6C00F91912 /* XCTestCase+Wait.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CC32AC59C6C00F91912 /* XCTestCase+Wait.swift */; };
81825CC52AC59C6C00F91912 /* XCTestCase+Wait.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CC32AC59C6C00F91912 /* XCTestCase+Wait.swift */; };
8182AAB72B95D3560087568E /* TwintConforming.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8182AAB62B95D3560087568E /* TwintConforming.swift */; };
8182AAB72B95D3560087568E /* Twint+Injectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8182AAB62B95D3560087568E /* Twint+Injectable.swift */; };
8182AAB92B95FEA10087568E /* TwintSDKActionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8182AAB82B95FEA10087568E /* TwintSDKActionTests.swift */; };
8182AABB2B974D160087568E /* Twint+Spy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8182AABA2B974D160087568E /* Twint+Spy.swift */; };
8182AABD2B974E2B0087568E /* AdyenTwint.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00E5D6512AF4E99B00CDE118 /* AdyenTwint.framework */; };
8182AABE2B974E2F0087568E /* TwintSDK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00E5D6602AF527C200CDE118 /* TwintSDK.xcframework */; };
81881BCE2B1A0A510020E3F2 /* AnyPaymentMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81881BCD2B1A0A510020E3F2 /* AnyPaymentMethod.swift */; };
81896E852A4DB5F300C532CA /* SearchViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81896E842A4DB5F300C532CA /* SearchViewControllerTests.swift */; };
819064F12B90DB90007A8E37 /* AdyenTwint.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00E5D6512AF4E99B00CDE118 /* AdyenTwint.framework */; platformFilter = ios; };
Expand Down Expand Up @@ -1500,8 +1503,9 @@
81825CBA2AC59C4000F91912 /* UIViewController+Search.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+Search.swift"; sourceTree = "<group>"; };
81825CC02AC59C6400F91912 /* XCTestCase+RootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTestCase+RootViewController.swift"; sourceTree = "<group>"; };
81825CC32AC59C6C00F91912 /* XCTestCase+Wait.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTestCase+Wait.swift"; sourceTree = "<group>"; };
8182AAB62B95D3560087568E /* TwintConforming.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwintConforming.swift; sourceTree = "<group>"; };
8182AAB62B95D3560087568E /* Twint+Injectable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Twint+Injectable.swift"; sourceTree = "<group>"; };
8182AAB82B95FEA10087568E /* TwintSDKActionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwintSDKActionTests.swift; sourceTree = "<group>"; };
8182AABA2B974D160087568E /* Twint+Spy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Twint+Spy.swift"; sourceTree = "<group>"; };
81881BCD2B1A0A510020E3F2 /* AnyPaymentMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyPaymentMethod.swift; sourceTree = "<group>"; };
81896E842A4DB5F300C532CA /* SearchViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewControllerTests.swift; sourceTree = "<group>"; };
8191838D2A53062F008EB61A /* FormAddressItem+Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FormAddressItem+Configuration.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2312,6 +2316,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8182AABE2B974E2F0087568E /* TwintSDK.xcframework in Frameworks */,
8182AABD2B974E2B0087568E /* AdyenTwint.framework in Frameworks */,
E97B971322980CBA00505476 /* Adyen3DS2.framework in Frameworks */,
E97B970E22980C8400505476 /* AdyenDropIn.framework in Frameworks */,
E97B970D22980C7900505476 /* AdyenCard.framework in Frameworks */,
Expand Down Expand Up @@ -2524,7 +2530,7 @@
isa = PBXGroup;
children = (
0042EBC22B8364ED001B1F6C /* TwintSDKActionComponent.swift */,
8182AAB62B95D3560087568E /* TwintConforming.swift */,
8182AAB62B95D3560087568E /* Twint+Injectable.swift */,
);
path = SDK;
sourceTree = "<group>";
Expand Down Expand Up @@ -2839,6 +2845,15 @@
path = Picker;
sourceTree = "<group>";
};
8182AABC2B974D4D0087568E /* Twint */ = {
isa = PBXGroup;
children = (
8182AAB82B95FEA10087568E /* TwintSDKActionTests.swift */,
8182AABA2B974D160087568E /* Twint+Spy.swift */,
);
path = Twint;
sourceTree = "<group>";
};
81A2E3BC2A5C452600CF5F9C /* Views */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4066,7 +4081,7 @@
children = (
F919DFA124ED599D0027976E /* AdyenActionComponentTests.swift */,
F9AC61C1243751A70062A00D /* ActionComponentDelegateMock.swift */,
8182AAB82B95FEA10087568E /* TwintSDKActionTests.swift */,
8182AABC2B974D4D0087568E /* Twint */,
);
path = ActionComponent;
sourceTree = "<group>";
Expand Down Expand Up @@ -6880,6 +6895,7 @@
C9BB460927622F4100E6730B /* BACSConfirmationPresenterTests.swift in Sources */,
C96688BF26A6FC1C00DC7297 /* AffirmComponentTests.swift in Sources */,
F957AA722552DBC80099AD73 /* AnyRedirectComponentMock.swift in Sources */,
8182AABB2B974D160087568E /* Twint+Spy.swift in Sources */,
F9EDB79A239664B500CFB3C9 /* StoredPaymentMethodComponentTests.swift in Sources */,
F9EDB7982396643A00CFB3C9 /* CardPaymentMethodMock.swift in Sources */,
C927084027590FE800D15EA0 /* BACSInputPresenterTests.swift in Sources */,
Expand Down Expand Up @@ -7301,7 +7317,7 @@
F96757C327CF909900A16FB6 /* AnyWeChatPaySDKActionComponent.swift in Sources */,
F9175FD22594999600D653BE /* RedirectComponent.swift in Sources */,
F9237D3D28CB470E004F9929 /* ThreeDS2ClassicActionHandler+Initializers.swift in Sources */,
8182AAB72B95D3560087568E /* TwintConforming.swift in Sources */,
8182AAB72B95D3560087568E /* Twint+Injectable.swift in Sources */,
F97C851625C192D000D7F85C /* VoucherViewController.swift in Sources */,
F95A78B925C4302A0032CF7E /* ShareableVoucherView.swift in Sources */,
F9175FBA2594996000D653BE /* Action.swift in Sources */,
Expand Down
36 changes: 36 additions & 0 deletions AdyenActions/Components/SDK/Twint+Injectable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Copyright (c) 2024 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

import Foundation
#if canImport(TwintSDK)
import TwintSDK
#endif

#if canImport(TwintSDK)
extension Twint {
@objc func fetchInstalledAppConfigurations(completion: @escaping ([TWAppConfiguration]) -> Void) {
Twint.fetchInstalledAppConfigurations { configurations in
completion(configurations ?? [])
}
}

@objc func pay(withCode code: String, appConfiguration: TWAppConfiguration, callback: String) -> Error? {
Twint.pay(withCode: code, appConfiguration: appConfiguration, callback: callback)
}

@objc func controller(
for installedAppConfigurations: [TWAppConfiguration],
selectionHandler: @escaping (TWAppConfiguration?) -> Void,
cancelHandler: @escaping () -> Void
) -> UIAlertController? {
Twint.controller(
for: installedAppConfigurations.map { $0 },
selectedConfigurationHandler: { selectionHandler($0) },
cancelHandler: { cancelHandler() }
)
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,12 @@
//

import Foundation
#if canImport(TwintSDK)
import TwintSDK
#endif
@testable @_spi(AdyenInternal) import Adyen
@testable import AdyenActions

#if canImport(TwintSDK)
extension Twint {
@objc func fetchInstalledAppConfigurations(completion: @escaping ([TWAppConfiguration]) -> Void) {
Twint.fetchInstalledAppConfigurations { configurations in
completion(configurations ?? [])
}
}

@objc func pay(withCode code: String, appConfiguration: TWAppConfiguration, callback: String) -> Error? {
Twint.pay(withCode: code, appConfiguration: appConfiguration, callback: callback)
}

@objc func controller(
for installedAppConfigurations: [TWAppConfiguration],
selectionHandler: @escaping (TWAppConfiguration?) -> Void,
cancelHandler: @escaping () -> Void
) -> UIAlertController? {
Twint.controller(
for: installedAppConfigurations.map { $0 },
selectedConfigurationHandler: { selectionHandler($0) },
cancelHandler: { cancelHandler() }
)
}
}
#endif

import TwintSDK

internal class TwintSpy: Twint {

Expand Down Expand Up @@ -88,3 +65,5 @@ internal class TwintSpy: Twint {
}

}

#endif

0 comments on commit 745d888

Please sign in to comment.