Skip to content

Commit e5e01d8

Browse files
authored
Merge branch 'trunk' into woomob-965-yosemite-update
2 parents 50db480 + c9e80a2 commit e5e01d8

File tree

44 files changed

+524
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+524
-264
lines changed

Modules/Sources/Networking/Mapper/JetpackConnectionDataMapper.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ public struct JetpackConnectionData: Decodable, GeneratedFakeable, GeneratedCopi
2121
/// Whether the site is already registered with Jetpack.
2222
/// This field is available only from Jetpack 14.4, so would be nil on older versions.
2323
/// Ref: pe5sF9-401-p2
24+
/// periphery: ignore - used in UI module
2425
public let isRegistered: Bool?
2526

2627
/// Username of the Jetpack connection owner.
2728
/// This field is non-nil for sites that already register a connection with Jetpack.
29+
/// periphery: ignore - used in UI module
2830
public let connectionOwner: String?
2931

3032
/// WP blog ID, available only if site has once connected to Jetpack.
33+
/// periphery: ignore - used in UI module
3134
public let blogID: Int64?
3235

36+
/// periphery: ignore - used by codegen
3337
public init(currentUser: JetpackUser,
3438
isRegistered: Bool?,
3539
connectionOwner: String?,

Modules/Sources/Networking/Mapper/JetpackConnectionProvisionMapper.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Foundation
22

33
/// Mapper: Jetpack connection registration
44
///
5+
/// periphery: ignore - used in `JetpackConnectionRemote`
56
struct JetpackConnectionProvisionMapper: Mapper {
67

78
/// (Attempts) to extract the updated `currentUser` field from a given JSON Encoded response.

Modules/Sources/Networking/Mapper/JetpackConnectionRegistrationMapper.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Foundation
22

33
/// Mapper: Jetpack connection registration
44
///
5+
/// periphery: ignore - used in `JetpackConnectionRemote`
56
struct JetpackConnectionRegistrationMapper: Mapper {
67

78
/// (Attempts) to extract the updated `currentUser` field from a given JSON Encoded response.

Modules/Sources/Networking/Model/JetpackUser.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public struct JetpackUser: Decodable, GeneratedFakeable, GeneratedCopiable {
2323
public let blogID: Int64?
2424

2525
/// Member-wise initializer
26+
/// periphery: ignore - used by codegen
2627
public init(isConnected: Bool,
2728
isPrimary: Bool,
2829
username: String,

Modules/Sources/Networking/Model/Product/Product.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -795,13 +795,6 @@ public struct Product: Codable, GeneratedCopiable, Equatable, GeneratedFakeable
795795

796796
}
797797

798-
public extension Product {
799-
/// Default product URL {site_url}?post_type=product&p={product_id} works for all sites.
800-
func alternativePermalink(with siteURL: String) -> String {
801-
String(format: "%@?post_type=product&p=%d", siteURL, productID)
802-
}
803-
}
804-
805798
/// Defines all of the Product CodingKeys
806799
///
807800
private extension Product {

Modules/Sources/Networking/Remote/JetpackConnectionRemote.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public final class JetpackConnectionRemote: Remote {
5959

6060
/// Establishes a site-level connection between the site and WordPress.com using Jetpack.
6161
/// Returns WPCom `blogID` of the connected site.
62+
/// periphery: ignore - used in `JetpackConnectionStore` later
6263
///
6364
public func registerSite() async throws -> Int64 {
6465
let request = RESTRequest(siteURL: siteURL, method: .post, path: Path.jetpackConnectionRegister)
@@ -74,6 +75,7 @@ public final class JetpackConnectionRemote: Remote {
7475

7576
/// Provisions the connection between the site and WordPress.com using Jetpack.
7677
/// Returns a response containing scope and secret to be sent for finalizing the connection.
78+
/// periphery: ignore - used in `JetpackConnectionStore` later
7779
///
7880
public func provisionConnection() async throws -> JetpackConnectionProvisionResponse {
7981
let request = RESTRequest(siteURL: siteURL, method: .post, path: Path.jetpackConnectionProvision)
@@ -82,6 +84,7 @@ public final class JetpackConnectionRemote: Remote {
8284
}
8385
}
8486

87+
/// periphery: ignore - used in test module and on the UI layer
8588
public enum JetpackConnectionError: Error, Equatable {
8689
case malformedURL
8790
case accountConnectionURLNotFound

Modules/Sources/Networking/Remote/SiteRemote.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public protocol SiteRemoteProtocol {
4343
/// - siteID: Remote ID of the site
4444
/// - siteURL: URL of the site
4545
/// - provisionResponse: Response from the provision connection call
46+
/// periphery: ignore - used in test module
47+
///
4648
func finalizeJetpackConnection(siteID: Int64,
4749
siteURL: String,
4850
provisionResponse: JetpackConnectionProvisionResponse) async throws
@@ -172,6 +174,7 @@ public class SiteRemote: Remote, SiteRemoteProtocol {
172174
}
173175

174176
/// Finalizes the Jetpack connection by sending a request to WPCom.
177+
/// periphery: ignore - used in `JetpackConnectionStore` later
175178
///
176179
public func finalizeJetpackConnection(siteID: Int64,
177180
siteURL: String,

Modules/Sources/Yosemite/Tools/ResultsController.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class GenericResultsController<T: ResultsControllerMutableType, Output> {
5151

5252
/// Internal NSFetchedResultsController Instance.
5353
///
54-
private lazy var controller: NSFetchedResultsController<T> = {
54+
public private(set) lazy var controller: NSFetchedResultsController<T> = {
5555
viewStorage.createFetchedResultsController(
5656
fetchRequest: fetchRequest,
5757
sectionNameKeyPath: sectionNameKeyPath,
@@ -65,10 +65,6 @@ public class GenericResultsController<T: ResultsControllerMutableType, Output> {
6565
// swiftlint:disable:next weak_delegate
6666
private let internalDelegate = FetchedResultsControllerDelegateWrapper()
6767

68-
/// NotificationCenter ObserverBlock Token
69-
///
70-
private var notificationCenterToken: Any?
71-
7268
/// Closure to be executed before the results are changed.
7369
///
7470
public var onWillChangeContent: (() -> Void)?

Modules/Tests/NetworkingTests/Mapper/ProductMapperTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ final class ProductMapperTests: XCTestCase {
2929
XCTAssertEqual(product.name, "Book the Green Room")
3030
XCTAssertEqual(product.slug, "book-the-green-room")
3131
XCTAssertEqual(product.permalink, "https://example.com/product/book-the-green-room/")
32-
XCTAssertEqual(product.alternativePermalink(with: "https://example.com"),
33-
"https://example.com?post_type=product&p=\(dummyProductID)")
3432

3533
let dateCreated = DateFormatter.Defaults.dateTimeFormatter.date(from: "2019-02-19T17:33:31")
3634
let dateModified = DateFormatter.Defaults.dateTimeFormatter.date(from: "2019-02-19T17:48:01")

Modules/Tests/YosemiteTests/Tools/ResultsControllerTests.swift

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ final class ResultsControllerTests: XCTestCase {
5656
///
5757
func testResultsControllerPicksUpEntitiesAvailablePriorToInstantiation() {
5858
storageManager.insertSampleAccount()
59-
viewStorage.saveIfNeeded()
6059

6160
let resultsController = ResultsController<StorageAccount>(viewStorage: viewStorage, sortedBy: [sampleSortDescriptor])
6261
try? resultsController.performFetch()
@@ -70,12 +69,11 @@ final class ResultsControllerTests: XCTestCase {
7069
/// Verifies that ResultsController does pick up entities inserted after being instantiated.
7170
///
7271
func testResultsControllerPicksUpEntitiesInsertedAfterInstantiation() {
72+
storageManager.insertSampleAccount()
73+
7374
let resultsController = ResultsController<StorageAccount>(viewStorage: viewStorage, sortedBy: [sampleSortDescriptor])
7475
try? resultsController.performFetch()
7576

76-
storageManager.insertSampleAccount()
77-
viewStorage.saveIfNeeded()
78-
7977
XCTAssertEqual(resultsController.sections.count, 1)
8078
XCTAssertEqual(resultsController.sections.first?.objects.count, 1)
8179
XCTAssertEqual(resultsController.sections.first?.numberOfObjects, 1)
@@ -85,18 +83,16 @@ final class ResultsControllerTests: XCTestCase {
8583
/// Verifies that `sectionNameKeyPath` effectively causes the ResultsController to produce multiple sections, based on the grouping parameter.
8684
///
8785
func testResultsControllerGroupSectionsBySectionNameKeypath() {
88-
let sectionNameKeyPath = "userID"
89-
let resultsController = ResultsController<StorageAccount>(viewStorage: viewStorage,
90-
sectionNameKeyPath: sectionNameKeyPath,
91-
sortedBy: [sampleSortDescriptor])
92-
try? resultsController.performFetch()
93-
9486
let numberOfAccounts = 100
9587
for _ in 0 ..< numberOfAccounts {
9688
storageManager.insertSampleAccount()
9789
}
9890

99-
viewStorage.saveIfNeeded()
91+
let sectionNameKeyPath = "userID"
92+
let resultsController = ResultsController<StorageAccount>(viewStorage: viewStorage,
93+
sectionNameKeyPath: sectionNameKeyPath,
94+
sortedBy: [sampleSortDescriptor])
95+
try? resultsController.performFetch()
10096

10197
XCTAssertEqual(resultsController.sections.count, numberOfAccounts)
10298

@@ -109,15 +105,13 @@ final class ResultsControllerTests: XCTestCase {
109105
/// Verifies that `object(at indexPath:)` effectively returns the expected (ReadOnly) Entity.
110106
///
111107
func testObjectAtIndexPathReturnsExpectedEntity() {
108+
let mutableAccount = storageManager.insertSampleAccount()
112109
let sectionNameKeyPath = "userID"
113110
let resultsController = ResultsController<StorageAccount>(viewStorage: viewStorage,
114111
sectionNameKeyPath: sectionNameKeyPath,
115112
sortedBy: [sampleSortDescriptor])
116113
try? resultsController.performFetch()
117114

118-
let mutableAccount = storageManager.insertSampleAccount()
119-
viewStorage.saveIfNeeded()
120-
121115
let indexPath = IndexPath(row: 0, section: 0)
122116
let readOnlyAccount = resultsController.object(at: indexPath)
123117

@@ -144,7 +138,6 @@ final class ResultsControllerTests: XCTestCase {
144138
}
145139

146140
storageManager.insertSampleAccount()
147-
viewStorage.saveIfNeeded()
148141

149142
waitForExpectations(timeout: Constants.expectationTimeout, handler: nil)
150143
}
@@ -167,7 +160,6 @@ final class ResultsControllerTests: XCTestCase {
167160
}
168161

169162
storageManager.insertSampleAccount()
170-
viewStorage.saveIfNeeded()
171163

172164
waitForExpectations(timeout: Constants.expectationTimeout, handler: nil)
173165
}
@@ -189,7 +181,6 @@ final class ResultsControllerTests: XCTestCase {
189181
}
190182

191183
storageManager.insertSampleAccount()
192-
viewStorage.saveIfNeeded()
193184

194185
waitForExpectations(timeout: Constants.expectationTimeout, handler: nil)
195186
}
@@ -211,7 +202,6 @@ final class ResultsControllerTests: XCTestCase {
211202
}
212203

213204
storageManager.insertSampleAccount()
214-
viewStorage.saveIfNeeded()
215205

216206
waitForExpectations(timeout: Constants.expectationTimeout, handler: nil)
217207
}
@@ -228,7 +218,6 @@ final class ResultsControllerTests: XCTestCase {
228218
let second = storageManager.insertSampleAccount().toReadOnly()
229219
let expected = [first.userID: first, second.userID: second]
230220

231-
viewStorage.saveIfNeeded()
232221

233222
for retrieved in resultsController.fetchedObjects {
234223
XCTAssertEqual(retrieved.username, expected[retrieved.userID]?.username)
@@ -239,14 +228,13 @@ final class ResultsControllerTests: XCTestCase {
239228
/// Verifies that `fetchedObjects` effectively returns all of the (readOnly) objects that are expected to be available.
240229
///
241230
func testResettingStorageIsMappedIntoOnResetClosure() {
231+
storageManager.insertSampleAccount()
232+
storageManager.insertSampleAccount()
233+
242234
let sortDescriptor = NSSortDescriptor(key: #selector(getter: StorageAccount.userID).description, ascending: true)
243235
let resultsController = ResultsController<StorageAccount>(viewStorage: viewStorage, sortedBy: [sortDescriptor])
244236
try? resultsController.performFetch()
245237

246-
storageManager.insertSampleAccount()
247-
storageManager.insertSampleAccount()
248-
249-
viewStorage.saveIfNeeded()
250238
XCTAssertEqual(resultsController.fetchedObjects.count, 2)
251239

252240
let expectation = self.expectation(description: "OnDidReset")
@@ -296,8 +284,6 @@ final class ResultsControllerTests: XCTestCase {
296284
}
297285
}
298286

299-
viewStorage.saveIfNeeded()
300-
301287
for (sectionNumber, sectionObject) in resultsController.sections.enumerated() {
302288
for (row, object) in sectionObject.objects.enumerated() {
303289
let indexPath = IndexPath(row: row, section: sectionNumber)

0 commit comments

Comments
 (0)