Skip to content

Commit 2009f8a

Browse files
committed
Change argument label from context to insertInto for better API name
1 parent ed604d9 commit 2009f8a

6 files changed

Lines changed: 17 additions & 19 deletions

WordPress/WordPressTest/FormattableUserContentTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ final class FormattableUserContentTests: XCTestCase {
138138
}
139139

140140
private func loadLikeNotification() -> WordPress.Notification {
141-
return .fixture(fromFile: "notifications-like.json", context: contextManager.mainContext)
141+
return .fixture(fromFile: "notifications-like.json", insertInto: contextManager.mainContext)
142142
}
143143

144144
private func loadMeta() -> [String: AnyObject] {

WordPress/WordPressTest/NSManagedObject+Fixture.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ extension NSManagedObject {
44

55
/// Loads the contents of any given JSON file into a new `NSManagedObject` instance.
66
///
7-
/// This helper method is useful for Unit Testing scenarios.
8-
///
97
/// - Parameters:
108
/// - filename: The name of the JSON file to be loaded
119
/// - context: The managed object context to use
1210
/// - Returns: A new instance with property values of the given JSON file.
13-
static func fixture(fromFile fileName: String, context: NSManagedObjectContext) -> Self {
11+
static func fixture(fromFile fileName: String, insertInto context: NSManagedObjectContext) -> Self {
1412
guard let jsonObject = JSONLoader().loadFile(named: fileName) else {
1513
fatalError("Mockup data could not be parsed, the filename is \(fileName)")
1614
}

WordPress/WordPressTest/NotificationSyncMediatorTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class NotificationSyncMediatorTests: XCTestCase {
155155

156156
// Inject Dummy Note
157157
let path = "notifications-like.json"
158-
let note = WordPress.Notification.fixture(fromFile: path, context: manager.mainContext)
158+
let note = WordPress.Notification.fixture(fromFile: path, insertInto: manager.mainContext)
159159

160160
XCTAssertNotNil(note)
161161
XCTAssertFalse(note.read)
@@ -187,9 +187,9 @@ class NotificationSyncMediatorTests: XCTestCase {
187187
let path1 = "notifications-like.json"
188188
let path2 = "notifications-new-follower.json"
189189
let path3 = "notifications-unapproved-comment.json"
190-
let note1 = WordPress.Notification.fixture(fromFile: path1, context: manager.mainContext)
191-
let note2 = WordPress.Notification.fixture(fromFile: path2, context: manager.mainContext)
192-
let note3 = WordPress.Notification.fixture(fromFile: path3, context: manager.mainContext)
190+
let note1 = WordPress.Notification.fixture(fromFile: path1, insertInto: manager.mainContext)
191+
let note2 = WordPress.Notification.fixture(fromFile: path2, insertInto: manager.mainContext)
192+
let note3 = WordPress.Notification.fixture(fromFile: path3, insertInto: manager.mainContext)
193193

194194
XCTAssertFalse(note1.read)
195195
XCTAssertFalse(note3.read)
@@ -225,9 +225,9 @@ class NotificationSyncMediatorTests: XCTestCase {
225225
let path1 = "notifications-like.json"
226226
let path2 = "notifications-new-follower.json"
227227
let path3 = "notifications-unapproved-comment.json"
228-
let note1 = WordPress.Notification.fixture(fromFile: path1, context: manager.mainContext)
229-
let note2 = WordPress.Notification.fixture(fromFile: path2, context: manager.mainContext)
230-
let note3 = WordPress.Notification.fixture(fromFile: path3, context: manager.mainContext)
228+
let note1 = WordPress.Notification.fixture(fromFile: path1, insertInto: manager.mainContext)
229+
let note2 = WordPress.Notification.fixture(fromFile: path2, insertInto: manager.mainContext)
230+
let note3 = WordPress.Notification.fixture(fromFile: path3, insertInto: manager.mainContext)
231231

232232
XCTAssertFalse(note1.read)
233233
XCTAssertFalse(note3.read)

WordPress/WordPressTest/NotificationTextContentTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ final class NotificationTextContentTests: XCTestCase {
100100
}
101101

102102
private func loadLikeNotification() -> WordPress.Notification {
103-
return .fixture(fromFile: "notifications-like.json", context: contextManager.mainContext)
103+
return .fixture(fromFile: "notifications-like.json", insertInto: contextManager.mainContext)
104104
}
105105

106106
private func mockedActions() -> [FormattableContentAction] {

WordPress/WordPressTest/NotificationUtility.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@ class NotificationUtility {
2121
}
2222

2323
func loadBadgeNotification() -> WordPress.Notification {
24-
return .fixture(fromFile: "notifications-badge.json", context: contextManager.mainContext)
24+
return .fixture(fromFile: "notifications-badge.json", insertInto: contextManager.mainContext)
2525
}
2626

2727
func loadLikeNotification() -> WordPress.Notification {
28-
return .fixture(fromFile: "notifications-like.json", context: contextManager.mainContext)
28+
return .fixture(fromFile: "notifications-like.json", insertInto: contextManager.mainContext)
2929
}
3030

3131
func loadFollowerNotification() -> WordPress.Notification {
32-
return .fixture(fromFile: "notifications-new-follower.json", context: contextManager.mainContext)
32+
return .fixture(fromFile: "notifications-new-follower.json", insertInto: contextManager.mainContext)
3333
}
3434

3535
func loadCommentNotification() -> WordPress.Notification {
36-
return .fixture(fromFile: "notifications-replied-comment.json", context: contextManager.mainContext)
36+
return .fixture(fromFile: "notifications-replied-comment.json", insertInto: contextManager.mainContext)
3737
}
3838

3939
func loadUnapprovedCommentNotification() -> WordPress.Notification {
40-
return .fixture(fromFile: "notifications-unapproved-comment.json", context: contextManager.mainContext)
40+
return .fixture(fromFile: "notifications-unapproved-comment.json", insertInto: contextManager.mainContext)
4141
}
4242

4343
func loadPingbackNotification() -> WordPress.Notification {
44-
return .fixture(fromFile: "notifications-pingback.json", context: contextManager.mainContext)
44+
return .fixture(fromFile: "notifications-pingback.json", insertInto: contextManager.mainContext)
4545
}
4646

4747
func mockCommentContent() -> FormattableCommentContent {

WordPress/WordPressTest/NotificationsContentFactoryTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ final class NotificationsContentFactoryTests: XCTestCase {
4040
}
4141

4242
func loadLikeNotification() -> WordPress.Notification {
43-
return .fixture(fromFile: "notifications-like.json", context: contextManager.mainContext)
43+
return .fixture(fromFile: "notifications-like.json", insertInto: contextManager.mainContext)
4444
}
4545
}

0 commit comments

Comments
 (0)