|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* CakePHPify : CakePHP Plugin for Shopify API Authentication |
|
4
|
|
|
* Copyright (c) Multidimension.al (http://multidimension.al) |
|
5
|
|
|
* Github : https://github.com/multidimension-al/cakephpify |
|
6
|
|
|
* |
|
7
|
|
|
* Licensed under The MIT License |
|
8
|
|
|
* For full copyright and license information, please see the LICENSE file |
|
9
|
|
|
* Redistributions of files must retain the above copyright notice. |
|
10
|
|
|
* |
|
11
|
|
|
* @copyright (c) Multidimension.al (http://multidimension.al) |
|
12
|
|
|
* @link https://github.com/multidimension-al/cakephpify CakePHPify Github |
|
13
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Multidimensional\Cakephpify\Test\TestCase\Controller\Component; |
|
17
|
|
|
|
|
18
|
|
|
use Cake\Controller\ComponentRegistry; |
|
19
|
|
|
use Cake\Controller\Controller; |
|
20
|
|
|
use Cake\Event\Event; |
|
21
|
|
|
use Cake\Network\Request; |
|
22
|
|
|
use Cake\Network\Response; |
|
23
|
|
|
use Cake\TestSuite\TestCase; |
|
24
|
|
|
use Multidimensional\Cakephpify\Controller\Component\ShopifyDatabaseComponent; |
|
25
|
|
|
use Multidimensional\Cakephpify\Test\Fixture\AccessTokensFixture; |
|
26
|
|
|
use Multidimensional\Cakephpify\Test\Fixture\ShopsFixture; |
|
27
|
|
|
|
|
28
|
|
|
class ShopifyDatabaseComponentTest extends TestCase |
|
29
|
|
|
{ |
|
30
|
|
|
|
|
31
|
|
|
public $component = null; |
|
32
|
|
|
public $controller = null; |
|
33
|
|
|
|
|
34
|
|
|
public $fixtures = ['plugin.Multidimensional/Cakephpify.Shops', |
|
35
|
|
|
'plugin.Multidimensional/Cakephpify.AccessTokens']; |
|
36
|
|
|
|
|
37
|
|
|
public function setUp() |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
parent::setUp(); |
|
40
|
|
|
$request = new Request(); |
|
41
|
|
|
$response = new Response(); |
|
42
|
|
|
$this->controller = $this->getMockBuilder('Cake\Controller\Controller') |
|
43
|
|
|
->setConstructorArgs([$request, $response]) |
|
44
|
|
|
->setMethods(null) |
|
45
|
|
|
->getMock(); |
|
46
|
|
|
$registry = new ComponentRegistry($this->controller); |
|
47
|
|
|
$this->component = new ShopifyDatabaseComponent($registry); |
|
48
|
|
|
$event = new Event('Controller.startup', $this->controller); |
|
49
|
|
|
$this->component->startup($event); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function tearDown() |
|
|
|
|
|
|
53
|
|
|
{ |
|
54
|
|
|
parent::tearDown(); |
|
55
|
|
|
unset($this->component, $this->controller); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testShopDataToDatabase() |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
$this->markTestIncomplete('Not implemented yet.'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testAccessTokenToDatabase() |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
$this->markTestIncomplete('Not implemented yet.'); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function testGetShopIdFromDomain() |
|
|
|
|
|
|
69
|
|
|
{ |
|
70
|
|
|
//$return = $this->component->getShopIdFromDomain('test.myshopify.com'); |
|
|
|
|
|
|
71
|
|
|
//$this->assertSame($return, 8675309); |
|
|
|
|
|
|
72
|
|
|
//$this->assertEquals($return, 8675309); |
|
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
$return = $this->component->getShopIdFromDomain('false.myshopify.com'); |
|
75
|
|
|
$this->assertFalse($return); |
|
76
|
|
|
|
|
77
|
|
|
$return = $this->component->getShopIdFromDomain('not-a-domain.com'); |
|
78
|
|
|
$this->assertFalse($return); |
|
79
|
|
|
|
|
80
|
|
|
$return = $this->component->getShopIdFromDomain(null); |
|
81
|
|
|
$this->assertFalse($return); |
|
82
|
|
|
|
|
83
|
|
|
$return = $this->component->getShopIdFromDomain(true); |
|
|
|
|
|
|
84
|
|
|
$this->assertFalse($return); |
|
85
|
|
|
|
|
86
|
|
|
$return = $this->component->getShopIdFromDomain(false); |
|
|
|
|
|
|
87
|
|
|
$this->assertFalse($return); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function testGetShopDataFromAccessToken() |
|
|
|
|
|
|
91
|
|
|
{ |
|
92
|
|
|
$return = $this->component->getShopDataFromAccessToken(null, null); |
|
93
|
|
|
$this->assertFalse($return); |
|
94
|
|
|
|
|
95
|
|
|
$return = $this->component->getShopDataFromAccessToken(null, true); |
|
|
|
|
|
|
96
|
|
|
$this->assertFalse($return); |
|
97
|
|
|
|
|
98
|
|
|
$return = $this->component->getShopDataFromAccessToken(true, null); |
|
|
|
|
|
|
99
|
|
|
$this->assertFalse($return); |
|
100
|
|
|
|
|
101
|
|
|
$return = $this->component->getShopDataFromAccessToken(null, false); |
|
|
|
|
|
|
102
|
|
|
$this->assertFalse($return); |
|
103
|
|
|
|
|
104
|
|
|
$return = $this->component->getShopDataFromAccessToken(false, null); |
|
|
|
|
|
|
105
|
|
|
$this->assertFalse($return); |
|
106
|
|
|
|
|
107
|
|
|
$return = $this->component->getShopDataFromAccessToken(false, false); |
|
|
|
|
|
|
108
|
|
|
$this->assertFalse($return); |
|
109
|
|
|
|
|
110
|
|
|
$return = $this->component->getShopDataFromAccessToken(true, true); |
|
|
|
|
|
|
111
|
|
|
$this->assertFalse($return); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function testGetAccessTokenFromShopDomain() |
|
|
|
|
|
|
115
|
|
|
{ |
|
116
|
|
|
$return = $this->component->getAccessTokenFromShopDomain(null, null); |
|
117
|
|
|
$this->assertFalse($return); |
|
118
|
|
|
|
|
119
|
|
|
$return = $this->component->getAccessTokenFromShopDomain(null, true); |
|
|
|
|
|
|
120
|
|
|
$this->assertFalse($return); |
|
121
|
|
|
|
|
122
|
|
|
$return = $this->component->getAccessTokenFromShopDomain(true, null); |
|
|
|
|
|
|
123
|
|
|
$this->assertFalse($return); |
|
124
|
|
|
|
|
125
|
|
|
$return = $this->component->getAccessTokenFromShopDomain(null, false); |
|
|
|
|
|
|
126
|
|
|
$this->assertFalse($return); |
|
127
|
|
|
|
|
128
|
|
|
$return = $this->component->getAccessTokenFromShopDomain(false, null); |
|
|
|
|
|
|
129
|
|
|
$this->assertFalse($return); |
|
130
|
|
|
|
|
131
|
|
|
$return = $this->component->getAccessTokenFromShopDomain(false, false); |
|
|
|
|
|
|
132
|
|
|
$this->assertFalse($return); |
|
133
|
|
|
|
|
134
|
|
|
$return = $this->component->getAccessTokenFromShopDomain(true, true); |
|
|
|
|
|
|
135
|
|
|
$this->assertFalse($return); |
|
|
|
|
|
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|