/** * blockRolePermissionデータ保存 validateBlockRolePermissionsテスト * $data['BlockRolePermission']['content_creatable']['room_administrator']['block_key']等 block_keyのkeyなしエラー * * @return void */ public function testSaveBlockRolePermissionValiateBlockRolePermissions() { $blockKey = 'block_1'; $roomId = 1; // 取得 $videoBlockSetting = $this->VideoBlockSetting->getVideoBlockSetting($blockKey, $roomId); $netCommonsBlock = new NetCommonsBlockComponent(new ComponentCollection()); $controller = new Controller(); $controller->viewVars['languageId'] = 2; $controller->viewVars['roomId'] = 1; $netCommonsBlock->initialize($controller); $permissions = $netCommonsBlock->getBlockRolePermissions($blockKey, array('content_creatable', 'content_publishable', 'content_comment_creatable', 'content_comment_publishable')); // 更新時間を再セット unset($videoBlockSetting['VideoBlockSetting']['modified']); $data = Hash::merge($videoBlockSetting, array('BlockRolePermission' => $permissions['BlockRolePermissions'])); $videoBlockSetting = $this->VideoBlockSetting->saveBlockRolePermission($data); $this->assertFalse($videoBlockSetting); }
/** * blockRolePermissionデータ保存 テスト * * @return void */ public function testSaveBlockRolePermission() { $blockKey = 'block_1'; $roomId = 1; // 取得 $videoBlockSetting = $this->VideoBlockSetting->getVideoBlockSetting($blockKey, $roomId); $netCommonsBlock = new NetCommonsBlockComponent(new ComponentCollection()); $controller = new Controller(); $controller->viewVars['languageId'] = 2; $controller->viewVars['roomId'] = $roomId; $netCommonsBlock->initialize($controller); $permissions = $netCommonsBlock->getBlockRolePermissions($blockKey, array('content_creatable', 'content_publishable', 'content_comment_creatable', 'content_comment_publishable')); // 更新時間を再セット unset($videoBlockSetting['VideoBlockSetting']['modified']); $data = $videoBlockSetting; $data['BlockRolePermission']['content_creatable'] = $permissions['BlockRolePermissions']['content_creatable']; $data['BlockRolePermission']['content_creatable']['room_administrator']['block_key'] = $blockKey; $data['BlockRolePermission']['content_creatable']['chief_editor']['block_key'] = $blockKey; $data['BlockRolePermission']['content_creatable']['editor']['block_key'] = $blockKey; $data['BlockRolePermission']['content_creatable']['general_user']['block_key'] = $blockKey; $data['BlockRolePermission']['content_creatable']['visitor']['block_key'] = $blockKey; $videoBlockSetting = $this->VideoBlockSetting->saveBlockRolePermission($data); $this->assertInternalType('array', $videoBlockSetting); }
/** * blockRolePermissionデータ保存 BlockRolePermission例外テスト * * @return void */ public function testSaveBlockRolePermissionBlockRolePermissionException() { $this->setExpectedException('InternalErrorException'); $blockKey = 'block_1'; $roomId = 1; // 取得 $videoBlockSetting = $this->VideoBlockSetting->getVideoBlockSetting($blockKey, $roomId); $netCommonsBlock = new NetCommonsBlockComponent(new ComponentCollection()); $controller = new Controller(); $controller->viewVars['languageId'] = 2; $controller->viewVars['roomId'] = 1; $netCommonsBlock->initialize($controller); $permissions = $netCommonsBlock->getBlockRolePermissions($blockKey, array('content_creatable', 'content_publishable', 'content_comment_creatable', 'content_comment_publishable')); // 更新時間を再セット unset($videoBlockSetting['VideoBlockSetting']['modified']); $data = $videoBlockSetting; $data['BlockRolePermission']['content_creatable'] = $permissions['BlockRolePermissions']['content_creatable']; $data['BlockRolePermission']['content_creatable']['room_administrator']['block_key'] = $blockKey; $data['BlockRolePermission']['content_creatable']['chief_editor']['block_key'] = $blockKey; $data['BlockRolePermission']['content_creatable']['editor']['block_key'] = $blockKey; $data['BlockRolePermission']['content_creatable']['general_user']['block_key'] = $blockKey; $data['BlockRolePermission']['content_creatable']['visitor']['block_key'] = $blockKey; // modelモック $modelMock = $this->getMockForModel('Blocks.BlockRolePermission', ['saveMany']); $modelMock->expects($this->any())->method('saveMany')->will($this->returnValue(false)); $this->VideoBlockSetting->BlockRolePermission = $modelMock; $this->VideoBlockSetting->saveBlockRolePermission($data); }