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