Skip to content

Commit 5637585

Browse files
committed
Fix unit tests compilation issues
1 parent 9834878 commit 5637585

3 files changed

Lines changed: 73 additions & 26 deletions

File tree

Modules/Tests/WordPressCoreTests/MockWordPressClientAPI.swift

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ final class MockWordPressClientAPI: WordPressClientAPI, @unchecked Sendable {
8282
fatalError("Not implemented")
8383
}
8484

85-
func uploadMedia(params: MediaCreateParams, fulfilling progress: Progress) async throws -> MediaRequestCreateResponse {
85+
func uploadMedia(
86+
params: MediaCreateParams,
87+
fulfilling progress: Progress
88+
) async throws -> MediaRequestCreateResponse {
8689
fatalError("Not implemented")
8790
}
8891
}
@@ -118,7 +121,9 @@ final class MockUsersRequestExecutor: UsersRequestExecutor {
118121
super.init(unsafeFromHandle: handle)
119122
}
120123

121-
override func retrieveMeWithEditContextCancellation(context: RequestContext?) async throws -> UsersRequestRetrieveMeWithEditContextResponse {
124+
override func retrieveMeWithEditContextCancellation(
125+
context: RequestContext?
126+
) async throws -> UsersRequestRetrieveMeWithEditContextResponse {
122127
let mockUser = UserWithEditContext(
123128
id: UserId(1),
124129
username: "testuser",
@@ -134,7 +139,7 @@ final class MockUsersRequestExecutor: UsersRequestExecutor {
134139
slug: "testuser",
135140
registeredDate: "2024-01-01T00:00:00",
136141
roles: [],
137-
capabilities: [:],
142+
capabilities: UserCapabilitiesMap(map: [:]),
138143
extraCapabilities: [:],
139144
avatarUrls: nil
140145
)
@@ -156,7 +161,10 @@ final class MockThemesRequestExecutor: ThemesRequestExecutor {
156161
super.init(unsafeFromHandle: handle)
157162
}
158163

159-
override func listWithEditContextCancellation(params: ThemeListParams, context: RequestContext?) async throws -> ThemesRequestListWithEditContextResponse {
164+
override func listWithEditContextCancellation(
165+
params: ThemeListParams,
166+
context: RequestContext?
167+
) async throws -> ThemesRequestListWithEditContextResponse {
160168
let mockTheme = ThemeWithEditContext(
161169
stylesheet: ThemeStylesheet(value: "twentytwentyfour"),
162170
template: "twentytwentyfour",
@@ -196,7 +204,9 @@ final class MockSiteSettingsRequestExecutor: SiteSettingsRequestExecutor {
196204
super.init(unsafeFromHandle: handle)
197205
}
198206

199-
override func retrieveWithEditContextCancellation(context: RequestContext?) async throws -> SiteSettingsRequestRetrieveWithEditContextResponse {
207+
override func retrieveWithEditContextCancellation(
208+
context: RequestContext?
209+
) async throws -> SiteSettingsRequestRetrieveWithEditContextResponse {
200210
let mockSettings = SiteSettingsWithEditContext(
201211
title: "Test Site",
202212
description: "A test site",
@@ -217,7 +227,8 @@ final class MockSiteSettingsRequestExecutor: SiteSettingsRequestExecutor {
217227
defaultPingStatus: .open,
218228
defaultCommentStatus: .open,
219229
siteLogo: nil,
220-
siteIcon: 0
230+
siteIcon: 0,
231+
additionalFields: AnyJson(noHandle: AnyJson.NoHandle())
221232
)
222233
let mockHeaderMap = WpNetworkHeaderMap(noHandle: WpNetworkHeaderMap.NoHandle())
223234
return SiteSettingsRequestRetrieveWithEditContextResponse(data: mockSettings, headerMap: mockHeaderMap)

Tests/KeystoneTests/Tests/Features/Posts/CustomPostEditorServiceTests.swift

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private func makeService(
196196
api: api,
197197
siteURL: URL(string: "https://example.com")!
198198
)
199-
let wpService = try api.createSelfHostedService(cache: .bootstrap())
199+
let wpService = try api.createService(cache: .bootstrap())
200200

201201
return CustomPostEditorService(
202202
blog: blog,
@@ -219,7 +219,7 @@ private func makePostTypeDetails() -> PostTypeDetailsWithEditContext {
219219
slug: "test_post_type",
220220
supports: PostTypeSupportsMap(map: [
221221
.title: .bool(true),
222-
.editor: .bool(true),
222+
.editor: .bool(true)
223223
]),
224224
hasArchive: .bool(false),
225225
taxonomies: [],
@@ -232,17 +232,40 @@ private func makePostTypeDetails() -> PostTypeDetailsWithEditContext {
232232

233233
private func makePostTypeLabels() -> PostTypeLabels {
234234
PostTypeLabels(
235-
name: "", singularName: "", addNew: "", addNewItem: "",
236-
editItem: "", newItem: "", viewItem: "", viewItems: "",
237-
searchItems: "", notFound: "", notFoundInTrash: "",
238-
parentItemColon: nil, allItems: "", archives: "",
239-
attributes: "", insertIntoItem: "", uploadedToThisItem: "",
240-
featuredImage: "", setFeaturedImage: "", removeFeaturedImage: "",
241-
useFeaturedImage: "", filterItemsList: "", filterByDate: "",
242-
itemsListNavigation: "", itemsList: "", itemPublished: "",
243-
itemPublishedPrivately: "", itemRevertedToDraft: "",
244-
itemTrashed: "", itemScheduled: "", itemUpdated: "",
245-
itemLink: "", itemLinkDescription: "", menuName: "",
235+
name: "",
236+
singularName: "",
237+
addNew: "",
238+
addNewItem: "",
239+
editItem: "",
240+
newItem: "",
241+
viewItem: "",
242+
viewItems: "",
243+
searchItems: "",
244+
notFound: "",
245+
notFoundInTrash: "",
246+
parentItemColon: nil,
247+
allItems: "",
248+
archives: "",
249+
attributes: "",
250+
insertIntoItem: "",
251+
uploadedToThisItem: "",
252+
featuredImage: "",
253+
setFeaturedImage: "",
254+
removeFeaturedImage: "",
255+
useFeaturedImage: "",
256+
filterItemsList: "",
257+
filterByDate: "",
258+
itemsListNavigation: "",
259+
itemsList: "",
260+
itemPublished: "",
261+
itemPublishedPrivately: "",
262+
itemRevertedToDraft: "",
263+
itemTrashed: "",
264+
itemScheduled: "",
265+
itemUpdated: "",
266+
itemLink: "",
267+
itemLinkDescription: "",
268+
menuName: "",
246269
nameAdminBar: ""
247270
)
248271
}

Tests/KeystoneTests/Tests/Services/BlogServiceRemoteCoreRESTSettingsTests.swift

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Testing
22
import WordPressAPI
3+
import WordPressAPIInternal
34
@testable import WordPress
45
@testable import WordPressKit
56

@@ -19,15 +20,27 @@ struct BlogServiceRemoteCoreRESTSettingsTests {
1920
postsPerPage: UInt64 = 10
2021
) -> SiteSettingsWithEditContext {
2122
SiteSettingsWithEditContext(
22-
title: title, description: description, url: "", email: "",
23-
timezone: timezone, dateFormat: dateFormat, timeFormat: timeFormat,
24-
startOfWeek: startOfWeek, language: "", useSmilies: false,
25-
defaultCategory: defaultCategory, defaultPostFormat: defaultPostFormat,
26-
postsPerPage: postsPerPage, showOnFront: "posts",
27-
pageOnFront: 0, pageForPosts: 0,
23+
title: title,
24+
description: description,
25+
url: "",
26+
email: "",
27+
timezone: timezone,
28+
dateFormat: dateFormat,
29+
timeFormat: timeFormat,
30+
startOfWeek: startOfWeek,
31+
language: "",
32+
useSmilies: false,
33+
defaultCategory: defaultCategory,
34+
defaultPostFormat: defaultPostFormat,
35+
postsPerPage: postsPerPage,
36+
showOnFront: "posts",
37+
pageOnFront: 0,
38+
pageForPosts: 0,
2839
defaultPingStatus: .closed,
2940
defaultCommentStatus: .closed,
30-
siteLogo: nil, siteIcon: 0
41+
siteLogo: nil,
42+
siteIcon: 0,
43+
additionalFields: AnyJson(noHandle: AnyJson.NoHandle())
3144
)
3245
}
3346

0 commit comments

Comments
 (0)