Completed
Push — dev/plugin-misc ( 77e831 )
by Kiyotaka
07:27
created

EA10PluginCest::installRemoveFromLocal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 31
rs 9.424
c 0
b 0
f 0
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
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);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
203
        $Plugin = $this->pluginRepository->findByCode('Horizon');
204
        $I->assertNull($Plugin);
205
    }
206
207
    public function installRemoveFromLocal(\AcceptanceTester $I)
208
    {
209
        /*
210
         * インストール
211
         */
212
        $ManagePage = PluginLocalInstallPage::go($I)
213
            ->アップロード('plugins/Horizon-1.0.0.tgz');
214
215
        $I->see('プラグインをインストールしました。', PluginManagePage::完了メーッセージ);
216
217
        $I->assertTrue($this->tableExists('dtb_dash'));
218
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
219
220
        $Plugin = $this->pluginRepository->findByCode('Horizon');
221
        $I->assertTrue($Plugin->isInitialized(), '初期化されていない');
222
        $I->assertFalse($Plugin->isEnabled(), '有効化されていない');
223
224
        /*
225
         * 削除
226
         */
227
        $ManagePage->独自プラグイン_削除('Horizon');
228
229
        $I->see('プラグインを削除しました。', PluginManagePage::完了メーッセージ);
230
231
        $I->assertFalse($this->tableExists('dtb_dash'));
232
        $I->assertFalse($this->columnExists('dtb_cart', 'is_horizon'));
233
234
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 220 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
235
        $Plugin = $this->pluginRepository->findByCode('Horizon');
236
        $I->assertNull($Plugin);
237
    }
238
239
    public function installRemoveFromStore(\AcceptanceTester $I)
240
    {
241
        $this->publishPlugin('Horizon-1.0.0.tgz');
242
        /*
243
         * インストール
244
         */
245
        $ManagePage = PluginSearchPage::go($I)
246
            ->入手する('Horizon')
247
            ->インストール();
248
249
        $I->assertFalse($this->tableExists('dtb_dash'));
250
        $I->assertFalse($this->columnExists('dtb_cart', 'is_horizon'));
251
252
        $Plugin = $this->pluginRepository->findByCode('Horizon');
253
        $I->assertFalse($Plugin->isInitialized(), '初期化されていない');
254
        $I->assertFalse($Plugin->isEnabled(), '有効化されていない');
255
256
        /*
257
         * 削除
258
         */
259
        $ManagePage->ストアプラグイン_削除('Horizon');
260
261
        $I->assertFalse($this->tableExists('dtb_dash'));
262
        $I->assertFalse($this->columnExists('dtb_cart', 'is_horizon'));
263
264
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 252 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

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:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
265
        $Plugin = $this->pluginRepository->findByCode('Horizon');
266
        $I->assertNull($Plugin);
267
    }
268
269
    public function installLocalPluginWithAssets(\AcceptanceTester $I)
270
    {
271
        $this->publishPlugin('Assets-1.0.0.tgz');
272
273
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
274
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
275
276
        $I->assertFileNotExists($assetsPath);
277
        $I->assertFileNotExists($updatedPath);
278
279
        $ManagePage = PluginLocalInstallPage::go($I)->アップロード('plugins/Assets-1.0.0.tgz');
280
        $I->assertFileExists($assetsPath);
281
        $I->assertFileNotExists($updatedPath);
282
283
        $ManagePage->独自プラグイン_有効化('Assets');
284
        $I->assertFileExists($assetsPath);
285
        $I->assertFileNotExists($updatedPath);
286
287
        $ManagePage->独自プラグイン_無効化('Assets');
288
        $I->assertFileExists($assetsPath);
289
        $I->assertFileNotExists($updatedPath);
290
291
        $ManagePage->独自プラグイン_アップデート('Assets', 'plugins/Assets-1.0.1.tgz');
292
        $I->assertFileExists($assetsPath);
293
        $I->assertFileExists($updatedPath);
294
295
        $ManagePage->独自プラグイン_削除('Assets');
296
        $I->assertFileNotExists($assetsPath);
297
        $I->assertFileNotExists($updatedPath);
298
    }
299
300
    public function installStorePluginWithAssets(\AcceptanceTester $I)
301
    {
302
        // 最初のバージョンを作成
303
        $this->publishPlugin('Assets-1.0.0.tgz');
304
305
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
306
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
307
        $I->assertFileNotExists($assetsPath);
308
        $I->assertFileNotExists($updatedPath);
309
310
        $ManagePage = PluginSearchPage::go($I)
311
            ->入手する('Assets')
312
            ->インストール();
313
        $I->assertFileNotExists($assetsPath);
314
        $I->assertFileNotExists($updatedPath);
315
316
        $ManagePage->ストアプラグイン_有効化('Assets');
317
        $I->assertFileExists($assetsPath);
318
        $I->assertFileNotExists($updatedPath);
319
320
        $ManagePage->ストアプラグイン_無効化('Assets');
321
        $I->assertFileExists($assetsPath);
322
        $I->assertFileNotExists($updatedPath);
323
324
        // 新しいバージョンを作成
325
        $this->publishPlugin('Assets-1.0.1.tgz');
326
327
        $I->reloadPage();
328
        $ManagePage->ストアプラグイン_アップデート('Assets')->アップデート();
329
        $I->assertFileExists($assetsPath);
330
        $I->assertFileExists($updatedPath);
331
332
        $ManagePage->ストアプラグイン_無効化('Assets');
333
        $I->assertFileExists($assetsPath);
334
        $I->assertFileExists($updatedPath);
335
336
        $ManagePage->ストアプラグイン_削除('Assets');
337
        $I->assertFileNotExists($assetsPath);
338
        $I->assertFileNotExists($updatedPath);
339
    }
340
341
    private function publishPlugin($fileName)
342
    {
343
        copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName);
344
    }
345
346
    private function tableExists($tableName)
347
    {
348
        return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}';")->fetch()['count'] > 0;
349
    }
350
351
    private function columnExists($tableName, $columnName)
352
    {
353
        return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1;
354
    }
355
}
356