File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -584,6 +584,13 @@ public extension StorageType {
584584 return firstObject ( ofType: PaymentGatewayAccount . self, matching: predicate)
585585 }
586586
587+ /// Returns a charge with a specified `siteID` and `chargeID`
588+ ///
589+ func loadWCPayCharge( siteID: Int64 , chargeID: String ) -> WCPayCharge ? {
590+ let predicate = \WCPayCharge . siteID == siteID && \WCPayCharge . id == chargeID
591+ return firstObject ( ofType: WCPayCharge . self, matching: predicate)
592+ }
593+
587594 // MARK: - System plugins
588595
589596 /// Returns all stored system plugins for a provided `siteID`.
Original file line number Diff line number Diff line change @@ -1170,4 +1170,21 @@ final class StorageTypeExtensionsTests: XCTestCase {
11701170 // Then
11711171 XCTAssertEqual ( foundSystemPlugin, systemPlugin2)
11721172 }
1173+
1174+ func test_load_WCPayCharge_by_siteID_and_chargeID( ) throws {
1175+ // Given
1176+ let charge1 = storage. insertNewObject ( ofType: WCPayCharge . self)
1177+ charge1. id = " ch_1 "
1178+ charge1. siteID = sampleSiteID
1179+
1180+ let charge2 = storage. insertNewObject ( ofType: WCPayCharge . self)
1181+ charge2. id = " ch_2 "
1182+ charge2. siteID = sampleSiteID
1183+
1184+ // When
1185+ let foundCharge = try XCTUnwrap ( storage. loadWCPayCharge ( siteID: sampleSiteID, chargeID: " ch_2 " ) )
1186+
1187+ // Then
1188+ XCTAssertEqual ( foundCharge, charge2)
1189+ }
11731190}
You can’t perform that action at this time.
0 commit comments