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\Common\EccubeConfig; |
17
|
|
|
use Eccube\Entity\Plugin; |
18
|
|
|
use Eccube\Repository\PluginRepository; |
19
|
|
|
use Page\Admin\PluginLocalInstallPage; |
20
|
|
|
use Page\Admin\PluginManagePage; |
21
|
|
|
use Page\Admin\PluginSearchPage; |
22
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
23
|
|
|
|
24
|
|
|
class EA10PluginCest |
25
|
|
|
{ |
26
|
|
|
/** @var EntityManager */ |
27
|
|
|
private $em; |
28
|
|
|
|
29
|
|
|
/** @var \Doctrine\DBAL\Connection */ |
30
|
|
|
private $conn; |
31
|
|
|
|
32
|
|
|
/** @var PluginRepository */ |
33
|
|
|
private $pluginRepository; |
34
|
|
|
|
35
|
|
|
/** @var EccubeConfig */ |
36
|
|
|
private $config; |
37
|
|
|
|
38
|
|
|
public function _before(\AcceptanceTester $I) |
39
|
|
|
{ |
40
|
|
|
$I->loginAsAdmin(); |
41
|
|
|
|
42
|
|
|
$this->em = Fixtures::get('entityManager'); |
43
|
|
|
$this->conn = $this->em->getConnection(); |
44
|
|
|
$this->pluginRepository = $this->em->getRepository(Plugin::class); |
45
|
|
|
$this->config = Fixtures::get('config'); |
46
|
|
|
|
47
|
|
|
$this->cleanPluginData(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
private function cleanPluginData() |
51
|
|
|
{ |
52
|
|
|
$this->conn->executeUpdate('TRUNCATE dtb_plugin'); |
53
|
|
|
$fs = new Filesystem(); |
54
|
|
|
$fs->remove($this->config['plugin_realdir']); |
55
|
|
|
$fs->remove($this->config['eccube_html_plugin_dir']); |
56
|
|
|
exec("git checkout composer.json composer.lock"); |
57
|
|
|
exec("git checkout ".$this->config['plugin_realdir']); |
58
|
|
|
exec("git checkout ".$this->config['eccube_html_plugin_dir']); |
59
|
|
|
exec("git clean -df app/proxy"); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function installFromStore(\AcceptanceTester $I) |
63
|
|
|
{ |
64
|
|
|
/* |
65
|
|
|
* インストール |
66
|
|
|
*/ |
67
|
|
|
|
68
|
|
|
$ManagePage = PluginSearchPage::go($I) |
69
|
|
|
->入手する('SamplePayment') |
70
|
|
|
->インストール(); |
71
|
|
|
|
72
|
|
|
$I->assertFalse($this->tableExists('plg_sample_payment_config')); |
73
|
|
|
$I->assertFalse($this->columnExists('dtb_customer', 'sample_payment_cards')); |
74
|
|
|
|
75
|
|
|
$Plugin = $this->pluginRepository->findByCode('SamplePayment'); |
76
|
|
|
$I->assertFalse($Plugin->isInitialized(), '初期化されていない'); |
77
|
|
|
$I->assertFalse($Plugin->isEnabled(), '有効化されていない'); |
78
|
|
|
|
79
|
|
|
/* |
80
|
|
|
* 有効化 |
81
|
|
|
*/ |
82
|
|
|
$ManagePage->ストアプラグイン_有効化('SamplePayment'); |
83
|
|
|
|
84
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を有効にしました。', PluginManagePage::完了メーッセージ); |
85
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
86
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
87
|
|
|
|
88
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
89
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
90
|
|
|
$I->assertTrue($Plugin->isEnabled(), '有効化されている'); |
91
|
|
|
|
92
|
|
|
/* |
93
|
|
|
* 無効化 |
94
|
|
|
*/ |
95
|
|
|
$ManagePage->ストアプラグイン_無効化('SamplePayment'); |
96
|
|
|
|
97
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を無効にしました。', PluginManagePage::完了メーッセージ); |
98
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
99
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
100
|
|
|
|
101
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
102
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
103
|
|
|
$I->assertFalse($Plugin->isEnabled(), '無効化されている'); |
104
|
|
|
|
105
|
|
|
/* |
106
|
|
|
* 再度有効化 |
107
|
|
|
*/ |
108
|
|
|
$ManagePage->ストアプラグイン_有効化('SamplePayment'); |
109
|
|
|
|
110
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を有効にしました。', PluginManagePage::完了メーッセージ); |
111
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
112
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
113
|
|
|
|
114
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
115
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
116
|
|
|
$I->assertTrue($Plugin->isEnabled(), '有効化されている'); |
117
|
|
|
|
118
|
|
|
/* |
119
|
|
|
* 再度無効化 |
120
|
|
|
*/ |
121
|
|
|
$ManagePage->ストアプラグイン_無効化('SamplePayment'); |
122
|
|
|
|
123
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を無効にしました。', PluginManagePage::完了メーッセージ); |
124
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
125
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
126
|
|
|
|
127
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
128
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
129
|
|
|
$I->assertFalse($Plugin->isEnabled(), '無効化されている'); |
130
|
|
|
|
131
|
|
|
/* |
132
|
|
|
* 削除 |
133
|
|
|
*/ |
134
|
|
|
$ManagePage->ストアプラグイン_削除('SamplePayment'); |
135
|
|
|
|
136
|
|
|
$I->assertFalse($this->tableExists('plg_sample_payment_config')); |
137
|
|
|
$I->assertFalse($this->columnExists('dtb_customer', 'sample_payment_cards')); |
138
|
|
|
|
139
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
140
|
|
|
$Plugin = $this->pluginRepository->findByCode('SamplePayment'); |
141
|
|
|
$I->assertNull($Plugin); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function installFromLocal(\AcceptanceTester $I) |
145
|
|
|
{ |
146
|
|
|
/* |
147
|
|
|
* インストール |
148
|
|
|
*/ |
149
|
|
|
$ManagePage = PluginLocalInstallPage::go($I) |
150
|
|
|
->アップロード('SamplePayment-1.0.0-beta-1.tgz'); |
151
|
|
|
|
152
|
|
|
$I->see('プラグインをインストールしました。', PluginManagePage::完了メーッセージ); |
153
|
|
|
|
154
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
155
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
156
|
|
|
|
157
|
|
|
$Plugin = $this->pluginRepository->findByCode('SamplePayment'); |
158
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されていない'); |
159
|
|
|
$I->assertFalse($Plugin->isEnabled(), '有効化されていない'); |
160
|
|
|
|
161
|
|
|
/* |
162
|
|
|
* 有効化 |
163
|
|
|
*/ |
164
|
|
|
$ManagePage->独自プラグイン_有効化('SamplePayment'); |
165
|
|
|
|
166
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を有効にしました。', PluginManagePage::完了メーッセージ); |
167
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
168
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
169
|
|
|
|
170
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
171
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
172
|
|
|
$I->assertTrue($Plugin->isEnabled(), '有効化されている'); |
173
|
|
|
|
174
|
|
|
/* |
175
|
|
|
* 無効化 |
176
|
|
|
*/ |
177
|
|
|
$ManagePage->独自プラグイン_無効化('SamplePayment'); |
178
|
|
|
|
179
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を無効にしました。', PluginManagePage::完了メーッセージ); |
180
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
181
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
182
|
|
|
|
183
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
184
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
185
|
|
|
$I->assertFalse($Plugin->isEnabled(), '無効化されている'); |
186
|
|
|
|
187
|
|
|
/* |
188
|
|
|
* 再度有効化 |
189
|
|
|
*/ |
190
|
|
|
$ManagePage->独自プラグイン_有効化('SamplePayment'); |
191
|
|
|
|
192
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を有効にしました。', PluginManagePage::完了メーッセージ); |
193
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
194
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
195
|
|
|
|
196
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
197
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
198
|
|
|
$I->assertTrue($Plugin->isEnabled(), '有効化されている'); |
199
|
|
|
|
200
|
|
|
/* |
201
|
|
|
* 再度無効化 |
202
|
|
|
*/ |
203
|
|
|
$ManagePage->独自プラグイン_無効化('SamplePayment'); |
204
|
|
|
|
205
|
|
|
$I->see('「EC-CUBE Payment Sample Plugin」を無効にしました。', PluginManagePage::完了メーッセージ); |
206
|
|
|
$I->assertTrue($this->tableExists('plg_sample_payment_config')); |
207
|
|
|
$I->assertTrue($this->columnExists('dtb_customer', 'sample_payment_cards')); |
208
|
|
|
|
209
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
210
|
|
|
$I->assertTrue($Plugin->isInitialized(), '初期化されている'); |
211
|
|
|
$I->assertFalse($Plugin->isEnabled(), '無効化されている'); |
212
|
|
|
|
213
|
|
|
/* |
214
|
|
|
* 削除 |
215
|
|
|
*/ |
216
|
|
|
$ManagePage->独自プラグイン_削除('SamplePayment'); |
217
|
|
|
|
218
|
|
|
$I->see('プラグインを削除しました。', PluginManagePage::完了メーッセージ); |
219
|
|
|
|
220
|
|
|
$I->assertFalse($this->tableExists('plg_sample_payment_config')); |
221
|
|
|
$I->assertFalse($this->columnExists('dtb_customer', 'sample_payment_cards')); |
222
|
|
|
|
223
|
|
|
$this->em->refresh($Plugin); |
|
|
|
|
224
|
|
|
$Plugin = $this->pluginRepository->findByCode('SamplePayment'); |
225
|
|
|
$I->assertNull($Plugin); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function installLocalPluginWithAssets(\AcceptanceTester $I) |
229
|
|
|
{ |
230
|
|
|
$assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js'; |
231
|
|
|
$updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js'; |
232
|
|
|
|
233
|
|
|
$I->assertFileNotExists($assetsPath); |
234
|
|
|
$I->assertFileNotExists($updatedPath); |
235
|
|
|
|
236
|
|
|
$ManagePage = PluginLocalInstallPage::go($I)->アップロード('plugins/Assets-1.0.0.tgz'); |
237
|
|
|
$I->assertFileExists($assetsPath); |
238
|
|
|
$I->assertFileNotExists($updatedPath); |
239
|
|
|
|
240
|
|
|
$ManagePage->独自プラグイン_有効化('Assets'); |
241
|
|
|
$I->assertFileExists($assetsPath); |
242
|
|
|
$I->assertFileNotExists($updatedPath); |
243
|
|
|
|
244
|
|
|
$ManagePage->独自プラグイン_無効化('Assets'); |
245
|
|
|
$I->assertFileExists($assetsPath); |
246
|
|
|
$I->assertFileNotExists($updatedPath); |
247
|
|
|
|
248
|
|
|
$ManagePage->独自プラグイン_アップデート('Assets', 'plugins/Assets-1.0.1.tgz'); |
249
|
|
|
$I->assertFileExists($assetsPath); |
250
|
|
|
$I->assertFileExists($updatedPath); |
251
|
|
|
|
252
|
|
|
$ManagePage->独自プラグイン_削除('Assets'); |
253
|
|
|
$I->assertFileNotExists($assetsPath); |
254
|
|
|
$I->assertFileNotExists($updatedPath); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
public function installStorePluginWithAssets(\AcceptanceTester $I) |
258
|
|
|
{ |
259
|
|
|
// 最初のバージョンを作成 |
260
|
|
|
copy(codecept_data_dir().'/'.'plugins/Assets-1.0.0.tgz', codecept_root_dir().'/repos/Assets-1.0.0.tgz'); |
261
|
|
|
|
262
|
|
|
$assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js'; |
263
|
|
|
$updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js'; |
264
|
|
|
$I->assertFileNotExists($assetsPath); |
265
|
|
|
$I->assertFileNotExists($updatedPath); |
266
|
|
|
|
267
|
|
|
$ManagePage = PluginSearchPage::go($I) |
268
|
|
|
->入手する('Assets') |
269
|
|
|
->インストール(); |
270
|
|
|
$I->assertFileNotExists($assetsPath); |
271
|
|
|
$I->assertFileNotExists($updatedPath); |
272
|
|
|
|
273
|
|
|
$ManagePage->ストアプラグイン_有効化('Assets'); |
274
|
|
|
$I->assertFileExists($assetsPath); |
275
|
|
|
$I->assertFileNotExists($updatedPath); |
276
|
|
|
|
277
|
|
|
$ManagePage->ストアプラグイン_無効化('Assets'); |
278
|
|
|
$I->assertFileExists($assetsPath); |
279
|
|
|
$I->assertFileNotExists($updatedPath); |
280
|
|
|
|
281
|
|
|
// 新しいバージョンを作成 |
282
|
|
|
copy(codecept_data_dir().'/'.'plugins/Assets-1.0.1.tgz', codecept_root_dir().'/repos/Assets-1.0.1.tgz'); |
283
|
|
|
|
284
|
|
|
$I->reloadPage(); |
285
|
|
|
$ManagePage->ストアプラグイン_アップデート('Assets')->アップデート(); |
286
|
|
|
$I->assertFileExists($assetsPath); |
287
|
|
|
$I->assertFileExists($updatedPath); |
288
|
|
|
|
289
|
|
|
$ManagePage->ストアプラグイン_無効化('Assets'); |
290
|
|
|
$I->assertFileExists($assetsPath); |
291
|
|
|
$I->assertFileExists($updatedPath); |
292
|
|
|
|
293
|
|
|
$ManagePage->ストアプラグイン_削除('Assets'); |
294
|
|
|
$I->assertFileNotExists($assetsPath); |
295
|
|
|
$I->assertFileNotExists($updatedPath); |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
private function tableExists($tableName) |
299
|
|
|
{ |
300
|
|
|
return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}';")->fetch()['count'] > 0; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
private function columnExists($tableName, $columnName) |
304
|
|
|
{ |
305
|
|
|
return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1; |
306
|
|
|
} |
307
|
|
|
} |
308
|
|
|
|
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: