1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of EC-CUBE |
5
|
|
|
* |
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
7
|
|
|
* |
8
|
|
|
* http://www.lockon.co.jp/ |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
use Codeception\Util\Fixtures; |
15
|
|
|
use Doctrine\ORM\EntityManager; |
16
|
|
|
use Eccube\Entity\Plugin; |
17
|
|
|
use Eccube\Repository\PluginRepository; |
18
|
|
|
use Page\Admin\PluginLocalInstallPage; |
19
|
|
|
use Page\Admin\PluginManagePage; |
20
|
|
|
use Page\Admin\PluginSearchPage; |
21
|
|
|
|
22
|
|
|
class EA10PluginCest |
23
|
|
|
{ |
24
|
|
|
/** @var EntityManager */ |
25
|
|
|
private $em; |
26
|
|
|
|
27
|
|
|
/** @var \Doctrine\DBAL\Connection */ |
28
|
|
|
private $conn; |
29
|
|
|
|
30
|
|
|
/** @var PluginRepository */ |
31
|
|
|
private $pluginRepository; |
32
|
|
|
|
33
|
|
|
public function _before(\AcceptanceTester $I) |
34
|
|
|
{ |
35
|
|
|
$I->loginAsAdmin(); |
36
|
|
|
|
37
|
|
|
$this->em = Fixtures::get('entityManager'); |
38
|
|
|
$this->conn = $this->em->getConnection(); |
39
|
|
|
$this->pluginRepository = $this->em->getRepository(Plugin::class); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function installFromStore(\AcceptanceTester $I) |
43
|
|
|
{ |
44
|
|
|
/* |
45
|
|
|
* インストール |
46
|
|
|
*/ |
47
|
|
|
|
48
|
|
|
$ManagePage = PluginSearchPage::go($I) |
49
|
|
|
->入手する('SamplePayment') |
50
|
|
|
->インストール(); |
51
|
|
|
|
52
|
|
|
$I->assertFalse($this->tableExists('plg_sample_payment_config')); |
53
|
|
|
$I->assertFalse($this->columnExists('dtb_customer', 'sample_payment_cards')); |
54
|
|
|
|
55
|
|
|
$Plugin = $this->pluginRepository->findByCode('SamplePayment'); |
56
|
|
|
$I->assertFalse($Plugin->isInitialized(), '初期化されていない'); |
57
|
|
|
$I->assertFalse($Plugin->isEnabled(), '有効化されていない'); |
58
|
|
|
|
59
|
|
|
/* |
60
|
|
|
* 有効化 |
61
|
|
|
*/ |
62
|
|
|
$ManagePage->ストアプラグイン_有効化('SamplePayment'); |
63
|
|
|
|
64
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を有効にしました。', PluginManagePage::完了メーッセージ); |
65
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
66
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
67
|
|
|
|
68
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
69
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
70
|
|
|
$I->assertTrue($Plugin->isEnabled(), '有効化されている'); |
71
|
|
|
|
72
|
|
|
/* |
73
|
|
|
* 無効化 |
74
|
|
|
*/ |
75
|
|
|
$ManagePage->ストアプラグイン_無効化('SamplePayment'); |
76
|
|
|
|
77
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を無効にしました。', PluginManagePage::完了メーッセージ); |
78
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
79
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
80
|
|
|
|
81
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
82
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
83
|
|
|
$I->assertFalse($Plugin->isEnabled(), '無効化されている'); |
84
|
|
|
|
85
|
|
|
/* |
86
|
|
|
* 再度有効化 |
87
|
|
|
*/ |
88
|
|
|
$ManagePage->ストアプラグイン_有効化('SamplePayment'); |
89
|
|
|
|
90
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を有効にしました。', PluginManagePage::完了メーッセージ); |
91
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
92
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
93
|
|
|
|
94
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
95
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
96
|
|
|
$I->assertTrue($Plugin->isEnabled(), '有効化されている'); |
97
|
|
|
|
98
|
|
|
/* |
99
|
|
|
* 再度無効化 |
100
|
|
|
*/ |
101
|
|
|
$ManagePage->ストアプラグイン_無効化('SamplePayment'); |
102
|
|
|
|
103
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を無効にしました。', PluginManagePage::完了メーッセージ); |
104
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
105
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
106
|
|
|
|
107
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
108
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
109
|
|
|
$I->assertFalse($Plugin->isEnabled(), '無効化されている'); |
110
|
|
|
|
111
|
|
|
/* |
112
|
|
|
* 削除 |
113
|
|
|
*/ |
114
|
|
|
$ManagePage->ストアプラグイン_削除('SamplePayment'); |
115
|
|
|
|
116
|
|
|
$I->assertFalse($this->tableExists('plg_sample_payment_config')); |
117
|
|
|
$I->assertFalse($this->columnExists('dtb_customer', 'sample_payment_cards')); |
118
|
|
|
|
119
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
120
|
|
|
$Plugin = $this->pluginRepository->findByCode('SamplePayment'); |
121
|
|
|
$I->assertNull($Plugin); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function installFromLocal(\AcceptanceTester $I) |
125
|
|
|
{ |
126
|
|
|
/* |
127
|
|
|
* インストール |
128
|
|
|
*/ |
129
|
|
|
$ManagePage = PluginLocalInstallPage::go($I) |
130
|
|
|
->アップロード('SamplePayment-1.0.0-beta-1.tgz'); |
131
|
|
|
|
132
|
|
|
$I->see('プラグインをインストールしました。', PluginManagePage::完了メーッセージ); |
133
|
|
|
|
134
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
135
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
136
|
|
|
|
137
|
|
|
$Plugin = $this->pluginRepository->findByCode('SamplePayment'); |
138
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されていない'); |
139
|
|
|
$I->assertFalse($Plugin->isEnabled(), '有効化されていない'); |
140
|
|
|
|
141
|
|
|
/* |
142
|
|
|
* 有効化 |
143
|
|
|
*/ |
144
|
|
|
$ManagePage->独自プラグイン_有効化('SamplePayment'); |
145
|
|
|
|
146
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を有効にしました。', PluginManagePage::完了メーッセージ); |
147
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
148
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
149
|
|
|
|
150
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
151
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
152
|
|
|
$I->assertTrue($Plugin->isEnabled(), '有効化されている'); |
153
|
|
|
|
154
|
|
|
/* |
155
|
|
|
* 無効化 |
156
|
|
|
*/ |
157
|
|
|
$ManagePage->独自プラグイン_無効化('SamplePayment'); |
158
|
|
|
|
159
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を無効にしました。', PluginManagePage::完了メーッセージ); |
160
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
161
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
162
|
|
|
|
163
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
164
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
165
|
|
|
$I->assertFalse($Plugin->isEnabled(), '無効化されている'); |
166
|
|
|
|
167
|
|
|
/* |
168
|
|
|
* 再度有効化 |
169
|
|
|
*/ |
170
|
|
|
$ManagePage->独自プラグイン_有効化('SamplePayment'); |
171
|
|
|
|
172
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を有効にしました。', PluginManagePage::完了メーッセージ); |
173
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
174
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
175
|
|
|
|
176
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
177
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
178
|
|
|
$I->assertTrue($Plugin->isEnabled(), '有効化されている'); |
179
|
|
|
|
180
|
|
|
/* |
181
|
|
|
* 再度無効化 |
182
|
|
|
*/ |
183
|
|
|
$ManagePage->独自プラグイン_無効化('SamplePayment'); |
184
|
|
|
|
185
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を無効にしました。', PluginManagePage::完了メーッセージ); |
186
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
187
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
188
|
|
|
|
189
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
190
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
191
|
|
|
$I->assertFalse($Plugin->isEnabled(), '無効化されている'); |
192
|
|
|
|
193
|
|
|
/* |
194
|
|
|
* 削除 |
195
|
|
|
*/ |
196
|
|
|
$ManagePage->独自プラグイン_削除('SamplePayment'); |
197
|
|
|
|
198
|
|
|
$I->see('プラグインを削除しました。', PluginManagePage::完了メーッセージ); |
199
|
|
|
|
200
|
|
|
$I->assertFalse($this->tableExists('plg_sample_payment_config')); |
201
|
|
|
$I->assertFalse($this->columnExists('dtb_customer', 'sample_payment_cards')); |
202
|
|
|
|
203
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
204
|
|
|
$Plugin = $this->pluginRepository->findByCode('SamplePayment'); |
205
|
|
|
$I->assertNull($Plugin); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
private function tableExists($tableName) |
209
|
|
|
{ |
210
|
|
|
return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}';")->fetch()['count'] > 0; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
private function columnExists($tableName, $columnName) |
214
|
|
|
{ |
215
|
|
|
return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1; |
216
|
|
|
} |
217
|
|
|
} |
218
|
|
|
|
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: