Completed
Push — 4.0 ( 268f2c...88f012 )
by Hideki
05:48 queued 10s
created

codeception/acceptance/EA10PluginCest.php (16 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.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 View Code Duplication
    public function _before(\AcceptanceTester $I)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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 test_install_enable_disable_remove_store(\AcceptanceTester $I)
50
    {
51
        Horizon_Store::start($I)
52
            ->インストール()
53
            ->有効化()
54
            ->無効化()
55
            ->削除();
56
    }
57
58
    public function test_install_enable_disable_remove_local(\AcceptanceTester $I)
59
    {
60
        Horizon_Store::start($I)
61
            ->インストール()
62
            ->有効化()
63
            ->無効化()
64
            ->削除();
65
    }
66
67
    public function test_install_enable_disable_enable_disable_remove_store(\AcceptanceTester $I)
68
    {
69
        Horizon_Store::start($I)
70
            ->インストール()
71
            ->有効化()
72
            ->無効化()
73
            ->有効化()
74
            ->無効化()
75
            ->削除();
76
    }
77
78
    public function test_install_enable_disable_enable_disable_remove_local(\AcceptanceTester $I)
79
    {
80
        Horizon_Local::start($I)
81
            ->インストール()
82
            ->有効化()
83
            ->無効化()
84
            ->有効化()
85
            ->無効化()
86
            ->削除();
87
    }
88
89
    public function test_install_remove_local(\AcceptanceTester $I)
90
    {
91
        Horizon_Local::start($I)
92
            ->インストール()
93
            ->削除();
94
    }
95
96
    public function test_install_remove_store(\AcceptanceTester $I)
97
    {
98
        Horizon_Store::start($I)
99
            ->インストール()
100
            ->削除();
101
    }
102
103
    public function test_install_update_remove_store(\AcceptanceTester $I)
104
    {
105
        Horizon_Store::start($I)
106
            ->インストール()
107
            ->アップデート()
108
            ->削除();
109
    }
110
111
    public function test_install_update_remove_local(\AcceptanceTester $I)
112
    {
113
        Horizon_Local::start($I)
114
            ->インストール()
115
            ->アップデート()
116
            ->削除();
117
    }
118
119
    public function test_install_enable_disable_update_enable_disable_remove_local(\AcceptanceTester $I)
120
    {
121
        Horizon_Local::start($I)
122
            ->インストール()
123
            ->有効化()
124
            ->無効化()
125
            ->アップデート()
126
            ->有効化()
127
            ->無効化()
128
            ->削除();
129
    }
130
131
    public function test_install_enable_disable_update_enable_disable_remove_store(\AcceptanceTester $I)
132
    {
133
        Horizon_Store::start($I)
134
            ->インストール()
135
            ->有効化()
136
            ->無効化()
137
            ->アップデート()
138
            ->有効化()
139
            ->無効化()
140
            ->削除();
141
    }
142
143
    public function test_install_enable_update_disable_remove_store(\AcceptanceTester $I)
144
    {
145
        Horizon_Store::start($I)
146
            ->インストール()
147
            ->有効化()
148
            ->アップデート()
149
            ->削除();
150
    }
151
152
    public function test_install_enable_update_disable_remove_local(\AcceptanceTester $I)
153
    {
154
        Horizon_Local::start($I)
155
            ->インストール()
156
            ->有効化()
157
            ->アップデート()
158
            ->無効化()
159
            ->削除();
160
    }
161
162
    public function test_install_update_enable_disable_remove_local(\AcceptanceTester $I)
163
    {
164
        Horizon_Local::start($I)
165
            ->インストール()
166
            ->アップデート()
167
            ->有効化()
168
            ->無効化()
169
            ->削除();
170
    }
171
172
    public function test_install_update_enable_disable_remove_store(\AcceptanceTester $I)
173
    {
174
        Horizon_Store::start($I)
175
            ->インストール()
176
            ->アップデート()
177
            ->有効化()
178
            ->無効化()
179
            ->削除();
180
    }
181
182
    public function test_install_enable_enable(\AcceptanceTester $I)
183
    {
184
        Horizon_Store::start($I)
185
            ->インストール()
186
            ->新しいタブで開く()
187
            ->有効化()
188
            ->前のタブに戻る()
189
            ->既に有効なものを有効化();
190
    }
191
192
    public function test_install_disable_disable(\AcceptanceTester $I)
193
    {
194
        Horizon_Store::start($I)
195
            ->インストール()
196
            ->有効化()
197
            ->新しいタブで開く()
198
            ->無効化()
199
            ->前のタブに戻る()
200
            ->既に無効なものを無効化();
201
    }
202
203
    public function test_install_assets_local(\AcceptanceTester $I)
204
    {
205
        $this->publishPlugin('Assets-1.0.0.tgz');
206
207
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
208
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
209
210
        $I->assertFileNotExists($assetsPath);
211
        $I->assertFileNotExists($updatedPath);
212
213
        $ManagePage = PluginLocalInstallPage::go($I)->アップロード('plugins/Assets-1.0.0.tgz');
214
        $I->assertFileExists($assetsPath);
215
        $I->assertFileNotExists($updatedPath);
216
217
        $ManagePage->独自プラグイン_有効化('Assets');
218
        $I->assertFileExists($assetsPath);
219
        $I->assertFileNotExists($updatedPath);
220
221
        $ManagePage->独自プラグイン_無効化('Assets');
222
        $I->assertFileExists($assetsPath);
223
        $I->assertFileNotExists($updatedPath);
224
225
        $ManagePage->独自プラグイン_アップデート('Assets', 'plugins/Assets-1.0.1.tgz');
226
        $I->assertFileExists($assetsPath);
227
        $I->assertFileExists($updatedPath);
228
229
        $ManagePage->独自プラグイン_削除('Assets');
230
        $I->assertFileNotExists($assetsPath);
231
        $I->assertFileNotExists($updatedPath);
232
    }
233
234
    public function test_install_assets_store(\AcceptanceTester $I)
235
    {
236
        // 最初のバージョンを作成
237
        $this->publishPlugin('Assets-1.0.0.tgz');
238
239
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
240
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
241
        $I->assertFileNotExists($assetsPath);
242
        $I->assertFileNotExists($updatedPath);
243
244
        $ManagePage = PluginSearchPage::go($I)
245
            ->入手する('Assets')
246
            ->インストール();
247
        $I->assertFileNotExists($assetsPath);
248
        $I->assertFileNotExists($updatedPath);
249
250
        $ManagePage->ストアプラグイン_有効化('Assets');
251
        $I->assertFileExists($assetsPath);
252
        $I->assertFileNotExists($updatedPath);
253
254
        $ManagePage->ストアプラグイン_無効化('Assets');
255
        $I->assertFileExists($assetsPath);
256
        $I->assertFileNotExists($updatedPath);
257
258
        // 新しいバージョンを作成
259
        $this->publishPlugin('Assets-1.0.1.tgz');
260
261
        $I->reloadPage();
262
        $ManagePage->ストアプラグイン_アップデート('Assets')->アップデート();
263
        $I->assertFileExists($assetsPath);
264
        $I->assertFileExists($updatedPath);
265
266
        $ManagePage->ストアプラグイン_削除('Assets');
267
        $I->assertFileNotExists($assetsPath);
268
        $I->assertFileNotExists($updatedPath);
269
    }
270
271 View Code Duplication
    public function test_extend_same_table_store(\AcceptanceTester $I)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
272
    {
273
        $Horizon = Horizon_Store::start($I);
274
        $Boomerang = Boomerang_Store::start($I);
275
276
        $Horizon->インストール()->有効化();
277
        $Boomerang->インストール()->有効化();
278
279
        $Horizon->検証()->無効化()->削除();
280
        $Boomerang->検証()->無効化()->削除();
281
    }
282
283 View Code Duplication
    public function test_extend_same_table_disabled_remove_store(\AcceptanceTester $I)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
284
    {
285
        $Horizon = Horizon_Store::start($I);
286
        $Boomerang = Boomerang_Store::start($I);
287
288
        $Horizon->インストール()->有効化()->無効化();
289
        $Boomerang->インストール()->有効化()->無効化();
290
291
        $Horizon->検証()->削除();
292
        $Boomerang->検証()->削除();
293
    }
294
295 View Code Duplication
    public function test_extend_same_table_local(\AcceptanceTester $I)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
296
    {
297
        $Horizon = Horizon_Local::start($I);
298
        $Boomerang = Boomerang_Local::start($I);
299
300
        $Horizon->インストール()->有効化();
301
        $Boomerang->インストール()->有効化();
302
303
        $Horizon->検証()->無効化()->削除();
304
        $Boomerang->検証()->無効化()->削除();
305
    }
306
307 View Code Duplication
    public function test_extend_same_table_disabled_remove_local(\AcceptanceTester $I)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
308
    {
309
        $Horizon = Horizon_Local::start($I);
310
        $Boomerang = Boomerang_Local::start($I);
311
312
        $Horizon->インストール()->有効化()->無効化();
313
        $Boomerang->インストール()->有効化()->無効化();
314
315
        $Horizon->検証()->削除();
316
        $Boomerang->検証()->削除();
317
    }
318
319 View Code Duplication
    public function test_extend_same_table_crossed_store(\AcceptanceTester $I)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
320
    {
321
        $Horizon = Horizon_Store::start($I);
322
        $Boomerang = Boomerang_Store::start($I);
323
324
        $Horizon->インストール()->有効化()->無効化();
325
        $Boomerang->インストール()->有効化();
326
327
        $Horizon->検証()->削除();
328
        $Boomerang->検証()->無効化()->削除();
329
    }
330
331 View Code Duplication
    public function test_extend_same_table_crossed_local(\AcceptanceTester $I)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
332
    {
333
        $Horizon = Horizon_Local::start($I);
334
        $Boomerang = Boomerang_Local::start($I);
335
336
        $Horizon->インストール()->有効化()->無効化();
337
        $Boomerang->インストール()->有効化();
338
339
        $Horizon->検証()->削除();
340
        $Boomerang->検証()->無効化()->削除();
341
    }
342
343
    public function test_dependency_each_install_plugin(\AcceptanceTester $I)
344
    {
345
        $Horizon = Horizon_Store::start($I);
346
        $Emperor = Emperor_Store::start($I);
347
348
        $Horizon->インストール()->有効化();
349
        $Emperor->インストール()->有効化();
350
    }
351
352
    public function test_dependency_plugin_install(\AcceptanceTester $I)
353
    {
354
        $Horizon = Horizon_Store::start($I);
355
        $Emperor = Emperor_Store::start($I, $Horizon);
356
357
        $Emperor->インストール()
358
            ->依存より先に有効化();
359
360
        $Horizon->有効化();
361
362
        $Emperor->有効化();
363
364
        $Horizon->依存されているのが有効なのに無効化();
365
        $Emperor->無効化();
366
        $Horizon->無効化();
367
368
        $Horizon->依存されているのが削除されていないのに削除();
369
        $Emperor->削除();
370
        $Horizon->削除();
371
    }
372
373
    public function test_dependency_plugin_update(\AcceptanceTester $I)
374
    {
375
        $Horizon = Horizon_Store::start($I);
376
        $Emperor = Emperor_Store::start($I, $Horizon);
377
378
        $Emperor->インストール();
379
380
        $Horizon->検証()
381
            ->有効化();
382
383
        $Emperor
384
            ->有効化()
385
            ->無効化()
386
            ->アップデート();
387
388
        $Horizon->検証();
389
    }
390
391
    public function test_install_error(\AcceptanceTester $I)
392
    {
393
        $this->publishPlugin('InstallError.tgz');
394
        $Horizon = Horizon_Store::start($I);
395
396
        PluginSearchPage::go($I)
397
            ->入手する('InstallError')
398
            ->インストール('システムエラーが発生しました。');
399
400
        // エラー後に他のプラグインがインストールできる
401
        $Horizon->インストール();
402
    }
403
404
    private function publishPlugin($fileName)
405
    {
406
        copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName);
407
    }
408
}
409
410
abstract class Abstract_Plugin
411
{
412
    /** @var AcceptanceTester */
413
    protected $I;
414
415
    /** @var EntityManager */
416
    protected $em;
417
418
    /** @var \Doctrine\DBAL\Connection */
419
    protected $conn;
420
421
    /** @var PluginRepository */
422
    protected $pluginRepository;
423
424
    /** @var EccubeConfig */
425
    protected $config;
426
427
    protected $initialized = false;
428
429
    protected $enabled = false;
430
431
    protected $removed = false;
432
433
    protected $tables = [];
434
435
    protected $columns = [];
436
437
    protected $traits = [];
438
439 View Code Duplication
    public function __construct(\AcceptanceTester $I)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
440
    {
441
        $this->I = $I;
442
        $this->em = Fixtures::get('entityManager');
443
        $this->conn = $this->em->getConnection();
444
        $this->pluginRepository = $this->em->getRepository(Plugin::class);
445
        $this->config = Fixtures::get('config');
446
    }
447
448 View Code Duplication
    public function tableExists()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
449
    {
450
        foreach ($this->tables as $table) {
451
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0;
452
            $this->I->assertTrue($exists, 'テーブルがあるはず '.$table);
453
        }
454
    }
455
456 View Code Duplication
    public function tableNotExists()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
457
    {
458
        foreach ($this->tables as $table) {
459
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0;
460
            $this->I->assertFalse($exists, 'テーブルがないはず '.$table);
461
        }
462
    }
463
464 View Code Duplication
    public function columnExists()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
465
    {
466
        foreach ($this->columns as $column) {
467
            list($tableName, $columnName) = explode('.', $column);
468
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1;
469
            $this->I->assertTrue($exists, 'カラムがあるはず '.$column);
470
        }
471
    }
472
473 View Code Duplication
    public function columnNotExists()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
474
    {
475
        foreach ($this->columns as $column) {
476
            list($tableName, $columnName) = explode('.', $column);
477
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1;
478
            $this->I->assertFalse($exists, 'カラムがないはず '.$column);
479
        }
480
    }
481
482
    public function traitExists()
483
    {
484
        foreach ($this->traits as $trait => $target) {
485
            $this->I->assertContains($trait, file_get_contents($this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php'), 'Traitがあるはず '.$trait);
486
        }
487
    }
488
489
    public function traitNotExists()
490
    {
491
        foreach ($this->traits as $trait => $target) {
492
            $file = $this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php';
493
            if (file_exists($file)) {
494
                $this->I->assertNotContains($trait, file_get_contents($file), 'Traitがないはず '.$trait);
495
            } else {
496
                $this->I->assertTrue(true, 'Traitがないはず');
497
            }
498
        }
499
    }
500
501
    public function 新しいタブで開く()
502
    {
503
        $this->I->executeJS("window.open(location.href, 'other')");
504
        $this->I->switchToWindow('other');
505
506
        return $this;
507
    }
508
509
    public function 前のタブに戻る()
510
    {
511
        $this->I->switchToPreviousTab();
512
513
        return $this;
514
    }
515
516
    public function 検証()
517
    {
518
        if ($this->initialized) {
519
            $this->tableExists();
520
            $this->columnExists();
521
        } else {
522
            $this->tableNotExists();
523
            $this->columnNotExists();
524
        }
525
526
        if ($this->enabled) {
527
            $this->traitExists();
528
        } else {
529
            $this->traitNotExists();
530
        }
531
532
        return $this;
533
    }
534
}
535
536
class Store_Plugin extends Abstract_Plugin
537
{
538
    /** @var PluginManagePage */
539
    protected $ManagePage;
540
541
    /** @var Plugin */
542
    protected $Plugin;
543
544
    protected $code;
545
546
    /** @var Store_Plugin */
547
    protected $dependency;
548
549
    public function __construct(AcceptanceTester $I, $code, Store_Plugin $dependency = null)
550
    {
551
        parent::__construct($I);
552
        $this->code = $code;
553
        $this->publishPlugin($this->code.'-1.0.0.tgz');
554
        if ($dependency) {
555
            $this->dependency = $dependency;
556
            $this->ManagePage = $dependency->ManagePage;
557
            $this->Plugin = $this->pluginRepository->findByCode($code);
558
        }
559
    }
560
561
    public function インストール()
562
    {
563
        /*
564
         * インストール
565
         */
566
        $this->ManagePage = PluginSearchPage::go($this->I)
567
            ->入手する($this->code)
568
            ->インストール();
569
570
        $this->検証();
571
572
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
573
        $this->I->assertFalse($this->Plugin->isInitialized(), '初期化されていない');
574
        $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていない');
575
576
        if ($this->dependency) {
577
            $this->dependency->ManagePage = $this->ManagePage;
578
            $this->dependency->Plugin = $this->pluginRepository->findByCode($this->dependency->code);
579
        }
580
581
        return $this;
582
    }
583
584
    public function 有効化()
585
    {
586
        $this->ManagePage->ストアプラグイン_有効化($this->code);
587
588
        $this->initialized = true;
589
        $this->enabled = true;
590
591
        $this->検証();
592
593
        $this->em->refresh($this->Plugin);
594
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
595
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている');
596
597
        return $this;
598
    }
599
600
    public function 既に有効なものを有効化()
601
    {
602
        $this->ManagePage->ストアプラグイン_有効化($this->code, '既に有効です。');
603
604
        $this->initialized = true;
605
        $this->enabled = true;
606
607
        $this->検証();
608
609
        $this->em->refresh($this->Plugin);
610
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
611
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている');
612
613
        return $this;
614
    }
615
616
    public function 無効化()
617
    {
618
        $this->ManagePage->ストアプラグイン_無効化($this->code);
619
620
        $this->enabled = false;
621
622
        $this->検証();
623
624
        $this->em->refresh($this->Plugin);
625
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
626
        $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている');
627
628
        return $this;
629
    }
630
631
    public function 既に無効なものを無効化()
632
    {
633
        $this->ManagePage->ストアプラグイン_無効化($this->code, '既に無効です。');
634
635
        $this->enabled = false;
636
637
        $this->検証();
638
639
        $this->em->refresh($this->Plugin);
640
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
641
        $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている');
642
643
        return $this;
644
    }
645
646 View Code Duplication
    public function 削除()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
647
    {
648
        $this->ManagePage->ストアプラグイン_削除($this->code);
649
650
        $this->initialized = false;
651
        $this->enabled = false;
652
653
        $this->検証();
654
655
        $this->em->refresh($this->Plugin);
656
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
657
        $this->I->assertNull($this->Plugin, '削除されている');
658
659
        return $this;
660
    }
661
662
    public function アップデート()
663
    {
664
        $this->publishPlugin($this->code.'-1.0.1.tgz');
665
666
        $this->I->reloadPage();
667
        $this->ManagePage->ストアプラグイン_アップデート($this->code)->アップデート();
668
669
        $this->initialized = true;
670
        $this->enabled = false;
671
672
        $this->検証();
673
674
        $this->em->refresh($this->Plugin);
675
        $this->I->assertEquals($this->initialized, $this->Plugin->isInitialized(), '初期化');
676
        $this->I->assertEquals($this->enabled, $this->Plugin->isEnabled(), '有効/無効');
677
678
        return $this;
679
    }
680
681
    protected function publishPlugin($fileName)
682
    {
683
        $published = copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName);
684
        $this->I->assertTrue($published, "公開できた ${fileName}");
685
    }
686
}
687
688
class Local_Plugin extends Abstract_Plugin
689
{
690
    /** @var PluginManagePage */
691
    private $ManagePage;
692
693
    /** @var Plugin */
694
    private $Plugin;
695
696
    /** @var string */
697
    private $code;
698
699
    public function __construct(AcceptanceTester $I, $code)
700
    {
701
        parent::__construct($I);
702
        $this->code = $code;
703
    }
704
705
    public function インストール()
706
    {
707
        $this->ManagePage = PluginLocalInstallPage::go($this->I)
708
            ->アップロード('plugins/'.$this->code.'-1.0.0.tgz');
709
710
        $this->initialized = true;
711
712
        $this->I->see('プラグインをインストールしました。', PluginManagePage::完了メーッセージ);
713
714
        $this->検証();
715
716
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
717
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されていない');
718
        $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていない');
719
720
        return $this;
721
    }
722
723
    public function 有効化()
724
    {
725
        $this->ManagePage->独自プラグイン_有効化($this->code);
726
727
        $this->enabled = true;
728
729
        $this->検証();
730
731
        $this->em->refresh($this->Plugin);
732
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
733
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている');
734
735
        return $this;
736
    }
737
738
    public function 無効化()
739
    {
740
        $this->ManagePage->独自プラグイン_無効化($this->code);
741
742
        $this->enabled = false;
743
744
        $this->検証();
745
746
        $this->em->refresh($this->Plugin);
747
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
748
        $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている');
749
750
        return $this;
751
    }
752
753 View Code Duplication
    public function 削除()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
754
    {
755
        $this->ManagePage->独自プラグイン_削除($this->code);
756
757
        $this->initialized = false;
758
        $this->enabled = false;
759
760
        $this->I->see('プラグインを削除しました。', PluginManagePage::完了メーッセージ);
761
762
        $this->検証();
763
764
        $this->em->refresh($this->Plugin);
765
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
766
        $this->I->assertNull($this->Plugin, '削除されている');
767
768
        return $this;
769
    }
770
771
    public function アップデート()
772
    {
773
        $this->ManagePage->独自プラグイン_アップデート($this->code, 'plugins/'.$this->code.'-1.0.1.tgz');
774
775
        $this->検証();
776
777
        $this->em->refresh($this->Plugin);
778
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
779
        $this->I->assertEquals($this->enabled, $this->Plugin->isEnabled(), '有効/無効');
780
781
        return $this;
782
    }
783
}
784
785 View Code Duplication
class Horizon_Local extends Local_Plugin
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
786
{
787
    public function __construct(AcceptanceTester $I)
788
    {
789
        parent::__construct($I, 'Horizon');
790
        $this->tables[] = 'dtb_dash';
791
        $this->columns[] = 'dtb_cart.is_horizon';
792
        $this->columns[] = 'dtb_cart.dash_id';
793
        $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'src/Eccube/Entity/Cart';
794
    }
795
796
    public static function start(AcceptanceTester $I)
797
    {
798
        return new self($I);
799
    }
800
}
801
802
class Horizon_Store extends Store_Plugin
803
{
804
    public function __construct(AcceptanceTester $I)
805
    {
806
        parent::__construct($I, 'Horizon');
807
        $this->tables[] = 'dtb_dash';
808
        $this->columns[] = 'dtb_cart.is_horizon';
809
        $this->columns[] = 'dtb_cart.dash_id';
810
        $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'src/Eccube/Entity/Cart';
811
    }
812
813
    public static function start(AcceptanceTester $I)
814
    {
815
        $result = new self($I);
816
817
        return $result;
818
    }
819
820
    public function 依存されているのが有効なのに無効化()
821
    {
822
        $this->ManagePage->ストアプラグイン_無効化($this->code, '「ホライゾン」を無効にする前に、「エンペラー」を無効にしてください。');
823
824
        $this->検証();
825
826
        $this->em->refresh($this->Plugin);
827
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されているはず');
828
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されているはず');
829
830
        return $this;
831
    }
832
833
    public function 依存されているのが削除されていないのに削除()
834
    {
835
        $this->ManagePage->ストアプラグイン_削除($this->code, '「エンペラー」が「ホライゾン」に依存しているため削除できません。');
836
837
        $this->検証();
838
839
        $this->em->refresh($this->Plugin);
840
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
841
        $this->I->assertNotNull($this->Plugin, '削除されていない');
842
843
        return $this;
844
    }
845
}
846
847
class Emperor_Store extends Store_Plugin
848
{
849
    public function __construct(AcceptanceTester $I, Store_Plugin $dependency = null)
850
    {
851
        parent::__construct($I, 'Emperor', $dependency);
852
        $this->publishPlugin('Horizon-1.0.0.tgz');
853
        $this->tables[] = 'dtb_foo';
854
        $this->columns[] = 'dtb_cart.foo_id';
855
        $this->traits['\Plugin\Emperor\Entity\CartTrait'] = 'src/Eccube/Entity/Cart';
856
    }
857
858
    public static function start(AcceptanceTester $I, Store_Plugin $dependency = null)
859
    {
860
        return new self($I, $dependency);
861
    }
862
863
    public function アップデート()
864
    {
865
        $this->tables = ['dtb_bar'];
866
        $this->columns = ['dtb_cart.bar_id'];
867
        $this->traits['\Plugin\Emperor\Entity\Cart2Trait'] = 'src/Eccube/Entity/Cart';
868
869
        return parent::アップデート();
870
    }
871
872
    public function 依存より先に有効化()
873
    {
874
        $this->ManagePage->ストアプラグイン_有効化($this->code, '「ホライゾン」を先に有効化してください。');
875
876
        $this->検証();
877
878
        $this->em->refresh($this->Plugin);
879
        $this->I->assertFalse($this->Plugin->isInitialized(), '初期化されていないはず');
880
        $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていないはず');
881
882
        return $this;
883
    }
884
}
885
886 View Code Duplication
class Boomerang_Store extends Store_Plugin
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
887
{
888
    public function __construct(AcceptanceTester $I)
889
    {
890
        parent::__construct($I, 'Boomerang');
891
        $this->tables[] = 'dtb_bar';
892
        $this->columns[] = 'dtb_cart.is_boomerang';
893
        $this->columns[] = 'dtb_cart.bar_id';
894
        $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'src/Eccube/Entity/Cart';
895
    }
896
897
    public static function start(AcceptanceTester $I)
898
    {
899
        return new self($I);
900
    }
901
}
902
903
class Boomerang_Local extends Local_Plugin
904
{
905
    public function __construct(AcceptanceTester $I)
906
    {
907
        parent::__construct($I, 'Boomerang');
908
        $this->tables[] = 'dtb_bar';
909
        $this->columns[] = 'dtb_cart.is_boomerang';
910
        $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'src/Eccube/Entity/Cart';
911
    }
912
913
    public static function start(AcceptanceTester $I)
914
    {
915
        return new self($I);
916
    }
917
}
918