Failed Conditions
Push — dev/plugin-misc ( 983469...4f3c5e )
by Kiyotaka
06:38
created

Store_Plugin::publishPlugin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 8
rs 10
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 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
112
113
    public function test_install_update_remove_local(\AcceptanceTester $I)
114
    {
115
        Horizon_Local::start($I)
116
            ->インストール()
117
            ->アップデート()
118
            ->削除();
119
    }
120
121
    public function test_install_enable_disable_update_enable_disable_remove_local(\AcceptanceTester $I)
122
    {
123
        Horizon_Local::start($I)
124
            ->インストール()
125
            ->有効化()
126
            ->無効化()
127
            ->アップデート()
128
            ->有効化()
129
            ->無効化()
130
            ->削除();
131
    }
132
133
    public function test_install_enable_disable_update_enable_disable_remove_store(\AcceptanceTester $I)
134
    {
135
        Horizon_Store::start($I)
136
            ->インストール()
137
            ->有効化()
138
            ->無効化()
139
            ->アップデート()
140
            ->有効化()
141
            ->無効化()
142
            ->削除();
143
    }
144
145
    public function test_install_enable_update_disable_remove_store(\AcceptanceTester $I)
146
    {
147
        Horizon_Store::start($I)
148
            ->インストール()
149
            ->有効化()
150
            ->アップデート()
151
            ->無効化()
152
            ->削除();
153
    }
154
155
    public function test_install_enable_update_disable_remove_local(\AcceptanceTester $I)
156
    {
157
        Horizon_Local::start($I)
158
            ->インストール()
159
            ->有効化()
160
            ->アップデート()
161
            ->無効化()
162
            ->削除();
163
    }
164
165
    public function test_install_update_enable_disable_remove_local(\AcceptanceTester $I)
166
    {
167
        Horizon_Local::start($I)
168
            ->インストール()
169
            ->アップデート()
170
            ->有効化()
171
            ->無効化()
172
            ->削除();
173
    }
174
175
    public function test_install_update_enable_disable_remove_store(\AcceptanceTester $I)
176
    {
177
        Horizon_Store::start($I)
178
            ->インストール()
179
            ->アップデート()
180
            ->有効化()
181
            ->無効化()
182
            ->削除();
183
    }
184
185
    public function test_install_enable_enable(\AcceptanceTester $I)
186
    {
187
        Horizon_Store::start($I)
188
            ->インストール()
189
            ->新しいタブで開く()
190
            ->有効化()
191
            ->前のタブに戻る()
192
            ->既に有効なものを有効化();
193
    }
194
195
    public function test_install_disable_disable(\AcceptanceTester $I)
196
    {
197
        Horizon_Store::start($I)
198
            ->インストール()
199
            ->有効化()
200
            ->新しいタブで開く()
201
            ->無効化()
202
            ->前のタブに戻る()
203
            ->既に無効なものを無効化();
204
    }
205
206
    public function test_install_assets_local(\AcceptanceTester $I)
207
    {
208
        $this->publishPlugin('Assets-1.0.0.tgz');
209
210
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
211
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
212
213
        $I->assertFileNotExists($assetsPath);
214
        $I->assertFileNotExists($updatedPath);
215
216
        $ManagePage = PluginLocalInstallPage::go($I)->アップロード('plugins/Assets-1.0.0.tgz');
217
        $I->assertFileExists($assetsPath);
218
        $I->assertFileNotExists($updatedPath);
219
220
        $ManagePage->独自プラグイン_有効化('Assets');
221
        $I->assertFileExists($assetsPath);
222
        $I->assertFileNotExists($updatedPath);
223
224
        $ManagePage->独自プラグイン_無効化('Assets');
225
        $I->assertFileExists($assetsPath);
226
        $I->assertFileNotExists($updatedPath);
227
228
        $ManagePage->独自プラグイン_アップデート('Assets', 'plugins/Assets-1.0.1.tgz');
229
        $I->assertFileExists($assetsPath);
230
        $I->assertFileExists($updatedPath);
231
232
        $ManagePage->独自プラグイン_削除('Assets');
233
        $I->assertFileNotExists($assetsPath);
234
        $I->assertFileNotExists($updatedPath);
235
    }
236
237
    public function test_install_assets_store(\AcceptanceTester $I)
238
    {
239
        // 最初のバージョンを作成
240
        $this->publishPlugin('Assets-1.0.0.tgz');
241
242
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
243
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
244
        $I->assertFileNotExists($assetsPath);
245
        $I->assertFileNotExists($updatedPath);
246
247
        $ManagePage = PluginSearchPage::go($I)
248
            ->入手する('Assets')
249
            ->インストール();
250
        $I->assertFileNotExists($assetsPath);
251
        $I->assertFileNotExists($updatedPath);
252
253
        $ManagePage->ストアプラグイン_有効化('Assets');
254
        $I->assertFileExists($assetsPath);
255
        $I->assertFileNotExists($updatedPath);
256
257
        $ManagePage->ストアプラグイン_無効化('Assets');
258
        $I->assertFileExists($assetsPath);
259
        $I->assertFileNotExists($updatedPath);
260
261
        // 新しいバージョンを作成
262
        $this->publishPlugin('Assets-1.0.1.tgz');
263
264
        $I->reloadPage();
265
        $ManagePage->ストアプラグイン_アップデート('Assets')->アップデート();
266
        $I->assertFileExists($assetsPath);
267
        $I->assertFileExists($updatedPath);
268
269
        $ManagePage->ストアプラグイン_削除('Assets');
270
        $I->assertFileNotExists($assetsPath);
271
        $I->assertFileNotExists($updatedPath);
272
    }
273
274 View Code Duplication
    public function test_extend_same_table_store(\AcceptanceTester $I)
0 ignored issues
show
Duplication introduced by
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...
275
    {
276
        $Horizon = Horizon_Store::start($I);
277
        $Boomerang = Boomerang_Store::start($I);
278
279
        $Horizon->インストール()->有効化();
280
        $Boomerang->インストール()->有効化();
281
282
        $Horizon->検証()->無効化()->削除();
283
        $Boomerang->検証()->無効化()->削除();
284
    }
285
286 View Code Duplication
    public function test_extend_same_table_local(\AcceptanceTester $I)
0 ignored issues
show
Duplication introduced by
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...
287
    {
288
        $Horizon = Horizon_Local::start($I);
289
        $Boomerang = Boomerang_Local::start($I);
290
291
        $Horizon->インストール()->有効化();
292
        $Boomerang->インストール()->有効化();
293
294
        $Horizon->検証()->無効化()->削除();
295
        $Boomerang->検証()->無効化()->削除();
296
    }
297
298 View Code Duplication
    public function test_extend_same_table_crossed_store(\AcceptanceTester $I)
0 ignored issues
show
Duplication introduced by
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...
299
    {
300
        $Horizon = Horizon_Store::start($I);
301
        $Boomerang = Boomerang_Store::start($I);
302
303
        $Horizon->インストール()->有効化()->無効化();
304
        $Boomerang->インストール()->有効化();
305
306
        $Horizon->検証()->削除();
307
        $Boomerang->検証()->無効化()->削除();
308
    }
309
310 View Code Duplication
    public function test_extend_same_table_crossed_local(\AcceptanceTester $I)
0 ignored issues
show
Duplication introduced by
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...
311
    {
312
        $Horizon = Horizon_Local::start($I);
313
        $Boomerang = Boomerang_Local::start($I);
314
315
        $Horizon->インストール()->有効化()->無効化();
316
        $Boomerang->インストール()->有効化();
317
318
        $Horizon->検証()->削除();
319
        $Boomerang->検証()->無効化()->削除();
320
    }
321
322
    private function publishPlugin($fileName)
323
    {
324
        copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName);
325
    }
326
}
327
328
abstract class Abstract_Plugin
329
{
330
    /** @var AcceptanceTester */
331
    protected $I;
332
333
    /** @var EntityManager */
334
    protected $em;
335
336
    /** @var \Doctrine\DBAL\Connection */
337
    protected $conn;
338
339
    /** @var PluginRepository */
340
    protected $pluginRepository;
341
342
    /** @var EccubeConfig */
343
    protected $config;
344
345
    protected $initialized = false;
346
347
    protected $enabled = false;
348
349
    protected $removed = false;
350
351
    protected $tables = [];
352
353
    protected $columns = [];
354
355
    protected $traits = [];
356
357
    public function __construct(\AcceptanceTester $I)
358
    {
359
        $this->I = $I;
360
        $this->em = Fixtures::get('entityManager');
361
        $this->conn = $this->em->getConnection();
362
        $this->pluginRepository = $this->em->getRepository(Plugin::class);
363
        $this->config = Fixtures::get('config');
364
    }
365
366 View Code Duplication
    public function tableExists()
0 ignored issues
show
Duplication introduced by
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...
367
    {
368
        foreach ($this->tables as $table) {
369
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0;
0 ignored issues
show
Security introduced by
If $table can contain user-input, it is usually preferable to use a parameter placeholder like :paramName and pass the dynamic input as second argument array('param' => $table).

Instead of embedding dynamic parameters in SQL, Doctrine also allows you to pass them separately and insert a placeholder instead:

function findUser(Doctrine\DBAL\Connection $con, $email) {
    // Unsafe
    $con->executeQuery("SELECT * FROM users WHERE email = '".$email."'");

    // Safe
    $con->executeQuery(
        "SELECT * FROM users WHERE email = :email",
        array('email' => $email)
    );
}
Loading history...
370
            $this->I->assertTrue($exists, 'テーブルがあるはず '.$table);
371
        }
372
    }
373
374 View Code Duplication
    public function tableNotExists()
0 ignored issues
show
Duplication introduced by
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...
375
    {
376
        foreach ($this->tables as $table) {
377
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0;
0 ignored issues
show
Security introduced by
If $table can contain user-input, it is usually preferable to use a parameter placeholder like :paramName and pass the dynamic input as second argument array('param' => $table).

Instead of embedding dynamic parameters in SQL, Doctrine also allows you to pass them separately and insert a placeholder instead:

function findUser(Doctrine\DBAL\Connection $con, $email) {
    // Unsafe
    $con->executeQuery("SELECT * FROM users WHERE email = '".$email."'");

    // Safe
    $con->executeQuery(
        "SELECT * FROM users WHERE email = :email",
        array('email' => $email)
    );
}
Loading history...
378
            $this->I->assertFalse($exists, 'テーブルがないはず '.$table);
379
        }
380
    }
381
382 View Code Duplication
    public function columnExists()
0 ignored issues
show
Duplication introduced by
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...
383
    {
384
        foreach ($this->columns as $column) {
385
            list($tableName, $columnName) = explode('.', $column);
386
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1;
387
            $this->I->assertTrue($exists, 'カラムがあるはず '.$column);
388
        }
389
    }
390
391 View Code Duplication
    public function columnNotExists()
0 ignored issues
show
Duplication introduced by
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...
392
    {
393
        foreach ($this->columns as $column) {
394
            list($tableName, $columnName) = explode('.', $column);
395
            $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1;
396
            $this->I->assertFalse($exists, 'カラムがないはず '.$column);
397
        }
398
    }
399
400
    public function traitExists()
401
    {
402
        foreach ($this->traits as $trait => $target) {
403
            $this->I->assertContains($trait, file_get_contents($this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php'), 'Traitがあるはず '.$trait);
404
        }
405
    }
406
407
    public function traitNotExists()
408
    {
409
        foreach ($this->traits as $trait => $target) {
410
            $file = $this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php';
411
            if (file_exists($file)) {
412
                $this->I->assertNotContains($trait, file_get_contents($file), 'Traitがないはず '.$trait);
413
            } else {
414
                $this->I->assertTrue(true, 'Traitがないはず');
415
            }
416
        }
417
    }
418
419
    public function 新しいタブで開く()
420
    {
421
        $this->I->executeJS("window.open(location.href, 'other')");
422
        $this->I->switchToWindow('other');
423
        return $this;
424
    }
425
426
    public function 前のタブに戻る()
427
    {
428
        $this->I->switchToPreviousTab();
429
        return $this;
430
    }
431
432
    public function 検証()
433
    {
434
        if ($this->initialized) {
435
            $this->tableExists();
436
            $this->columnExists();
437
        } else {
438
            $this->tableNotExists();
439
            $this->columnNotExists();
440
        }
441
442
        if ($this->enabled) {
443
            $this->traitExists();
444
        } else {
445
            $this->traitNotExists();
446
        }
447
448
        return $this;
449
    }
450
}
451
452
class Store_Plugin extends Abstract_Plugin
453
{
454
    /** @var PluginManagePage */
455
    private $ManagePage;
456
457
    /** @var Plugin */
458
    private $Plugin;
459
460
    private $code;
461
462
    public function __construct(AcceptanceTester $I, $code)
463
    {
464
        parent::__construct($I);
465
        $this->code = $code;
466
        $this->publishPlugin($this->code.'-1.0.0.tgz');
467
    }
468
469
    public function インストール()
470
    {
471
        /*
472
         * インストール
473
         */
474
        $this->ManagePage = PluginSearchPage::go($this->I)
475
            ->入手する($this->code)
476
            ->インストール();
477
478
        $this->検証();
479
480
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
481
        $this->I->assertFalse($this->Plugin->isInitialized(), '初期化されていない');
482
        $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていない');
483
484
        return $this;
485
    }
486
487 View Code Duplication
    public function 有効化()
0 ignored issues
show
Duplication introduced by
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...
488
    {
489
        $this->ManagePage->ストアプラグイン_有効化($this->code);
490
491
        $this->initialized = true;
492
        $this->enabled = true;
493
494
        $this->検証();
495
496
        $this->em->refresh($this->Plugin);
497
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
498
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている');
499
        return $this;
500
    }
501
502
    public function 既に有効なものを有効化()
503
    {
504
        $this->ManagePage->ストアプラグイン_有効化($this->code, '既に有効です。');
505
506
        $this->initialized = true;
507
        $this->enabled = true;
508
509
        $this->検証();
510
511
        $this->em->refresh($this->Plugin);
512
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
513
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている');
514
515
516
        return $this;
517
    }
518
519
    public function 無効化()
520
    {
521
        $this->ManagePage->ストアプラグイン_無効化($this->code);
522
523
        $this->enabled = false;
524
525
        $this->検証();
526
527
        $this->em->refresh($this->Plugin);
528
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
529
        $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている');
530
531
        return $this;
532
    }
533
534
    public function 既に無効なものを無効化()
535
    {
536
        $this->ManagePage->ストアプラグイン_無効化($this->code, '既に無効です。');
537
538
        $this->enabled = false;
539
540
        $this->検証();
541
542
        $this->em->refresh($this->Plugin);
543
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
544
        $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている');
545
546
        return $this;
547
    }
548
549 View Code Duplication
    public function 削除()
0 ignored issues
show
Duplication introduced by
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...
550
    {
551
        $this->ManagePage->ストアプラグイン_削除($this->code);
552
553
        $this->initialized = false;
554
        $this->enabled = false;
555
556
        $this->検証();
557
558
        $this->em->refresh($this->Plugin);
559
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
560
        $this->I->assertNull($this->Plugin, '削除されている');
561
562
        return $this;
563
    }
564
565
    public function アップデート()
566
    {
567
        $this->publishPlugin($this->code.'-1.0.1.tgz');
568
569
        $this->I->reloadPage();
570
        $this->ManagePage->ストアプラグイン_アップデート($this->code)->アップデート();
571
572
        $this->initialized = true;
573
574
        $this->検証();
575
576
        $this->em->refresh($this->Plugin);
577
        $this->I->assertEquals($this->initialized, $this->Plugin->isInitialized(), '初期化');
578
        $this->I->assertEquals($this->enabled, $this->Plugin->isEnabled(), '有効/無効');
579
580
        return $this;
581
    }
582
583
    private function publishPlugin($fileName)
584
    {
585
        $published = copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName);
586
        $this->I->assertTrue($published, "公開できた ${fileName}");
587
        $output = [];
588
        exec("ls -ltra repos/", $output);
589
        echo implode(PHP_EOL, $output).PHP_EOL;
590
    }
591
}
592
593
class Local_Plugin extends Abstract_Plugin
594
{
595
    /** @var PluginManagePage */
596
    private $ManagePage;
597
598
    /** @var Plugin */
599
    private $Plugin;
600
601
    /** @var string */
602
    private $code;
603
604
    public function __construct(AcceptanceTester $I, $code)
605
    {
606
        parent::__construct($I);
607
        $this->code = $code;
608
    }
609
610
    public function インストール()
611
    {
612
        $this->ManagePage = PluginLocalInstallPage::go($this->I)
613
            ->アップロード('plugins/'.$this->code.'-1.0.0.tgz');
614
615
        $this->initialized = true;
616
617
        $this->I->see('プラグインをインストールしました。', PluginManagePage::完了メーッセージ);
618
619
        $this->検証();
620
621
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
622
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されていない');
623
        $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていない');
624
625
        return $this;
626
    }
627
628
    public function 有効化()
629
    {
630
        $this->ManagePage->独自プラグイン_有効化($this->code);
631
632
        $this->enabled = true;
633
634
        $this->検証();
635
636
        $this->em->refresh($this->Plugin);
637
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
638
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている');
639
        return $this;
640
    }
641
642
    public function 無効化()
643
    {
644
        $this->ManagePage->独自プラグイン_無効化($this->code);
645
646
        $this->enabled = false;
647
648
        $this->検証();
649
650
        $this->em->refresh($this->Plugin);
651
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
652
        $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている');
653
654
        return $this;
655
    }
656
657 View Code Duplication
    public function 削除()
0 ignored issues
show
Duplication introduced by
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...
658
    {
659
        $this->ManagePage->独自プラグイン_削除($this->code);
660
661
        $this->initialized = false;
662
        $this->enabled = false;
663
664
        $this->I->see('プラグインを削除しました。', PluginManagePage::完了メーッセージ);
665
666
        $this->検証();
667
668
        $this->em->refresh($this->Plugin);
669
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
670
        $this->I->assertNull($this->Plugin, '削除されている');
671
672
        return $this;
673
    }
674
675
    public function アップデート()
676
    {
677
        $this->ManagePage->独自プラグイン_アップデート($this->code, 'plugins/'.$this->code.'-1.0.1.tgz');
678
679
        $this->検証();
680
681
        $this->em->refresh($this->Plugin);
682
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている');
683
        $this->I->assertEquals($this->enabled, $this->Plugin->isEnabled(), '有効/無効');
684
685
        return $this;
686
    }
687
}
688
689 View Code Duplication
class Horizon_Local extends Local_Plugin
0 ignored issues
show
Duplication introduced by
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...
690
{
691
    public function __construct(AcceptanceTester $I)
692
    {
693
        parent::__construct($I, 'Horizon');
694
        $this->tables[] = 'dtb_dash';
695
        $this->columns[] = 'dtb_cart.is_horizon';
696
        $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'Cart';
697
    }
698
699
    public static function start(AcceptanceTester $I)
700
    {
701
        return new self($I);
702
    }
703
}
704
705 View Code Duplication
class Horizon_Store extends Store_Plugin
0 ignored issues
show
Duplication introduced by
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...
706
{
707
    public function __construct(AcceptanceTester $I)
708
    {
709
        parent::__construct($I, 'Horizon');
710
        $this->tables[] = 'dtb_dash';
711
        $this->columns[] = 'dtb_cart.is_horizon';
712
        $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'Cart';
713
    }
714
715
    public static function start(AcceptanceTester $I)
716
    {
717
        return new self($I);
718
    }
719
}
720
721 View Code Duplication
class Boomerang_Store extends Store_Plugin
0 ignored issues
show
Duplication introduced by
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...
722
{
723
    public function __construct(AcceptanceTester $I)
724
    {
725
        parent::__construct($I, 'Boomerang');
726
        $this->columns[] = 'dtb_cart.is_boomerang';
727
        $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'Cart';
728
    }
729
730
    public static function start(AcceptanceTester $I)
731
    {
732
        return new self($I);
733
    }
734
}
735
736 View Code Duplication
class Boomerang_Local extends Local_Plugin
0 ignored issues
show
Duplication introduced by
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...
737
{
738
    public function __construct(AcceptanceTester $I)
739
    {
740
        parent::__construct($I, 'Boomerang');
741
        $this->columns[] = 'dtb_cart.is_boomerang';
742
        $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'Cart';
743
    }
744
745
    public static function start(AcceptanceTester $I)
746
    {
747
        return new self($I);
748
    }
749
}