Skip to content

Commit

Permalink
test: PluginsRoleテーブルの値が変わらなくなりテストエラー
Browse files Browse the repository at this point in the history
  • Loading branch information
akagane99 committed Mar 15, 2019
1 parent 610ded5 commit e8a0fd7
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Test/Case/Controller/CleanUpController/DeleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class CleanUpControllerDeleteTest extends CleanUpControllerTestCase {
*/
public $fixtures = array(
'plugin.clean_up.clean_up',
'plugin.plugin_manager.plugin4test',
//'plugin.plugin_manager.plugin4test',
//'plugin.plugin_manager.plugin',
'plugin.clean_up.plugin_for_clean_up',
'plugin.clean_up.plugins_role_for_clean_up',
);

/**
Expand Down
68 changes: 68 additions & 0 deletions Test/Fixture/PluginsRoleForCleanUpFixture.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* PluginsRoleForCleanUpFixture
*
* @author Mitsuru Mutaguchi <mutaguchi@opensource-workshop.jp>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/

/**
* PluginsRoleForCleanUpFixture
*
* @author Mitsuru Mutaguchi <mutaguchi@opensource-workshop.jp>
* @package NetCommons\PluginManager\Test\Fixture
* @see PluginsRoleFixture からコピー
*/
class PluginsRoleForCleanUpFixture extends CakeTestFixture {

/**
* Model name
*
* @var string
*/
public $name = 'PluginsRole';

/**
* Full Table Name
*
* @var string
*/
public $table = 'plugins_role';

/**
* Records
*
* @var array
*/
public $records = array(
array(
'role_key' => 'system_administrator',
//'plugin_key' => 'test_plugin',
'plugin_key' => 'clean_up',
),
);

/**
* Initialize the fixture.
*
* @return void
*/
public function init() {
require_once App::pluginPath('PluginManager') . 'Config' . DS . 'Schema' . DS . 'schema.php';
$this->fields = (new PluginManagerSchema())->tables[Inflector::tableize($this->name)];
// if (class_exists('NetCommonsTestSuite') && NetCommonsTestSuite::$plugin) {
// //var_dump($this->records, NetCommonsTestSuite::$plugin);
// $records = array_keys($this->records);
// foreach ($records as $i) {
// if ($this->records[$i]['plugin_key'] === 'test_plugin') {
// $this->records[$i]['plugin_key'] = NetCommonsTestSuite::$plugin;
// }
// }
// }
// //var_dump($this->records, NetCommonsTestSuite::$plugin);
parent::init();
}

}
6 changes: 5 additions & 1 deletion TestSuite/CleanUpControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ public function setUp() {
CleanUpUtility::$lockFilePath =
ROOT . DS . APP_DIR . DS . 'tmp' . DS . 'tests' . DS . 'CleanUp.lock';

//$instance = Current::getInstance();
// 独自でFixture用意してセットしてもPluginsRoleテーブルの値が変わらなかったため
// コントローラー動かすならPluginsRoleテーブルにcleanup必須
/* @see PluginsRoleForCleanUpFixture 独自でFixture用意 */
Current::$current['PluginsRole'][] = array(
'id' => '1',
//$instance->current['PluginsRole'][] = array(
'id' => '2',
'role_key' => 'system_administrator',
'plugin_key' => 'clean_up',
);
Expand Down

0 comments on commit e8a0fd7

Please sign in to comment.