1 | <?php |
||
29 | class ShopifyAPIComponentTest extends TestCase |
||
30 | { |
||
31 | |||
32 | public $component = null; |
||
33 | public $controller = null; |
||
34 | public $fixtures = ['plugin.Multidimensional/Cakephpify.Shops', 'plugin.Multidimensional/Cakephpify.AccessTokens']; |
||
35 | |||
36 | public function setUp() |
||
|
|||
37 | { |
||
38 | parent::setUp(); |
||
39 | |||
40 | Configure::write('Multidimensional/Cakephpify', [ |
||
41 | 'abc123' => |
||
42 | [ |
||
43 | 'sharedSecret' => 'abc123', |
||
44 | 'scope' => '', |
||
45 | 'privateApp' => false, |
||
46 | 'privateAppPassword' => NULL] |
||
47 | ]); |
||
48 | |||
49 | $request = new Request(); |
||
50 | $response = new Response(); |
||
51 | $this->controller = $this->getMockBuilder('Cake\Controller\Controller') |
||
52 | ->setConstructorArgs([$request, $response]) |
||
53 | ->setMethods(null) |
||
54 | ->getMock(); |
||
55 | $registry = new ComponentRegistry($this->controller); |
||
56 | $this->component = new ShopifyAPIComponent($registry, ['apiKey' => 'abc123']); |
||
57 | $event = new Event('Controller.startup', $this->controller); |
||
58 | $this->component->startup($event); |
||
59 | } |
||
60 | |||
61 | public function tearDown() |
||
66 | |||
67 | public function testShopDomain() |
||
68 | { |
||
69 | $shopDomain = "test.myshopify.com"; |
||
70 | $return = $this->component->setShopDomain($shopDomain); |
||
71 | $this->assertSame($return, $shopDomain); |
||
72 | $return = $this->component->getShopDomain(); |
||
73 | $this->assertSame($return, $shopDomain); |
||
74 | |||
75 | $shopDomain = "random.myshopify.com"; |
||
76 | $this->component->setShopDomain($shopDomain); |
||
77 | $return = $this->component->setShopDomain($shopDomain); |
||
78 | $this->assertSame($return, $shopDomain); |
||
79 | $return = $this->component->getShopDomain(); |
||
80 | $this->assertSame($return, $shopDomain); |
||
81 | |||
82 | $shopDomain = null; |
||
83 | $return = $this->component->setShopDomain($shopDomain); |
||
84 | $this->assertNull($return); |
||
85 | $return = $this->component->getShopDomain(); |
||
86 | $this->assertNull($return); |
||
87 | |||
88 | $shopDomain = false; |
||
89 | $return = $this->component->setShopDomain($shopDomain); |
||
90 | $this->assertFalse($return); |
||
91 | $return = $this->component->getShopDomain(); |
||
92 | $this->assertFalse($return); |
||
93 | |||
94 | $shopDomain = true; |
||
95 | $return = $this->component->setShopDomain($shopDomain); |
||
96 | $this->assertTrue($return); |
||
97 | $return = $this->component->getShopDomain(); |
||
98 | $this->assertTrue($return); |
||
99 | |||
100 | $shopDomain = "test.myshopify.com"; |
||
101 | $return = $this->component->validDomain($shopDomain); |
||
102 | $this->assertTrue($return); |
||
103 | |||
104 | $shopDomain = "TEST.MYshopify.COM"; |
||
105 | $return = $this->component->validDomain($shopDomain); |
||
106 | $this->assertTrue($return); |
||
107 | |||
108 | $shopDomain = "random.myshopify.com"; |
||
109 | $return = $this->component->validDomain($shopDomain); |
||
110 | $this->assertTrue($return); |
||
111 | |||
112 | $shopDomain = "www.myshopify.com"; |
||
113 | $return = $this->component->validDomain($shopDomain); |
||
114 | $this->assertTrue($return); |
||
115 | |||
116 | /*$shopDomain = "test.myshopify.net"; |
||
117 | $return = $this->component->validDomain($shopDomain); |
||
118 | $this->assertFalse($return); |
||
119 | |||
120 | $shopDomain = "http://test.myshopify.com/"; |
||
121 | $return = $this->component->validDomain($shopDomain); |
||
122 | $this->assertFalse($return); |
||
123 | |||
124 | $shopDomain = "google.com"; |
||
125 | $return = $this->component->validDomain($shopDomain); |
||
126 | $this->assertFalse($return); |
||
127 | |||
128 | $shopDomain = NULL; |
||
129 | $return = $this->component->validDomain($shopDomain); |
||
130 | $this->assertFalse($return); |
||
131 | |||
132 | $shopDomain = false; |
||
133 | $return = $this->component->validDomain($shopDomain); |
||
134 | $this->assertFalse($return); |
||
135 | |||
136 | $shopDomain = true; |
||
137 | $return = $this->component->validDomain($shopDomain); |
||
138 | $this->assertFalse($return);*/ |
||
139 | } |
||
140 | |||
141 | public function testSetAccessToken() |
||
145 | |||
146 | public function testGetAuthorizeUrl() |
||
150 | |||
151 | public function testGetAccessToken() |
||
155 | |||
156 | public function testNonce() |
||
157 | { |
||
188 | |||
189 | public function testValidateHMAC() |
||
203 | } |
||
204 |