Completed
Push — 4.0 ( fb8a1d...7a5a53 )
by
unknown
05:18 queued 11s
created

codeception/acceptance/EA10PluginCest.php (2 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
153
    public function test_install_enable_update_disable_remove_local(\AcceptanceTester $I)
154
    {
155
        Horizon_Local::start($I)
156
            ->インストール()
157
            ->有効化()
158
            ->アップデート()
159
            ->無効化()
160
            ->削除();
161
    }
162
163
    public function test_install_update_enable_disable_remove_local(\AcceptanceTester $I)
164
    {
165
        Horizon_Local::start($I)
166
            ->インストール()
167
            ->アップデート()
168
            ->有効化()
169
            ->無効化()
170
            ->削除();
171
    }
172
173
    public function test_install_update_enable_disable_remove_store(\AcceptanceTester $I)
174
    {
175
        Horizon_Store::start($I)
176
            ->インストール()
177
            ->アップデート()
178
            ->有効化()
179
            ->無効化()
180
            ->削除();
181
    }
182
183
    public function test_install_enable_enable(\AcceptanceTester $I)
184
    {
185
        Horizon_Store::start($I)
186
            ->インストール()
187
            ->新しいタブで開く()
188
            ->有効化()
189
            ->前のタブに戻る()
190
            ->既に有効なものを有効化();
191
    }
192
193
    public function test_install_disable_disable(\AcceptanceTester $I)
194
    {
195
        Horizon_Store::start($I)
196
            ->インストール()
197
            ->有効化()
198
            ->新しいタブで開く()
199
            ->無効化()
200
            ->前のタブに戻る()
201
            ->既に無効なものを無効化();
202
    }
203
204
    public function test_install_assets_local(\AcceptanceTester $I)
205
    {
206
        $this->publishPlugin('Assets-1.0.0.tgz');
207
208
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
209
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
210
211
        $I->assertFileNotExists($assetsPath);
212
        $I->assertFileNotExists($updatedPath);
213
214
        $ManagePage = PluginLocalInstallPage::go($I)->アップロード('plugins/Assets-1.0.0.tgz');
215
        $I->assertFileExists($assetsPath);
216
        $I->assertFileNotExists($updatedPath);
217
218
        $ManagePage->独自プラグイン_有効化('Assets');
219
        $I->assertFileExists($assetsPath);
220
        $I->assertFileNotExists($updatedPath);
221
222
        $ManagePage->独自プラグイン_無効化('Assets');
223
        $I->assertFileExists($assetsPath);
224
        $I->assertFileNotExists($updatedPath);
225
226
        $ManagePage->独自プラグイン_アップデート('Assets', 'plugins/Assets-1.0.1.tgz');
227
        $I->assertFileExists($assetsPath);
228
        $I->assertFileExists($updatedPath);
229
230
        $ManagePage->独自プラグイン_削除('Assets');
231
        $I->assertFileNotExists($assetsPath);
232
        $I->assertFileNotExists($updatedPath);
233
    }
234
235
    public function test_install_assets_store(\AcceptanceTester $I)
236
    {
237
        // 最初のバージョンを作成
238
        $this->publishPlugin('Assets-1.0.0.tgz');
239
240
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
241
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
242
        $I->assertFileNotExists($assetsPath);
243
        $I->assertFileNotExists($updatedPath);
244
245
        $ManagePage = PluginSearchPage::go($I)
246
            ->入手する('Assets')
247
            ->インストール();
248
        $I->assertFileNotExists($assetsPath);
249
        $I->assertFileNotExists($updatedPath);
250
251
        $ManagePage->ストアプラグイン_有効化('Assets');
252
        $I->assertFileExists($assetsPath);
253
        $I->assertFileNotExists($updatedPath);
254
255
        $ManagePage->ストアプラグイン_無効化('Assets');
256
        $I->assertFileExists($assetsPath);
257
        $I->assertFileNotExists($updatedPath);
258
259
        // 新しいバージョンを作成
260
        $this->publishPlugin('Assets-1.0.1.tgz');
261
262
        $I->reloadPage();
263
        $ManagePage->ストアプラグイン_アップデート('Assets')->アップデート();
264
        $I->assertFileExists($assetsPath);
265
        $I->assertFileExists($updatedPath);
266
267
        $ManagePage->ストアプラグイン_削除('Assets');
268
        $I->assertFileNotExists($assetsPath);
269
        $I->assertFileNotExists($updatedPath);
270
    }
271
272 View Code Duplication
    public function test_extend_same_table_store(\AcceptanceTester $I)
273
    {
274
        $Horizon = Horizon_Store::start($I);
275
        $Boomerang = Boomerang_Store::start($I);
276
277
        $Horizon->インストール()->有効化();
278
        $Boomerang->インストール()->有効化();
279
280
        $Horizon->検証()->無効化()->削除();
281
        $Boomerang->検証()->無効化()->削除();
282
    }
283
284 View Code Duplication
    public function test_extend_same_table_disabled_remove_store(\AcceptanceTester $I)
285
    {
286
        $Horizon = Horizon_Store::start($I);
287
        $Boomerang = Boomerang_Store::start($I);
288
289
        $Horizon->インストール()->有効化()->無効化();
290
        $Boomerang->インストール()->有効化()->無効化();
291
292
        $Horizon->検証()->削除();
293
        $Boomerang->検証()->削除();
294
    }
295
296 View Code Duplication
    public function test_extend_same_table_local(\AcceptanceTester $I)
297
    {
298
        $Horizon = Horizon_Local::start($I);
299
        $Boomerang = Boomerang_Local::start($I);
300
301
        $Horizon->インストール()->有効化();
302
        $Boomerang->インストール()->有効化();
303
304
        $Horizon->検証()->無効化()->削除();
305
        $Boomerang->検証()->無効化()->削除();
306
    }
307
308 View Code Duplication
    public function test_extend_same_table_disabled_remove_local(\AcceptanceTester $I)
309
    {
310
        $Horizon = Horizon_Local::start($I);
311
        $Boomerang = Boomerang_Local::start($I);
312
313
        $Horizon->インストール()->有効化()->無効化();
314
        $Boomerang->インストール()->有効化()->無効化();
315
316
        $Horizon->検証()->削除();
317
        $Boomerang->検証()->削除();
318
    }
319
320 View Code Duplication
    public function test_extend_same_table_crossed_store(\AcceptanceTester $I)
321
    {
322
        $Horizon = Horizon_Store::start($I);
323
        $Boomerang = Boomerang_Store::start($I);
324
325
        $Horizon->インストール()->有効化()->無効化();
326
        $Boomerang->インストール()->有効化();
327
328
        $Horizon->検証()->削除();
329
        $Boomerang->検証()->無効化()->削除();
330
    }
331
332 View Code Duplication
    public function test_extend_same_table_crossed_local(\AcceptanceTester $I)
333
    {
334
        $Horizon = Horizon_Local::start($I);
335
        $Boomerang = Boomerang_Local::start($I);
336
337
        $Horizon->インストール()->有効化()->無効化();
338
        $Boomerang->インストール()->有効化();
339
340
        $Horizon->検証()->削除();
341
        $Boomerang->検証()->無効化()->削除();
342
    }
343
344
    public function test_dependency_each_install_plugin(\AcceptanceTester $I)
345
    {
346
        $Horizon = Horizon_Store::start($I);
347
        $Emperor = Emperor_Store::start($I);
348
349
        $Horizon->インストール()->有効化();
350
        $Emperor->インストール()->有効化();
351
    }
352
353
    public function test_dependency_plugin_install(\AcceptanceTester $I)
354
    {
355
        $Horizon = Horizon_Store::start($I);
356
        $Emperor = Emperor_Store::start($I, $Horizon);
357
358
        $Emperor->インストール()
359
            ->依存より先に有効化();
360
361
        $Horizon->有効化();
362
363
        $Emperor->有効化();
364
365
        $Horizon->依存されているのが有効なのに無効化();
366
        $Emperor->無効化();
367
        $Horizon->無効化();
368
369
        $Horizon->依存されているのが削除されていないのに削除();
370
        $Emperor->削除();
371
        $Horizon->削除();
372
    }
373
374
    public function test_dependency_plugin_update(\AcceptanceTester $I)
375
    {
376
        $Horizon = Horizon_Store::start($I);
377
        $Emperor = Emperor_Store::start($I, $Horizon);
378
379
        $Emperor->インストール();
380
381
        $Horizon->検証()
382
            ->有効化();
383
384
        $Emperor
385
            ->有効化()
386
            ->無効化()
387
            ->アップデート();
388
389
        $Horizon->検証();
390
    }
391
392
    public function test_install_error(\AcceptanceTester $I)
393
    {
394
        $this->publishPlugin('InstallError.tgz');
395
        $Horizon = Horizon_Store::start($I);
396
397
        PluginSearchPage::go($I)
398
            ->入手する('InstallError')
399
            ->インストール('システムエラーが発生しました。');
400
401
        // エラー後に他のプラグインがインストールできる
402
        $Horizon->インストール();
403
    }
404
405
    private function publishPlugin($fileName)
406
    {
407
        copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName);
408
    }
409
}
410
411
abstract class Abstract_Plugin
412
{
413
    /** @var AcceptanceTester */
414
    protected $I;
415
416
    /** @var EntityManager */
417
    protected $em;
418
419
    /** @var \Doctrine\DBAL\Connection */
420
    protected $conn;
421
422
    /** @var PluginRepository */
423
    protected $pluginRepository;
424
425
    /** @var EccubeConfig */
426
    protected $config;
427
428
    protected $initialized = false;
429
430
    protected $enabled = false;
431
432
    protected $removed = false;
433
434
    protected $tables = [];
435
436
    protected $columns = [];
437
438
    protected $traits = [];
439
440 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...
441
    {
442
        $this->I = $I;
443
        $this->em = Fixtures::get('entityManager');
444
        $this->conn = $this->em->getConnection();
445
        $this->pluginRepository = $this->em->getRepository(Plugin::class);
446
        $this->config = Fixtures::get('config');
447
    }
448
449 View Code Duplication
    public function tableExists()
450
    {
451
        foreach ($this->tables as $table) {
452
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0;
453
            $this->I->assertTrue($exists, 'テーブルがあるはず '.$table);
454
        }
455
    }
456
457 View Code Duplication
    public function tableNotExists()
458
    {
459
        foreach ($this->tables as $table) {
460
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0;
461
            $this->I->assertFalse($exists, 'テーブルがないはず '.$table);
462
        }
463
    }
464
465 View Code Duplication
    public function columnExists()
466
    {
467
        foreach ($this->columns as $column) {
468
            list($tableName, $columnName) = explode('.', $column);
469
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1;
470
            $this->I->assertTrue($exists, 'カラムがあるはず '.$column);
471
        }
472
    }
473
474 View Code Duplication
    public function columnNotExists()
475
    {
476
        foreach ($this->columns as $column) {
477
            list($tableName, $columnName) = explode('.', $column);
478
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1;
479
            $this->I->assertFalse($exists, 'カラムがないはず '.$column);
480
        }
481
    }
482
483
    public function traitExists()
484
    {
485
        foreach ($this->traits as $trait => $target) {
486
            $this->I->assertContains($trait, file_get_contents($this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php'), 'Traitがあるはず '.$trait);
487
        }
488
    }
489
490
    public function traitNotExists()
491
    {
492
        foreach ($this->traits as $trait => $target) {
493
            $file = $this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php';
494
            if (file_exists($file)) {
495
                $this->I->assertNotContains($trait, file_get_contents($file), 'Traitがないはず '.$trait);
496
            } else {
497
                $this->I->assertTrue(true, 'Traitがないはず');
498
            }
499
        }
500
    }
501
502
    public function 新しいタブで開く()
503
    {
504
        $this->I->executeJS("window.open(location.href, 'other')");
505
        $this->I->switchToWindow('other');
506
507
        return $this;
508
    }
509
510
    public function 前のタブに戻る()
511
    {
512
        $this->I->switchToPreviousTab();
513
514
        return $this;
515
    }
516
517
    public function 検証()
518
    {
519
        if ($this->initialized) {
520
            $this->tableExists();
521
            $this->columnExists();
522
        } else {
523
            $this->tableNotExists();
524
            $this->columnNotExists();
525
        }
526
527
        if ($this->enabled) {
528
            $this->traitExists();
529
        } else {
530
            $this->traitNotExists();
531
        }
532
533
        return $this;
534
    }
535
}
536
537
class Store_Plugin extends Abstract_Plugin
538
{
539
    /** @var PluginManagePage */
540
    protected $ManagePage;
541
542
    /** @var Plugin */
543
    protected $Plugin;
544
545
    protected $code;
546
547
    /** @var Store_Plugin */
548
    protected $dependency;
549
550
    public function __construct(AcceptanceTester $I, $code, Store_Plugin $dependency = null)
551
    {
552
        parent::__construct($I);
553
        $this->code = $code;
554
        $this->publishPlugin($this->code.'-1.0.0.tgz');
555
        if ($dependency) {
556
            $this->dependency = $dependency;
557
            $this->ManagePage = $dependency->ManagePage;
558
            $this->Plugin = $this->pluginRepository->findByCode($code);
559
        }
560
    }
561
562
    public function インストール()
563
    {
564
        /*
565
         * インストール
566
         */
567
        $this->ManagePage = PluginSearchPage::go($this->I)
568
            ->入手する($this->code)
569
            ->インストール();
570
571
        $this->検証();
572
573
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
574
        $this->I->assertFalse($this->Plugin->isInitialized(), '初期化されていない');
575
        $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていない');
576
577
        if ($this->dependency) {
578
            $this->dependency->ManagePage = $this->ManagePage;
579
            $this->dependency->Plugin = $this->pluginRepository->findByCode($this->dependency->code);
580
        }
581
582
        return $this;
583
    }
584
585
    public function 有効化()
586
    {
587
        $this->ManagePage->ストアプラグイン_有効化($this->code);
588
589
        $this->initialized = true;
590
        $this->enabled = true;
591
592
        $this->検証();
593
594
        $this->em->refresh($this->Plugin);
595
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
596
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている');
597
598
        return $this;
599
    }
600
601
    public function 既に有効なものを有効化()
602
    {
603
        $this->ManagePage->ストアプラグイン_有効化($this->code, '既に有効です。');
604
605
        $this->initialized = true;
606
        $this->enabled = true;
607
608
        $this->検証();
609
610
        $this->em->refresh($this->Plugin);
611
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
612
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている');
613
614
        return $this;
615
    }
616
617
    public function 無効化()
618
    {
619
        $this->ManagePage->ストアプラグイン_無効化($this->code);
620
621
        $this->enabled = false;
622
623
        $this->検証();
624
625
        $this->em->refresh($this->Plugin);
626
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
627
        $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている');
628
629
        return $this;
630
    }
631
632
    public function 既に無効なものを無効化()
633
    {
634
        $this->ManagePage->ストアプラグイン_無効化($this->code, '既に無効です。');
635
636
        $this->enabled = false;
637
638
        $this->検証();
639
640
        $this->em->refresh($this->Plugin);
641
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
642
        $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている');
643
644
        return $this;
645
    }
646
647 View Code Duplication
    public function 削除()
648
    {
649
        $this->ManagePage->ストアプラグイン_削除($this->code);
650
651
        $this->initialized = false;
652
        $this->enabled = false;
653
654
        $this->検証();
655
656
        $this->em->refresh($this->Plugin);
657
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
658
        $this->I->assertNull($this->Plugin, '削除されている');
659
660
        return $this;
661
    }
662
663
    public function アップデート()
664
    {
665
        $this->publishPlugin($this->code.'-1.0.1.tgz');
666
667
        $this->I->reloadPage();
668
        $this->ManagePage->ストアプラグイン_アップデート($this->code)->アップデート();
669
670
        $this->initialized = true;
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 削除()
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
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'] = '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'] = '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'] = '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'] = '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
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'] = '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'] = 'Cart';
911
    }
912
913
    public static function start(AcceptanceTester $I)
914
    {
915
        return new self($I);
916
    }
917
}
918