Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shopify_iossdk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
shopify_iossdk
Commits
d390ebc6
Commit
d390ebc6
authored
8 years ago
by
Dima Bart
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #183 from Shopify/bugfix/payment-providers-tests
Fix payment provider tests
parents
e64df449
ddfbb567
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
16 deletions
+129
-16
BUYFakeSafariController.h
...le Buy SDK/Mobile Buy SDK Tests/BUYFakeSafariController.h
+33
-0
BUYFakeSafariController.m
...le Buy SDK/Mobile Buy SDK Tests/BUYFakeSafariController.m
+39
-0
BUYPaymentProviderTests.m
...le Buy SDK/Mobile Buy SDK Tests/BUYPaymentProviderTests.m
+13
-1
project.pbxproj
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
+6
-0
BUYWebCheckoutPaymentProvider.m
...Buy SDK/Payment Providers/BUYWebCheckoutPaymentProvider.m
+38
-15
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYFakeSafariController.h
0 → 100644
View file @
d390ebc6
//
// BUYFakeSafariController.h
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <Foundation/Foundation.h>
@interface
BUYFakeSafariController
:
NSObject
@property
(
weak
,
nonatomic
)
id
delegate
;
@end
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYFakeSafariController.m
0 → 100644
View file @
d390ebc6
//
// BUYFakeSafariController.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "BUYFakeSafariController.h"
@implementation
BUYFakeSafariController
-
(
instancetype
)
initWithURL
:(
NSURL
*
)
URL
{
return
[
self
initWithURL
:
URL
entersReaderIfAvailable
:
YES
];
}
-
(
instancetype
)
initWithURL
:(
NSURL
*
)
URL
entersReaderIfAvailable
:(
BOOL
)
entersReaderIfAvailable
{
return
(
id
)[[[
self
class
]
alloc
]
init
];
}
@end
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYPaymentProviderTests.m
View file @
d390ebc6
...
...
@@ -14,9 +14,12 @@
#import "BUYWebCheckoutPaymentProvider.h"
#import "BUYClientTestBase.h"
#import "BUYPaymentController.h"
#import "BUYFakeSafariController.h"
#import <OHHTTPStubs/OHHTTPStubs.h>
@interface
BUYPaymentController
()
extern
Class
SafariViewControllerClass
;
@interface
BUYPaymentController
(
Private
)
-
(
id
<
BUYPaymentProvider
>
)
providerForType
:(
NSString
*
)
type
;
@end
...
...
@@ -34,6 +37,15 @@
[
super
setUp
];
self
.
modelManager
=
[
BUYModelManager
modelManager
];
self
.
expectations
=
[@{}
mutableCopy
];
/* ---------------------------------
* We need to kick off the provider
* class initialization before setting
* the fake safari controller to
* prevent it getting overriden.
*/
[
BUYWebCheckoutPaymentProvider
class
];
SafariViewControllerClass
=
[
BUYFakeSafariController
class
];
}
-
(
void
)
tearDown
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
View file @
d390ebc6
...
...
@@ -374,6 +374,7 @@
9A47CF221CE5112A00A6D5BA
/* BUYAssert.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A47CF211CE5112A00A6D5BA
/* BUYAssert.h */
;
};
9A47CF231CE5112A00A6D5BA
/* BUYAssert.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A47CF211CE5112A00A6D5BA
/* BUYAssert.h */
;
};
9A6B03791CDA5D4F0054C26E
/* BUYAccountCredentialsTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A6B03781CDA5D4F0054C26E
/* BUYAccountCredentialsTests.m */
;
};
9ABBCCA11CF5C9D10075B0C5
/* BUYFakeSafariController.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9ABBCCA01CF5C9D10075B0C5
/* BUYFakeSafariController.m */
;
};
B2653EC31CEF55CC0012D57D
/* BUYModelManager+ApplePay.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
B2653EC11CEF55CC0012D57D
/* BUYModelManager+ApplePay.h */
;
};
B2653EC41CEF55CC0012D57D
/* BUYModelManager+ApplePay.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
B2653EC11CEF55CC0012D57D
/* BUYModelManager+ApplePay.h */
;
};
B2653EC51CEF55CC0012D57D
/* BUYModelManager+ApplePay.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
B2653EC21CEF55CC0012D57D
/* BUYModelManager+ApplePay.m */
;
};
...
...
@@ -655,6 +656,8 @@
9A47CF1F1CE50EBB00A6D5BA
/* BUYApplePayTestToken.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYApplePayTestToken.m
;
sourceTree
=
"<group>"
;
};
9A47CF211CE5112A00A6D5BA
/* BUYAssert.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
name
=
BUYAssert.h
;
path
=
../Additions/BUYAssert.h
;
sourceTree
=
"<group>"
;
};
9A6B03781CDA5D4F0054C26E
/* BUYAccountCredentialsTests.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYAccountCredentialsTests.m
;
sourceTree
=
"<group>"
;
};
9ABBCC9F1CF5C9D10075B0C5
/* BUYFakeSafariController.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYFakeSafariController.h
;
sourceTree
=
"<group>"
;
};
9ABBCCA01CF5C9D10075B0C5
/* BUYFakeSafariController.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYFakeSafariController.m
;
sourceTree
=
"<group>"
;
};
B2653EC11CEF55CC0012D57D
/* BUYModelManager+ApplePay.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"BUYModelManager+ApplePay.h"
;
sourceTree
=
"<group>"
;
};
B2653EC21CEF55CC0012D57D
/* BUYModelManager+ApplePay.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"BUYModelManager+ApplePay.m"
;
sourceTree
=
"<group>"
;
};
BE33B4ED1B15FF4D0067982B
/* BUYApplePayAuthorizationDelegate.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYApplePayAuthorizationDelegate.h
;
sourceTree
=
"<group>"
;
};
...
...
@@ -1019,6 +1022,8 @@
children
=
(
9A47CF1E1CE50EBB00A6D5BA
/* BUYApplePayTestToken.h */
,
9A47CF1F1CE50EBB00A6D5BA
/* BUYApplePayTestToken.m */
,
9ABBCC9F1CF5C9D10075B0C5
/* BUYFakeSafariController.h */
,
9ABBCCA01CF5C9D10075B0C5
/* BUYFakeSafariController.m */
,
);
name
=
"Test Objects"
;
sourceTree
=
"<group>"
;
...
...
@@ -1643,6 +1648,7 @@
8498DCCC1CDD208200BD12A8
/* BUYCustomerTests.m in Sources */
,
B2653EC51CEF55CC0012D57D
/* BUYModelManager+ApplePay.m in Sources */
,
8498DCCE1CDD208200BD12A8
/* BUYOrderTests.m in Sources */
,
9ABBCCA11CF5C9D10075B0C5
/* BUYFakeSafariController.m in Sources */
,
9A0B0C831CEB981C0037D68F
/* BUYClient+RoutingTests.m in Sources */
,
849110351CCE70CE00E53B93
/* BUYDictionaryAdditionsTests.m in Sources */
,
90F5930A1B0D5F4C0026B382
/* BUYLineItemTest.m in Sources */
,
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Payment Providers/BUYWebCheckoutPaymentProvider.m
View file @
d390ebc6
...
...
@@ -27,9 +27,12 @@
#import "BUYWebCheckoutPaymentProvider.h"
#import "BUYCheckout.h"
#import "BUYClient+CheckoutHelpers.h"
#import "BUYAssert.h"
@import
SafariServices
;
Class
SafariViewControllerClass
;
NSString
*
BUYSafariCallbackURLNotification
=
@"kBUYSafariCallbackURLNotification"
;
NSString
*
BUYURLKey
=
@"url"
;
NSString
*
const
BUYWebPaymentProviderId
=
@"BUYWebPaymentProviderId"
;
...
...
@@ -37,32 +40,60 @@ NSString * const BUYWebPaymentProviderId = @"BUYWebPaymentProviderId";
static
NSString
*
const
WebCheckoutCustomerAccessToken
=
@"customer_access_token"
;
@interface
BUYWebCheckoutPaymentProvider
()
<
SFSafariViewControllerDelegate
>
@property
(
nonatomic
,
strong
)
BUYCheckout
*
checkout
;
@property
(
nonatomic
,
strong
)
BUYClient
*
client
;
@end
@implementation
BUYWebCheckoutPaymentProvider
@synthesize
delegate
;
#pragma mark - Initialize -
+
(
void
)
initialize
{
/* ----------------------------------
* Used in tests to set a fake / mock
* SFSafariViewController to avoid
* instantiating a real one.
*/
SafariViewControllerClass
=
[
SFSafariViewController
class
];
}
#pragma mark - Init -
-
(
instancetype
)
initWithClient
:
(
BUYClient
*
)
client
{
NSParameterAssert
(
client
);
BUYAssert
(
client
,
@"Failed to initialize BUYWebCheckoutPaymentProvider, client must not be nil."
);
self
=
[
super
init
];
if
(
self
)
{
_client
=
client
;
}
return
self
;
}
#pragma mark - Accessors -
-
(
BOOL
)
isAvailable
{
return
YES
;
}
-
(
BOOL
)
isInProgress
{
return
(
self
.
checkout
!=
nil
);
}
-
(
NSString
*
)
identifier
{
return
BUYWebPaymentProviderId
;
}
#pragma mark - Equality -
-
(
NSUInteger
)
hash
{
return
self
.
identifier
.
hash
;
...
...
@@ -73,10 +104,7 @@ static NSString *const WebCheckoutCustomerAccessToken = @"customer_access_token"
return
([
object
isKindOfClass
:[
self
class
]]
&&
[
self
.
identifier
isEqual
:[
object
identifier
]]);
}
-
(
NSString
*
)
identifier
{
return
BUYWebPaymentProviderId
;
}
#pragma mark - Checkout -
-
(
void
)
startCheckout
:
(
BUYCheckout
*
)
checkout
{
...
...
@@ -108,11 +136,6 @@ static NSString *const WebCheckoutCustomerAccessToken = @"customer_access_token"
self
.
checkout
=
nil
;
}
-
(
BOOL
)
isAvailable
{
return
YES
;
}
-
(
void
)
postCheckoutCompletion
:
(
BUYCheckout
*
)
checkout
error
:
(
NSError
*
)
error
{
if
(
self
.
checkout
&&
error
==
nil
)
{
...
...
@@ -140,9 +163,9 @@ static NSString *const WebCheckoutCustomerAccessToken = @"customer_access_token"
-
(
void
)
openWebCheckout
:
(
BUYCheckout
*
)
checkout
{
NSURL
*
checkoutURL
=
[
self
authenticatedWebCheckoutURL
:
checkout
.
webCheckoutURL
];
if
(
[
SFSafariViewController
class
]
)
{
if
(
SafariViewControllerClass
)
{
SFSafariViewController
*
safariViewController
=
[[
S
FSafariViewController
alloc
]
initWithURL
:
checkoutURL
];
SFSafariViewController
*
safariViewController
=
[[
S
afariViewControllerClass
alloc
]
initWithURL
:
checkoutURL
];
safariViewController
.
delegate
=
self
;
[
self
.
delegate
paymentProvider
:
self
wantsControllerPresented
:
safariViewController
];
}
...
...
@@ -163,7 +186,7 @@ static NSString *const WebCheckoutCustomerAccessToken = @"customer_access_token"
return
authenticatedComponents
.
URL
;
}
#pragma mark - Web Checkout
delegate methods
#pragma mark - Web Checkout
Delegate Methods -
-
(
void
)
safariViewControllerDidFinish
:
(
SFSafariViewController
*
)
controller
;
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment