FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bazaar-api-php/tests/SubscriptionTest.php at master · nikapps/bazaar-api-php · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
nikapps
/
bazaar-api-php
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
4
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
bazaar-api-php
/
tests
/
SubscriptionTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
82 lines (71 loc) · 3.01 KB
Breadcrumbs
bazaar-api-php
/
tests
/
SubscriptionTest.php
Copy path
File metadata and controls
82 lines (71 loc) · 3.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace
Nikapps
\
BazaarApi
\
Tests
;
use
Nikapps
\
BazaarApi
\
Bazaar
;
use
Nikapps
\
BazaarApi
\
Client
\
ClientInterface
;
use
Nikapps
\
BazaarApi
\
Models
\
Subscription
;
class
SubscriptionTest
extends
TestCase
{
/** @test */
public
function
it_should_fetch_subscription_state
()
{
$
bazaar
=
$
this
->
makeBazaar
();
$
this
->
setClient
(
'
get
'
,
$
this
->
makeSubscriptionUrl
(
'
com.example.app
'
,
'
sub-id
'
,
'
purchase-123456
'
),
[
'
query
'
=> [
'
access_token
'
=>
'
token-123456
'
]
],
[
"
kind
"
=>
"
androidpublisher#subscriptionPurchase
"
,
"
initiationTimestampMsec
"
=>
1000000000000
,
"
validUntilTimestampMsec
"
=>
1100000000000
,
"
autoRenewing
"
=>
true
,
]
);
$
this
->
setStorage
();
$
subscription
=
$
bazaar
->
subscription
(
'
com.example.app
'
,
'
sub-id
'
,
'
purchase-123456
'
);
$
this
->
assertEquals
(
1000000000000
,
$
subscription
->
startTime
());
$
this
->
assertEquals
(
1100000000000
,
$
subscription
->
endTime
());
$
this
->
assertTrue
(
$
subscription
->
autoRenewing
());
$
this
->
assertTrue
(
$
subscription
->
expired
());
}
/** @test */
public
function
subscription_should_parse_successfully_response
()
{
$
tomorrow
= (
time
() + (
24
*
3600
)) *
1000
;
// convert to ms
$
subscription
=
new
Subscription
([
"
kind
"
=>
"
androidpublisher#subscriptionPurchase
"
,
"
initiationTimestampMsec
"
=>
1000000000000
,
"
validUntilTimestampMsec
"
=>
$
tomorrow
,
"
autoRenewing
"
=>
true
,
]);
$
this
->
assertTrue
(
$
subscription
->
found
());
$
this
->
assertFalse
(
$
subscription
->
notFound
());
$
this
->
assertFalse
(
$
subscription
->
hasError
());
$
this
->
assertFalse
(
$
subscription
->
failed
());
$
this
->
assertFalse
(
$
subscription
->
expired
());
$
this
->
assertTrue
(
$
subscription
->
autoRenewing
());
$
this
->
assertEquals
(
1000000000000
,
$
subscription
->
startTime
());
$
this
->
assertEquals
(
1000000000000
,
$
subscription
->
initiationTime
());
$
this
->
assertEquals
(
$
tomorrow
,
$
subscription
->
endTime
());
$
this
->
assertEquals
(
$
tomorrow
,
$
subscription
->
expirationTime
());
$
this
->
assertEquals
(
$
tomorrow
,
$
subscription
->
nextTime
());
$
this
->
assertEquals
(
'
androidpublisher#subscriptionPurchase
'
,
$
subscription
->
kind
());
}
/** @test */
public
function
it_should_parse_not_found_response
()
{
$
subscription
=
new
Subscription
([
"
error
"
=>
"
not_found
"
,
"
error_description
"
=>
"
The requested purchase is not found!
"
,
]);
$
this
->
assertFalse
(
$
subscription
->
found
());
$
this
->
assertTrue
(
$
subscription
->
failed
());
$
this
->
assertTrue
(
$
subscription
->
hasError
());
$
this
->
assertTrue
(
$
subscription
->
notFound
());
$
this
->
assertEquals
(
'
not_found
'
,
$
subscription
->
error
());
$
this
->
assertEquals
(
'
The requested purchase is not found!
'
,
$
subscription
->
errorDescription
());
}
}
Back
|
FazBrowse Home
|
New Git URL