Issues (623)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

codeception/acceptance/EA10PluginCest.php (18 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;
0 ignored issues
show
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...
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;
0 ignored issues
show
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...
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 function アップデート()
797
    {
798
        // アップデートで新たしいカラムが追加される
799
        $this->columns[] = 'dtb_dash.new_column';
800
        return parent::アップデート();
801
    }
802
803
    public static function start(AcceptanceTester $I)
804
    {
805
        return new self($I);
806
    }
807
}
808
809
class Horizon_Store extends Store_Plugin
810
{
811
    public function __construct(AcceptanceTester $I)
812
    {
813
        parent::__construct($I, 'Horizon');
814
        $this->tables[] = 'dtb_dash';
815
        $this->columns[] = 'dtb_cart.is_horizon';
816
        $this->columns[] = 'dtb_cart.dash_id';
817
        $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'src/Eccube/Entity/Cart';
818
    }
819
820
    public function アップデート()
821
    {
822
        // アップデートで新たしいカラムが追加される
823
        $this->columns[] = 'dtb_dash.new_column';
824
        return parent::アップデート();
825
    }
826
827
    public static function start(AcceptanceTester $I)
828
    {
829
        $result = new self($I);
830
831
        return $result;
832
    }
833
834
    public function 依存されているのが有効なのに無効化()
835
    {
836
        $this->ManagePage->ストアプラグイン_無効化($this->code, '「ホライゾン」を無効にする前に、「エンペラー」を無効にしてください。');
837
838
        $this->検証();
839
840
        $this->em->refresh($this->Plugin);
841
        $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されているはず');
842
        $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されているはず');
843
844
        return $this;
845
    }
846
847
    public function 依存されているのが削除されていないのに削除()
848
    {
849
        $this->ManagePage->ストアプラグイン_削除($this->code, '「エンペラー」が「ホライゾン」に依存しているため削除できません。');
850
851
        $this->検証();
852
853
        $this->em->refresh($this->Plugin);
854
        $this->Plugin = $this->pluginRepository->findByCode($this->code);
855
        $this->I->assertNotNull($this->Plugin, '削除されていない');
856
857
        return $this;
858
    }
859
}
860
861
class Emperor_Store extends Store_Plugin
862
{
863
    public function __construct(AcceptanceTester $I, Store_Plugin $dependency = null)
864
    {
865
        parent::__construct($I, 'Emperor', $dependency);
866
        $this->publishPlugin('Horizon-1.0.0.tgz');
867
        $this->tables[] = 'dtb_foo';
868
        $this->columns[] = 'dtb_cart.foo_id';
869
        $this->traits['\Plugin\Emperor\Entity\CartTrait'] = 'src/Eccube/Entity/Cart';
870
    }
871
872
    public static function start(AcceptanceTester $I, Store_Plugin $dependency = null)
873
    {
874
        return new self($I, $dependency);
875
    }
876
877
    public function アップデート()
878
    {
879
        $this->tables = ['dtb_bar'];
880
        $this->columns = ['dtb_cart.bar_id'];
881
        $this->traits['\Plugin\Emperor\Entity\Cart2Trait'] = 'src/Eccube/Entity/Cart';
882
883
        return parent::アップデート();
884
    }
885
886
    public function 依存より先に有効化()
887
    {
888
        $this->ManagePage->ストアプラグイン_有効化($this->code, '「ホライゾン」を先に有効化してください。');
889
890
        $this->検証();
891
892
        $this->em->refresh($this->Plugin);
893
        $this->I->assertFalse($this->Plugin->isInitialized(), '初期化されていないはず');
894
        $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていないはず');
895
896
        return $this;
897
    }
898
}
899
900 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...
901
{
902
    public function __construct(AcceptanceTester $I)
903
    {
904
        parent::__construct($I, 'Boomerang');
905
        $this->tables[] = 'dtb_bar';
906
        $this->columns[] = 'dtb_cart.is_boomerang';
907
        $this->columns[] = 'dtb_cart.bar_id';
908
        $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'src/Eccube/Entity/Cart';
909
    }
910
911
    public static function start(AcceptanceTester $I)
912
    {
913
        return new self($I);
914
    }
915
}
916
917
class Boomerang_Local extends Local_Plugin
918
{
919
    public function __construct(AcceptanceTester $I)
920
    {
921
        parent::__construct($I, 'Boomerang');
922
        $this->tables[] = 'dtb_bar';
923
        $this->columns[] = 'dtb_cart.is_boomerang';
924
        $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'src/Eccube/Entity/Cart';
925
    }
926
927
    public static function start(AcceptanceTester $I)
928
    {
929
        return new self($I);
930
    }
931
}
932