Skip to content

Commit

Permalink
Add more deprecations to make the CI happy
Browse files Browse the repository at this point in the history
  • Loading branch information
pinarol committed Mar 28, 2024
1 parent a196a9c commit 6eef821
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Sources/WordPressUI/Extensions/UIImageView+Gravatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ extension UIImageView {
/// - email: the user's email
/// - rating: expected image rating
///
/// This method uses deprecated types. Check out the UIImageView extension from the Gravatar iOS SDK as an alternative to download images. See: https://github.com/Automattic/Gravatar-SDK-iOS.
/// This method uses deprecated types. Please check the deprecation warning in `GravatarRatings`. Also check out the UIImageView extension from the Gravatar iOS SDK as an alternative to download images. See: https://github.com/Automattic/Gravatar-SDK-iOS.
@available(*, deprecated, message: "Usage of the deprecated type: GravatarRatings.")
@objc
public func downloadGravatarWithEmail(_ email: String, rating: GravatarRatings) {
downloadGravatarWithEmail(email, rating: rating, placeholderImage: .gravatarPlaceholderImage)
Expand All @@ -41,8 +42,8 @@ extension UIImageView {
/// - email: the user's email
/// - rating: expected image rating
/// - placeholderImage: Image to be used as Placeholder
///
/// This method uses deprecated types. Check out the UIImageView extension from the Gravatar iOS SDK as an alternative to download images. See: https://github.com/Automattic/Gravatar-SDK-iOS.
/// This method uses deprecated types. Please check the deprecation warning in `GravatarRatings`. Also check out the UIImageView extension from the Gravatar iOS SDK as an alternative to download images. See: https://github.com/Automattic/Gravatar-SDK-iOS.
@available(*, deprecated, message: "Usage of the deprecated type: GravatarRatings.")
@objc
public func downloadGravatarWithEmail(_ email: String, rating: GravatarRatings = .default, placeholderImage: UIImage = .gravatarPlaceholderImage) {
let gravatarURL = Gravatar.gravatarUrl(for: email, size: gravatarDefaultSize(), rating: rating)
Expand Down Expand Up @@ -90,7 +91,8 @@ extension UIImageView {
/// - animate: enable/disable fade in animation
/// - failure: Callback block to be invoked when an error occurs while fetching the Gravatar image
///
/// This method uses deprecated types. Check out the UIImageView extension from the Gravatar iOS SDK as an alternative to download images. See: https://github.com/Automattic/Gravatar-SDK-iOS.
/// This method uses deprecated types. Please check the deprecation warning in `GravatarRatings`. Also check out the UIImageView extension from the Gravatar iOS SDK as an alternative to download images. See: https://github.com/Automattic/Gravatar-SDK-iOS.
@available(*, deprecated, message: "Usage of the deprecated type: Gravatar.")
public func downloadGravatar(_ gravatar: Gravatar?, placeholder: UIImage, animate: Bool, failure: ((Error?) -> Void)? = nil) {
guard let gravatar = gravatar else {
self.image = placeholder
Expand Down Expand Up @@ -141,6 +143,7 @@ extension UIImageView {
/// P.s.:
/// Hope buddah, and the code reviewer, can forgive me for this hack.
///
@available(*, deprecated, message: "Usage of the deprecated type: GravatarRatings.")
@objc public func overrideGravatarImageCache(_ image: UIImage, rating: GravatarRatings, email: String) {
guard let gravatarURL = Gravatar.gravatarUrl(for: email, size: gravatarDefaultSize(), rating: rating) else {
return
Expand Down
8 changes: 8 additions & 0 deletions Tests/WordPressUITests/Extensions/GravatarTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,42 @@ import XCTest
@testable import WordPressUI

class GravatarTest: XCTestCase {
@available(*, deprecated, message: "Deprecated because of Gravatar usage")
func testUnknownGravatarUrlMatchesURLWithSubdomainAndQueryParameters() {
let url = URL(string: "https://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=256&r=G")!
let gravatar = Gravatar(url)
XCTAssertNil(gravatar)
}

@available(*, deprecated, message: "Deprecated because of Gravatar usage")
func testUnknownGravatarUrlMatchesURLWithoutSubdomains() {
let url = URL(string: "https://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536")!
let gravatar = Gravatar(url)
XCTAssertNil(gravatar)
}

@available(*, deprecated, message: "Deprecated because of Gravatar usage")
func testIsUnknownGravatarUrlMatchesURLWithHttpSchema() {
let url = URL(string: "http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536")!
let gravatar = Gravatar(url)
XCTAssertNil(gravatar)
}

@available(*, deprecated, message: "Deprecated because of Gravatar usage")
func testGravatarRejectsIncorrectPath() {
let url = URL(string: "http://0.gravatar.com/5b415e3c9c245e557af9f580eeb8760a")!
let gravatar = Gravatar(url)
XCTAssertNil(gravatar)
}

@available(*, deprecated, message: "Deprecated because of Gravatar usage")
func testGravatarRejectsIncorrectHost() {
let url = URL(string: "http://0.argvatar.com/avatar/5b415e3c9c245e557af9f580eeb8760a")!
let gravatar = Gravatar(url)
XCTAssertNil(gravatar)
}

@available(*, deprecated, message: "Deprecated because of Gravatar usage")
func testGravatarRemovesQueryParameters() {
let url = URL(string: "https://secure.gravatar.com/avatar/5b415e3c9c245e557af9f580eeb8760a?d=http://0.gravatar.com/5b415e3c9c245e557af9f580eeb8760a")!
let expected = URL(string: "https://secure.gravatar.com/avatar/5b415e3c9c245e557af9f580eeb8760a")!
Expand All @@ -40,6 +46,7 @@ class GravatarTest: XCTestCase {
XCTAssertEqual(gravatar!.canonicalURL, expected)
}

@available(*, deprecated, message: "Deprecated because of Gravatar usage")
func testGravatarForcesHTTPS() {
let url = URL(string: "http://0.gravatar.com/avatar/5b415e3c9c245e557af9f580eeb8760a")!
let expected = URL(string: "https://secure.gravatar.com/avatar/5b415e3c9c245e557af9f580eeb8760a")!
Expand All @@ -48,6 +55,7 @@ class GravatarTest: XCTestCase {
XCTAssertEqual(gravatar!.canonicalURL, expected)
}

@available(*, deprecated, message: "Deprecated because of Gravatar usage")
func testGravatarAppendsSizeQuery() {
let url = URL(string: "http://0.gravatar.com/avatar/5b415e3c9c245e557af9f580eeb8760a")!
let expected = URL(string: "https://secure.gravatar.com/avatar/5b415e3c9c245e557af9f580eeb8760a?s=128&d=404")!
Expand Down

0 comments on commit 6eef821

Please sign in to comment.