kiy0taka /
ec-cube
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) 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 | View Code Duplication | 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) |
|
| 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) |
|
| 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) |
|
| 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) |
|
| 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 | public function test_dependency_each_install_plugin(\AcceptanceTester $I) |
||
| 323 | { |
||
| 324 | $Horizon = Horizon_Store::start($I); |
||
| 325 | $Emperor = Emperor_Store::start($I); |
||
| 326 | |||
| 327 | $Horizon->インストール()->有効化(); |
||
| 328 | $Emperor->インストール()->有効化(); |
||
| 329 | } |
||
| 330 | |||
| 331 | public function test_dependency_plugin(\AcceptanceTester $I) |
||
| 332 | { |
||
| 333 | $Emperor = Emperor_Store::start($I); |
||
| 334 | $Horizon = Horizon_Store::start($I, $Emperor); |
||
| 335 | |||
| 336 | $Emperor->インストール() |
||
| 337 | ->依存より先に有効化(); |
||
| 338 | |||
| 339 | $Horizon->有効化(); |
||
| 340 | |||
| 341 | $Emperor->有効化(); |
||
| 342 | |||
| 343 | $Horizon->依存されているのが有効なのに無効化(); |
||
| 344 | $Emperor->無効化(); |
||
| 345 | $Horizon->無効化(); |
||
| 346 | |||
| 347 | $Horizon->依存されているのが削除されていないのに削除(); |
||
| 348 | $Emperor->削除(); |
||
| 349 | $Horizon->削除(); |
||
| 350 | } |
||
| 351 | |||
| 352 | public function test_dependency_plugin_update(\AcceptanceTester $I) |
||
| 353 | { |
||
| 354 | $Emperor = Emperor_Store::start($I); |
||
| 355 | $Horizon = Horizon_Store::start($I, $Emperor); |
||
| 356 | |||
| 357 | $Emperor->インストール(); |
||
| 358 | $Horizon->検証()->有効化(); |
||
| 359 | |||
| 360 | $Emperor |
||
| 361 | ->有効化() |
||
| 362 | ->無効化() |
||
| 363 | ->アップデート(); |
||
| 364 | |||
| 365 | $Horizon->検証(); |
||
| 366 | } |
||
| 367 | |||
| 368 | private function publishPlugin($fileName) |
||
| 369 | { |
||
| 370 | copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName); |
||
| 371 | } |
||
| 372 | } |
||
| 373 | |||
| 374 | abstract class Abstract_Plugin |
||
| 375 | { |
||
| 376 | /** @var AcceptanceTester */ |
||
| 377 | protected $I; |
||
| 378 | |||
| 379 | /** @var EntityManager */ |
||
| 380 | protected $em; |
||
| 381 | |||
| 382 | /** @var \Doctrine\DBAL\Connection */ |
||
| 383 | protected $conn; |
||
| 384 | |||
| 385 | /** @var PluginRepository */ |
||
| 386 | protected $pluginRepository; |
||
| 387 | |||
| 388 | /** @var EccubeConfig */ |
||
| 389 | protected $config; |
||
| 390 | |||
| 391 | protected $initialized = false; |
||
| 392 | |||
| 393 | protected $enabled = false; |
||
| 394 | |||
| 395 | protected $removed = false; |
||
| 396 | |||
| 397 | protected $tables = []; |
||
| 398 | |||
| 399 | protected $columns = []; |
||
| 400 | |||
| 401 | protected $traits = []; |
||
| 402 | |||
| 403 | View Code Duplication | public function __construct(\AcceptanceTester $I) |
|
| 404 | { |
||
| 405 | $this->I = $I; |
||
| 406 | $this->em = Fixtures::get('entityManager'); |
||
| 407 | $this->conn = $this->em->getConnection(); |
||
| 408 | $this->pluginRepository = $this->em->getRepository(Plugin::class); |
||
| 409 | $this->config = Fixtures::get('config'); |
||
| 410 | } |
||
| 411 | |||
| 412 | View Code Duplication | public function tableExists() |
|
| 413 | { |
||
| 414 | foreach ($this->tables as $table) { |
||
| 415 | $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0; |
||
| 416 | $this->I->assertTrue($exists, 'テーブルがあるはず '.$table); |
||
| 417 | } |
||
| 418 | } |
||
| 419 | |||
| 420 | View Code Duplication | public function tableNotExists() |
|
| 421 | { |
||
| 422 | foreach ($this->tables as $table) { |
||
| 423 | $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0; |
||
| 424 | $this->I->assertFalse($exists, 'テーブルがないはず '.$table); |
||
| 425 | } |
||
| 426 | } |
||
| 427 | |||
| 428 | View Code Duplication | public function columnExists() |
|
| 429 | { |
||
| 430 | foreach ($this->columns as $column) { |
||
| 431 | list($tableName, $columnName) = explode('.', $column); |
||
| 432 | $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1; |
||
| 433 | $this->I->assertTrue($exists, 'カラムがあるはず '.$column); |
||
| 434 | } |
||
| 435 | } |
||
| 436 | |||
| 437 | View Code Duplication | public function columnNotExists() |
|
| 438 | { |
||
| 439 | foreach ($this->columns as $column) { |
||
| 440 | list($tableName, $columnName) = explode('.', $column); |
||
| 441 | $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1; |
||
| 442 | $this->I->assertFalse($exists, 'カラムがないはず '.$column); |
||
| 443 | } |
||
| 444 | } |
||
| 445 | |||
| 446 | public function traitExists() |
||
| 447 | { |
||
| 448 | foreach ($this->traits as $trait => $target) { |
||
| 449 | $this->I->assertContains($trait, file_get_contents($this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php'), 'Traitがあるはず '.$trait); |
||
| 450 | } |
||
| 451 | } |
||
| 452 | |||
| 453 | public function traitNotExists() |
||
| 454 | { |
||
| 455 | foreach ($this->traits as $trait => $target) { |
||
| 456 | $file = $this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php'; |
||
| 457 | if (file_exists($file)) { |
||
| 458 | $this->I->assertNotContains($trait, file_get_contents($file), 'Traitがないはず '.$trait); |
||
| 459 | } else { |
||
| 460 | $this->I->assertTrue(true, 'Traitがないはず'); |
||
| 461 | } |
||
| 462 | } |
||
| 463 | } |
||
| 464 | |||
| 465 | public function 新しいタブで開く() |
||
| 466 | { |
||
| 467 | $this->I->executeJS("window.open(location.href, 'other')"); |
||
| 468 | $this->I->switchToWindow('other'); |
||
| 469 | return $this; |
||
| 470 | } |
||
| 471 | |||
| 472 | public function 前のタブに戻る() |
||
| 473 | { |
||
| 474 | $this->I->switchToPreviousTab(); |
||
| 475 | return $this; |
||
| 476 | } |
||
| 477 | |||
| 478 | public function 検証() |
||
| 479 | { |
||
| 480 | if ($this->initialized) { |
||
| 481 | $this->tableExists(); |
||
| 482 | $this->columnExists(); |
||
| 483 | } else { |
||
| 484 | $this->tableNotExists(); |
||
| 485 | $this->columnNotExists(); |
||
| 486 | } |
||
| 487 | |||
| 488 | if ($this->enabled) { |
||
| 489 | $this->traitExists(); |
||
| 490 | } else { |
||
| 491 | $this->traitNotExists(); |
||
| 492 | } |
||
| 493 | |||
| 494 | return $this; |
||
| 495 | } |
||
| 496 | } |
||
| 497 | |||
| 498 | class Store_Plugin extends Abstract_Plugin |
||
| 499 | { |
||
| 500 | /** @var PluginManagePage */ |
||
| 501 | protected $ManagePage; |
||
| 502 | |||
| 503 | /** @var Plugin */ |
||
| 504 | protected $Plugin; |
||
| 505 | |||
| 506 | protected $code; |
||
| 507 | |||
| 508 | /** @var Store_Plugin */ |
||
| 509 | protected $dependentBy; |
||
| 510 | |||
| 511 | public function __construct(AcceptanceTester $I, $code, Store_Plugin $dependentBy = null) |
||
| 512 | { |
||
| 513 | parent::__construct($I); |
||
| 514 | $this->code = $code; |
||
| 515 | $this->publishPlugin($this->code.'-1.0.0.tgz'); |
||
| 516 | if ($dependentBy) { |
||
| 517 | $this->ManagePage = $dependentBy->ManagePage; |
||
| 518 | $this->Plugin = $this->pluginRepository->findByCode($code); |
||
| 519 | } |
||
| 520 | } |
||
| 521 | |||
| 522 | public function インストール() |
||
| 523 | { |
||
| 524 | /* |
||
| 525 | * インストール |
||
| 526 | */ |
||
| 527 | $this->ManagePage = PluginSearchPage::go($this->I) |
||
| 528 | ->入手する($this->code) |
||
| 529 | ->インストール(); |
||
| 530 | |||
| 531 | $this->検証(); |
||
| 532 | |||
| 533 | $this->Plugin = $this->pluginRepository->findByCode($this->code); |
||
| 534 | $this->I->assertFalse($this->Plugin->isInitialized(), '初期化されていない'); |
||
| 535 | $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていない'); |
||
| 536 | |||
| 537 | return $this; |
||
| 538 | } |
||
| 539 | |||
| 540 | View Code Duplication | public function 有効化() |
|
| 541 | { |
||
| 542 | $this->ManagePage->ストアプラグイン_有効化($this->code); |
||
| 543 | |||
| 544 | $this->initialized = true; |
||
| 545 | $this->enabled = true; |
||
| 546 | |||
| 547 | $this->検証(); |
||
| 548 | |||
| 549 | $this->em->refresh($this->Plugin); |
||
| 550 | $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); |
||
| 551 | $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている'); |
||
| 552 | return $this; |
||
| 553 | } |
||
| 554 | |||
| 555 | public function 既に有効なものを有効化() |
||
| 556 | { |
||
| 557 | $this->ManagePage->ストアプラグイン_有効化($this->code, '既に有効です。'); |
||
| 558 | |||
| 559 | $this->initialized = true; |
||
| 560 | $this->enabled = true; |
||
| 561 | |||
| 562 | $this->検証(); |
||
| 563 | |||
| 564 | $this->em->refresh($this->Plugin); |
||
| 565 | $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); |
||
| 566 | $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている'); |
||
| 567 | |||
| 568 | |||
| 569 | return $this; |
||
| 570 | } |
||
| 571 | |||
| 572 | View Code Duplication | public function 無効化() |
|
| 573 | { |
||
| 574 | $this->ManagePage->ストアプラグイン_無効化($this->code); |
||
| 575 | |||
| 576 | $this->enabled = false; |
||
| 577 | |||
| 578 | $this->検証(); |
||
| 579 | |||
| 580 | $this->em->refresh($this->Plugin); |
||
| 581 | $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); |
||
| 582 | $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている'); |
||
| 583 | |||
| 584 | return $this; |
||
| 585 | } |
||
| 586 | |||
| 587 | View Code Duplication | public function 既に無効なものを無効化() |
|
| 588 | { |
||
| 589 | $this->ManagePage->ストアプラグイン_無効化($this->code, '既に無効です。'); |
||
| 590 | |||
| 591 | $this->enabled = false; |
||
| 592 | |||
| 593 | $this->検証(); |
||
| 594 | |||
| 595 | $this->em->refresh($this->Plugin); |
||
| 596 | $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); |
||
| 597 | $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている'); |
||
| 598 | |||
| 599 | return $this; |
||
| 600 | } |
||
| 601 | |||
| 602 | View Code Duplication | public function 削除() |
|
| 603 | { |
||
| 604 | $this->ManagePage->ストアプラグイン_削除($this->code); |
||
| 605 | |||
| 606 | $this->initialized = false; |
||
| 607 | $this->enabled = false; |
||
| 608 | |||
| 609 | $this->検証(); |
||
| 610 | |||
| 611 | $this->em->refresh($this->Plugin); |
||
| 612 | $this->Plugin = $this->pluginRepository->findByCode($this->code); |
||
| 613 | $this->I->assertNull($this->Plugin, '削除されている'); |
||
| 614 | |||
| 615 | return $this; |
||
| 616 | } |
||
| 617 | |||
| 618 | public function アップデート() |
||
| 619 | { |
||
| 620 | $this->publishPlugin($this->code.'-1.0.1.tgz'); |
||
| 621 | |||
| 622 | $this->I->reloadPage(); |
||
| 623 | $this->ManagePage->ストアプラグイン_アップデート($this->code)->アップデート(); |
||
| 624 | |||
| 625 | $this->initialized = true; |
||
| 626 | |||
| 627 | $this->検証(); |
||
| 628 | |||
| 629 | $this->em->refresh($this->Plugin); |
||
| 630 | $this->I->assertEquals($this->initialized, $this->Plugin->isInitialized(), '初期化'); |
||
| 631 | $this->I->assertEquals($this->enabled, $this->Plugin->isEnabled(), '有効/無効'); |
||
| 632 | |||
| 633 | return $this; |
||
| 634 | } |
||
| 635 | |||
| 636 | protected function publishPlugin($fileName) |
||
| 637 | { |
||
| 638 | $published = copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName); |
||
| 639 | $this->I->assertTrue($published, "公開できた ${fileName}"); |
||
| 640 | $output = []; |
||
| 641 | exec("ls -ltra repos/", $output); |
||
| 642 | echo implode(PHP_EOL, $output).PHP_EOL; |
||
| 643 | } |
||
| 644 | } |
||
| 645 | |||
| 646 | class Local_Plugin extends Abstract_Plugin |
||
| 647 | { |
||
| 648 | /** @var PluginManagePage */ |
||
| 649 | private $ManagePage; |
||
| 650 | |||
| 651 | /** @var Plugin */ |
||
| 652 | private $Plugin; |
||
| 653 | |||
| 654 | /** @var string */ |
||
| 655 | private $code; |
||
| 656 | |||
| 657 | public function __construct(AcceptanceTester $I, $code) |
||
| 658 | { |
||
| 659 | parent::__construct($I); |
||
| 660 | $this->code = $code; |
||
| 661 | } |
||
| 662 | |||
| 663 | public function インストール() |
||
| 664 | { |
||
| 665 | $this->ManagePage = PluginLocalInstallPage::go($this->I) |
||
| 666 | ->アップロード('plugins/'.$this->code.'-1.0.0.tgz'); |
||
| 667 | |||
| 668 | $this->initialized = true; |
||
| 669 | |||
| 670 | $this->I->see('プラグインをインストールしました。', PluginManagePage::完了メーッセージ); |
||
| 671 | |||
| 672 | $this->検証(); |
||
| 673 | |||
| 674 | $this->Plugin = $this->pluginRepository->findByCode($this->code); |
||
| 675 | $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されていない'); |
||
| 676 | $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていない'); |
||
| 677 | |||
| 678 | return $this; |
||
| 679 | } |
||
| 680 | |||
| 681 | View Code Duplication | public function 有効化() |
|
| 682 | { |
||
| 683 | $this->ManagePage->独自プラグイン_有効化($this->code); |
||
| 684 | |||
| 685 | $this->enabled = true; |
||
| 686 | |||
| 687 | $this->検証(); |
||
| 688 | |||
| 689 | $this->em->refresh($this->Plugin); |
||
| 690 | $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); |
||
| 691 | $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている'); |
||
| 692 | return $this; |
||
| 693 | } |
||
| 694 | |||
| 695 | View Code Duplication | public function 無効化() |
|
| 696 | { |
||
| 697 | $this->ManagePage->独自プラグイン_無効化($this->code); |
||
| 698 | |||
| 699 | $this->enabled = false; |
||
| 700 | |||
| 701 | $this->検証(); |
||
| 702 | |||
| 703 | $this->em->refresh($this->Plugin); |
||
| 704 | $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); |
||
| 705 | $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている'); |
||
| 706 | |||
| 707 | return $this; |
||
| 708 | } |
||
| 709 | |||
| 710 | View Code Duplication | public function 削除() |
|
| 711 | { |
||
| 712 | $this->ManagePage->独自プラグイン_削除($this->code); |
||
| 713 | |||
| 714 | $this->initialized = false; |
||
| 715 | $this->enabled = false; |
||
| 716 | |||
| 717 | $this->I->see('プラグインを削除しました。', PluginManagePage::完了メーッセージ); |
||
| 718 | |||
| 719 | $this->検証(); |
||
| 720 | |||
| 721 | $this->em->refresh($this->Plugin); |
||
| 722 | $this->Plugin = $this->pluginRepository->findByCode($this->code); |
||
| 723 | $this->I->assertNull($this->Plugin, '削除されている'); |
||
| 724 | |||
| 725 | return $this; |
||
| 726 | } |
||
| 727 | |||
| 728 | public function アップデート() |
||
| 729 | { |
||
| 730 | $this->ManagePage->独自プラグイン_アップデート($this->code, 'plugins/'.$this->code.'-1.0.1.tgz'); |
||
| 731 | |||
| 732 | $this->検証(); |
||
| 733 | |||
| 734 | $this->em->refresh($this->Plugin); |
||
| 735 | $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); |
||
| 736 | $this->I->assertEquals($this->enabled, $this->Plugin->isEnabled(), '有効/無効'); |
||
| 737 | |||
| 738 | return $this; |
||
| 739 | } |
||
| 740 | } |
||
| 741 | |||
| 742 | View Code Duplication | class Horizon_Local extends Local_Plugin |
|
| 743 | { |
||
| 744 | public function __construct(AcceptanceTester $I) |
||
| 745 | { |
||
| 746 | parent::__construct($I, 'Horizon'); |
||
| 747 | $this->tables[] = 'dtb_dash'; |
||
| 748 | $this->columns[] = 'dtb_cart.is_horizon'; |
||
| 749 | $this->columns[] = 'dtb_cart.dash_id'; |
||
| 750 | $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'Cart'; |
||
| 751 | } |
||
| 752 | |||
| 753 | public static function start(AcceptanceTester $I) |
||
| 754 | { |
||
| 755 | return new self($I); |
||
| 756 | } |
||
| 757 | } |
||
| 758 | |||
| 759 | class Horizon_Store extends Store_Plugin |
||
| 760 | { |
||
| 761 | public function __construct(AcceptanceTester $I, Store_Plugin $dependentBy) |
||
| 762 | { |
||
| 763 | parent::__construct($I, 'Horizon', $dependentBy); |
||
| 764 | $this->tables[] = 'dtb_dash'; |
||
| 765 | $this->columns[] = 'dtb_cart.is_horizon'; |
||
| 766 | $this->columns[] = 'dtb_cart.dash_id'; |
||
| 767 | $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'Cart'; |
||
| 768 | } |
||
| 769 | |||
| 770 | public static function start(AcceptanceTester $I, Store_Plugin $dependentBy = null) |
||
| 771 | { |
||
| 772 | $result = new self($I, $dependentBy); |
||
|
0 ignored issues
–
show
|
|||
| 773 | return $result; |
||
| 774 | } |
||
| 775 | |||
| 776 | View Code Duplication | public function 依存されているのが有効なのに無効化() |
|
| 777 | { |
||
| 778 | $this->ManagePage->ストアプラグイン_無効化($this->code, '「ホライゾン」を無効にする前に、「エンペラー」を無効にしてください。'); |
||
| 779 | |||
| 780 | $this->検証(); |
||
| 781 | |||
| 782 | $this->em->refresh($this->Plugin); |
||
| 783 | $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されているはず'); |
||
| 784 | $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されているはず'); |
||
| 785 | return $this; |
||
| 786 | } |
||
| 787 | |||
| 788 | public function 依存されているのが削除されていないのに削除() |
||
| 789 | { |
||
| 790 | $this->ManagePage->ストアプラグイン_削除($this->code, '「エンペラー」が「ホライゾン」に依存しているため削除できません。'); |
||
| 791 | |||
| 792 | $this->検証(); |
||
| 793 | |||
| 794 | $this->em->refresh($this->Plugin); |
||
| 795 | $this->Plugin = $this->pluginRepository->findByCode($this->code); |
||
| 796 | $this->I->assertNotNull($this->Plugin, '削除されていない'); |
||
| 797 | |||
| 798 | return $this; |
||
| 799 | } |
||
| 800 | |||
| 801 | } |
||
| 802 | |||
| 803 | class Emperor_Store extends Store_Plugin |
||
| 804 | { |
||
| 805 | public function __construct(AcceptanceTester $I) |
||
| 806 | { |
||
| 807 | parent::__construct($I, 'Emperor'); |
||
| 808 | $this->publishPlugin('Horizon-1.0.0.tgz'); |
||
| 809 | $this->tables[] = 'dtb_foo'; |
||
| 810 | $this->columns[] = 'dtb_cart.foo_id'; |
||
| 811 | $this->traits['\Plugin\Emperor\Entity\CartTrait'] = 'Cart'; |
||
| 812 | } |
||
| 813 | |||
| 814 | public static function start(AcceptanceTester $I) |
||
| 815 | { |
||
| 816 | return new self($I); |
||
| 817 | } |
||
| 818 | |||
| 819 | View Code Duplication | public function 依存より先に有効化() |
|
| 820 | { |
||
| 821 | $this->ManagePage->ストアプラグイン_有効化($this->code, '「ホライゾン」を先に有効化してください。'); |
||
| 822 | |||
| 823 | $this->検証(); |
||
| 824 | |||
| 825 | $this->em->refresh($this->Plugin); |
||
| 826 | $this->I->assertFalse($this->Plugin->isInitialized(), '初期化されていないはず'); |
||
| 827 | $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていないはず'); |
||
| 828 | return $this; |
||
| 829 | } |
||
| 830 | } |
||
| 831 | |||
| 832 | View Code Duplication | class Boomerang_Store extends Store_Plugin |
|
| 833 | { |
||
| 834 | public function __construct(AcceptanceTester $I) |
||
| 835 | { |
||
| 836 | parent::__construct($I, 'Boomerang'); |
||
| 837 | $this->tables[] = 'dtb_bar'; |
||
| 838 | $this->columns[] = 'dtb_cart.is_boomerang'; |
||
| 839 | $this->columns[] = 'dtb_cart.bar_id'; |
||
| 840 | $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'Cart'; |
||
| 841 | } |
||
| 842 | |||
| 843 | public static function start(AcceptanceTester $I) |
||
| 844 | { |
||
| 845 | return new self($I); |
||
| 846 | } |
||
| 847 | } |
||
| 848 | |||
| 849 | class Boomerang_Local extends Local_Plugin |
||
| 850 | { |
||
| 851 | public function __construct(AcceptanceTester $I) |
||
| 852 | { |
||
| 853 | parent::__construct($I, 'Boomerang'); |
||
| 854 | $this->tables[] = 'dtb_bar'; |
||
| 855 | $this->columns[] = 'dtb_cart.is_boomerang'; |
||
| 856 | $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'Cart'; |
||
| 857 | } |
||
| 858 | |||
| 859 | public static function start(AcceptanceTester $I) |
||
| 860 | { |
||
| 861 | return new self($I); |
||
| 862 | } |
||
| 863 | } |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):