Completed
Push — dev/plugin-misc ( 77e831...c06838 )
by Kiyotaka
30:36
created

EA10PluginCest::install_remove_store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 29
rs 9.456
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 install_enable_disable_enable_disable_remove_store(\AcceptanceTester $I)
50
    {
51
        $this->publishPlugin('Horizon-1.0.0.tgz');
52
        /*
53
         * インストール
54
         */
55
        $ManagePage = PluginSearchPage::go($I)
56
            ->入手する('Horizon')
57
            ->インストール();
58
59
        $I->assertFalse($this->tableExists('dtb_dash'));
60
        $I->assertFalse($this->columnExists('dtb_cart', 'is_horizon'));
61
62
        $Plugin = $this->pluginRepository->findByCode('Horizon');
63
        $I->assertFalse($Plugin->isInitialized(), '初期化されていない');
64
        $I->assertFalse($Plugin->isEnabled(), '有効化されていない');
65
66
        /*
67
         * 有効化
68
         */
69
        $ManagePage->ストアプラグイン_有効化('Horizon');
70
71
        $I->assertTrue($this->tableExists('dtb_dash'));
72
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
73
74
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
75
        $I->assertTrue($Plugin->isInitialized(), '初期化されている');
76
        $I->assertTrue($Plugin->isEnabled(), '有効化されている');
77
78
        /*
79
         * 無効化
80
         */
81
        $ManagePage->ストアプラグイン_無効化('Horizon');
82
83
        $I->assertTrue($this->tableExists('dtb_dash'));
84
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
85
86
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
87
        $I->assertTrue($Plugin->isInitialized(), '初期化されている');
88
        $I->assertFalse($Plugin->isEnabled(), '無効化されている');
89
90
        /*
91
         * 再度有効化
92
         */
93
        $ManagePage->ストアプラグイン_有効化('Horizon');
94
95
        $I->assertTrue($this->tableExists('dtb_dash'));
96
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
97
98
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
99
        $I->assertTrue($Plugin->isInitialized(), '初期化されている');
100
        $I->assertTrue($Plugin->isEnabled(), '有効化されている');
101
102
        /*
103
         * 再度無効化
104
         */
105
        $ManagePage->ストアプラグイン_無効化('Horizon');
106
107
        $I->assertTrue($this->tableExists('dtb_dash'));
108
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
109
110
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
111
        $I->assertTrue($Plugin->isInitialized(), '初期化されている');
112
        $I->assertFalse($Plugin->isEnabled(), '無効化されている');
113
114
        /*
115
         * 削除
116
         */
117
        $ManagePage->ストアプラグイン_削除('Horizon');
118
119
        $I->assertFalse($this->tableExists('dtb_dash'));
120
        $I->assertFalse($this->columnExists('dtb_cart', 'is_horizon'));
121
122
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 62 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
123
        $Plugin = $this->pluginRepository->findByCode('Horizon');
124
        $I->assertNull($Plugin);
125
    }
126
127
    public function install_enable_disable_enable_disable_remove_local(\AcceptanceTester $I)
128
    {
129
        /*
130
         * インストール
131
         */
132
        $ManagePage = PluginLocalInstallPage::go($I)
133
            ->アップロード('plugins/Horizon-1.0.0.tgz');
134
135
        $I->see('プラグインをインストールしました。', PluginManagePage::完了メーッセージ);
136
137
        $I->assertTrue($this->tableExists('dtb_dash'));
138
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
139
140
        $Plugin = $this->pluginRepository->findByCode('Horizon');
141
        $I->assertTrue($Plugin->isInitialized(), '初期化されていない');
142
        $I->assertFalse($Plugin->isEnabled(), '有効化されていない');
143
144
        /*
145
         * 有効化
146
         */
147
        $ManagePage->独自プラグイン_有効化('Horizon');
148
149
        $I->assertTrue($this->tableExists('dtb_dash'));
150
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
151
152
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
153
        $I->assertTrue($Plugin->isInitialized(), '初期化されている');
154
        $I->assertTrue($Plugin->isEnabled(), '有効化されている');
155
156
        /*
157
         * 無効化
158
         */
159
        $ManagePage->独自プラグイン_無効化('Horizon');
160
161
        $I->assertTrue($this->tableExists('dtb_dash'));
162
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
163
164
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
165
        $I->assertTrue($Plugin->isInitialized(), '初期化されている');
166
        $I->assertFalse($Plugin->isEnabled(), '無効化されている');
167
168
        /*
169
         * 再度有効化
170
        */
171
        $ManagePage->独自プラグイン_有効化('Horizon');
172
173
        $I->assertTrue($this->tableExists('dtb_dash'));
174
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
175
176
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
177
        $I->assertTrue($Plugin->isInitialized(), '初期化されている');
178
        $I->assertTrue($Plugin->isEnabled(), '有効化されている');
179
180
        /*
181
         * 再度無効化
182
         */
183
        $ManagePage->独自プラグイン_無効化('Horizon');
184
185
        $I->assertTrue($this->tableExists('dtb_dash'));
186
        $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon'));
187
188
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
189
        $I->assertTrue($Plugin->isInitialized(), '初期化されている');
190
        $I->assertFalse($Plugin->isEnabled(), '無効化されている');
191
192
        /*
193
         * 削除
194
         */
195
        $ManagePage->独自プラグイン_削除('Horizon');
196
197
        $I->see('プラグインを削除しました。', PluginManagePage::完了メーッセージ);
198
199
        $I->assertFalse($this->tableExists('dtb_dash'));
200
        $I->assertFalse($this->columnExists('dtb_cart', 'is_horizon'));
201
202
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 140 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

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

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

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

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
265
        $Plugin = $this->pluginRepository->findByCode('Horizon');
266
        $I->assertNull($Plugin);
267
    }
268
269
    public function install_update_remove_store(\AcceptanceTester $I)
270
    {
271
        // 最初のバージョンを作成
272
        $this->publishPlugin('Horizon-1.0.0.tgz');
273
274
        /*
275
         * インストール
276
         */
277
        $ManagePage = PluginSearchPage::go($I)
278
            ->入手する('Horizon')
279
            ->インストール();
280
281
        $Plugin = $this->pluginRepository->findByCode('Horizon');
282
        $I->assertFalse($Plugin->isInitialized());
283
        $I->assertFalse($Plugin->isEnabled());
284
285
        // 新しいバージョンを作成
286
        $this->publishPlugin('Horizon-1.0.1.tgz');
287
288
        /*
289
         * アップデート
290
         */
291
        $I->reloadPage();
292
        $ManagePage->ストアプラグイン_アップデート('Horizon')->アップデート();
293
294
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 281 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
295
        $I->assertFalse($Plugin->isInitialized());
296
        $I->assertFalse($Plugin->isEnabled());
297
298
        /*
299
         * 削除
300
         */
301
        $ManagePage->ストアプラグイン_削除('Horizon');
302
303
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 281 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
304
        $Plugin = $this->pluginRepository->findByCode('Horizon');
305
        $I->assertNull($Plugin);
306
    }
307
308
309
310
    public function install_update_remove_local(\AcceptanceTester $I)
311
    {
312
        /*
313
         * インストール
314
         */
315
        $ManagePage = PluginLocalInstallPage::go($I)
316
            ->アップロード('plugins/Horizon-1.0.0.tgz');
317
318
        $Plugin = $this->pluginRepository->findByCode('Horizon');
319
        $I->assertTrue($Plugin->isInitialized());
320
        $I->assertFalse($Plugin->isEnabled());
321
322
        /*
323
         * アップデート
324
         */
325
        $ManagePage->独自プラグイン_アップデート('Horizon', 'plugins/Horizon-1.0.1.tgz');
326
327
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 318 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
328
        $I->assertTrue($Plugin->isInitialized());
329
        $I->assertFalse($Plugin->isEnabled());
330
331
        /*
332
         * 削除
333
         */
334
        $ManagePage->独自プラグイン_削除('Horizon');
335
336
        $this->em->refresh($Plugin);
0 ignored issues
show
Bug introduced by
It seems like $Plugin defined by $this->pluginRepository->findByCode('Horizon') on line 318 can be null; however, Doctrine\ORM\EntityManager::refresh() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
337
        $Plugin = $this->pluginRepository->findByCode('Horizon');
338
        $I->assertNull($Plugin);
339
    }
340
341
    public function install_assets_local(\AcceptanceTester $I)
342
    {
343
        $this->publishPlugin('Assets-1.0.0.tgz');
344
345
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
346
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
347
348
        $I->assertFileNotExists($assetsPath);
349
        $I->assertFileNotExists($updatedPath);
350
351
        $ManagePage = PluginLocalInstallPage::go($I)->アップロード('plugins/Assets-1.0.0.tgz');
352
        $I->assertFileExists($assetsPath);
353
        $I->assertFileNotExists($updatedPath);
354
355
        $ManagePage->独自プラグイン_有効化('Assets');
356
        $I->assertFileExists($assetsPath);
357
        $I->assertFileNotExists($updatedPath);
358
359
        $ManagePage->独自プラグイン_無効化('Assets');
360
        $I->assertFileExists($assetsPath);
361
        $I->assertFileNotExists($updatedPath);
362
363
        $ManagePage->独自プラグイン_アップデート('Assets', 'plugins/Assets-1.0.1.tgz');
364
        $I->assertFileExists($assetsPath);
365
        $I->assertFileExists($updatedPath);
366
367
        $ManagePage->独自プラグイン_削除('Assets');
368
        $I->assertFileNotExists($assetsPath);
369
        $I->assertFileNotExists($updatedPath);
370
    }
371
372
    public function install_assets_store(\AcceptanceTester $I)
373
    {
374
        // 最初のバージョンを作成
375
        $this->publishPlugin('Assets-1.0.0.tgz');
376
377
        $assetsPath = $this->config['plugin_html_realdir'].'/Assets/assets/assets.js';
378
        $updatedPath = $this->config['plugin_html_realdir'].'/Assets/assets/updated.js';
379
        $I->assertFileNotExists($assetsPath);
380
        $I->assertFileNotExists($updatedPath);
381
382
        $ManagePage = PluginSearchPage::go($I)
383
            ->入手する('Assets')
384
            ->インストール();
385
        $I->assertFileNotExists($assetsPath);
386
        $I->assertFileNotExists($updatedPath);
387
388
        $ManagePage->ストアプラグイン_有効化('Assets');
389
        $I->assertFileExists($assetsPath);
390
        $I->assertFileNotExists($updatedPath);
391
392
        $ManagePage->ストアプラグイン_無効化('Assets');
393
        $I->assertFileExists($assetsPath);
394
        $I->assertFileNotExists($updatedPath);
395
396
        // 新しいバージョンを作成
397
        $this->publishPlugin('Assets-1.0.1.tgz');
398
399
        $I->reloadPage();
400
        $ManagePage->ストアプラグイン_アップデート('Assets')->アップデート();
401
        $I->assertFileExists($assetsPath);
402
        $I->assertFileExists($updatedPath);
403
404
        $ManagePage->ストアプラグイン_無効化('Assets');
405
        $I->assertFileExists($assetsPath);
406
        $I->assertFileExists($updatedPath);
407
408
        $ManagePage->ストアプラグイン_削除('Assets');
409
        $I->assertFileNotExists($assetsPath);
410
        $I->assertFileNotExists($updatedPath);
411
    }
412
413
    private function publishPlugin($fileName)
414
    {
415
        copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName);
416
    }
417
418
    private function tableExists($tableName)
419
    {
420
        return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}';")->fetch()['count'] > 0;
421
    }
422
423
    private function columnExists($tableName, $columnName)
424
    {
425
        return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1;
426
    }
427
}
428