-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from s-nakajima/master
ブロックの権限設定テストの共通化対応
- Loading branch information
Showing
20 changed files
with
394 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
Test/Case/Controller/BbsBlockRolePermissionsController/EditTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
<?php | ||
/** | ||
* BlockRolePermissionsController Test Case | ||
* | ||
* @author Noriko Arai <arai@nii.ac.jp> | ||
* @author Shohei Nakajima <nakajimashouhei@gmail.com> | ||
* @link http://www.netcommons.org NetCommons Project | ||
* @license http://www.netcommons.org/license.txt NetCommons License | ||
* @copyright Copyright 2014, NetCommons Project | ||
*/ | ||
|
||
App::uses('BbsBlockRolePermissionsController', 'Bbses.Controller'); | ||
App::uses('BlockRolePermissionsControllerEditTest', 'Blocks.TestSuite'); | ||
|
||
/** | ||
* BlockRolePermissionsController Test Case | ||
* | ||
* @author Shohei Nakajima <nakajimashouhei@gmail.com> | ||
* @package NetCommons\Bbses\Test\Case\Controller | ||
*/ | ||
class BbsBlockRolePermissionsControllerEditTest extends BlockRolePermissionsControllerEditTest { | ||
|
||
/** | ||
* Fixtures | ||
* | ||
* @var array | ||
*/ | ||
public $fixtures = array( | ||
'plugin.bbses.bbs', | ||
'plugin.bbses.bbs_setting', | ||
'plugin.bbses.bbs_frame_setting', | ||
'plugin.bbses.bbs_article', | ||
'plugin.bbses.bbs_article_tree', | ||
'plugin.bbses.bbs_articles_user', | ||
'plugin.workflow.workflow_comment', | ||
); | ||
|
||
/** | ||
* Plugin name | ||
* | ||
* @var array | ||
*/ | ||
public $plugin = 'bbses'; | ||
|
||
/** | ||
* Controller name | ||
* | ||
* @var string | ||
*/ | ||
protected $_controller = 'bbs_block_role_permissions'; | ||
|
||
/** | ||
* テストDataの取得 | ||
* | ||
* @param bool $isPost POSTかどうか | ||
* @return array | ||
*/ | ||
private function __getData($isPost) { | ||
if ($isPost) { | ||
$data = array( | ||
'BbsSetting' => array( | ||
'id' => 2, | ||
'bbs_key' => 'bbs_2', | ||
'use_workflow' => true, | ||
'use_comment_approval' => true, | ||
'approval_type' => true, | ||
) | ||
); | ||
} else { | ||
$data = array( | ||
'BbsSetting' => array( | ||
'use_workflow', | ||
'use_comment_approval', | ||
'approval_type', | ||
) | ||
); | ||
} | ||
return $data; | ||
} | ||
|
||
/** | ||
* edit()アクションDataProvider | ||
* | ||
* ### 戻り値 | ||
* - approvalFields コンテンツ承認の利用有無のフィールド | ||
* - exception Exception | ||
* - return testActionの実行後の結果 | ||
* | ||
* @return void | ||
*/ | ||
public function dataProviderEditGet() { | ||
return array( | ||
array('approvalFields' => $this->__getData(false)) | ||
); | ||
} | ||
|
||
/** | ||
* editアクションのGETテスト(Exceptionエラー) | ||
* | ||
* @param array $approvalFields コンテンツ承認の利用有無のフィールド | ||
* @param string|null $exception Exception | ||
* @param string $return testActionの実行後の結果 | ||
* @dataProvider dataProviderEditGet | ||
* @return void | ||
*/ | ||
public function testEditGetExceptionError($approvalFields, $exception = null, $return = 'view') { | ||
$this->_mockForReturnFalse('Bbses.Bbs', 'getBbs'); | ||
|
||
$exception = 'BadRequestException'; | ||
$this->testEditGet($approvalFields, $exception, $return); | ||
} | ||
|
||
/** | ||
* editアクションのGET(JSON)テスト(Exceptionエラー) | ||
* | ||
* @param array $approvalFields コンテンツ承認の利用有無のフィールド | ||
* @param string|null $exception Exception | ||
* @param string $return testActionの実行後の結果 | ||
* @dataProvider dataProviderEditGet | ||
* @return void | ||
*/ | ||
public function testEditGetJsonExceptionError($approvalFields, $exception = null, $return = 'view') { | ||
$this->_mockForReturnFalse('Bbses.Bbs', 'getBbs'); | ||
|
||
$exception = 'BadRequestException'; | ||
$return = 'json'; | ||
$this->testEditGet($approvalFields, $exception, $return); | ||
} | ||
|
||
/** | ||
* edit()アクションDataProvider | ||
* | ||
* ### 戻り値 | ||
* - data POSTデータ | ||
* - exception Exception | ||
* - return testActionの実行後の結果 | ||
* | ||
* @return void | ||
*/ | ||
public function dataProviderEditPost() { | ||
return array( | ||
array('data' => $this->__getData(true)) | ||
); | ||
} | ||
|
||
/** | ||
* editアクションのPOSTテスト(Saveエラー) | ||
* | ||
* @param array $data POSTデータ | ||
* @param string|null $exception Exception | ||
* @param string $return testActionの実行後の結果 | ||
* @dataProvider dataProviderEditPost | ||
* @return void | ||
*/ | ||
public function testEditPostSaveError($data, $exception = null, $return = 'view') { | ||
$data['BlockRolePermission']['content_creatable'][Role::ROOM_ROLE_KEY_GENERAL_USER]['roles_room_id'] = 'aaaa'; | ||
|
||
//テスト実施 | ||
$exception = false; | ||
$result = $this->testEditPost($data, false, $return); | ||
|
||
$approvalFields = $this->__getData(false); | ||
$this->_assertEditGetPermission($approvalFields, $result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.