/**
  * Expect admin user can edit topic frame settings
  *
  * @return void
  */
 public function testEditPostWithInvalidFrameId()
 {
     RolesControllerTest::login($this);
     $this->testAction('/topics/topic_frame_settings/edit/191', array('method' => 'post', 'data' => array('TopicFrameSetting' => array('id' => 1, 'frame_id' => '', 'key' => 'key', 'created' => '2015-08-05 12:38:49', 'created_user' => '1', 'modified' => '2015-08-05 12:38:49', 'modified_user' => '1', 'unit_type' => '0', 'display_days' => '0', 'select_room' => '0', 'show_my_room' => '0', 'display_title' => '1', 'display_description' => '1', 'display_room_name' => '0', 'display_plugin_name' => '1', 'display_created_user' => '0', 'display_created' => '1'), 'TopicSelectedRoom' => array('room_id' => '')), 'return' => 'contents'));
     $this->assertTextEquals('edit', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect admin user failes to edit topic frame settings with invalid searchbox target plugin key
  *
  * @return void
  */
 public function testEditPostWithInvalidSearchBoxTargetPluginKey()
 {
     RolesControllerTest::login($this);
     $this->testAction('/search_boxes/search_boxes/edit/191', array('method' => 'post', 'data' => array('SearchBox' => array('id' => '1', 'frame_key' => 'frame_191', 'created_user' => '1', 'modified_user' => '1', 'is_advanced' => '1'), 'Frame' => array('key' => 'frame_191'), 'SearchBoxTargetPlugin' => array('plugin_key' => array(0 => 'invalid'))), 'return' => 'contents'));
     $this->assertTextEquals('edit', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * 管理者ログイン後 ブロック一覧 表示テスト
  *
  * @return void
  */
 public function testIndex()
 {
     RolesControllerTest::login($this);
     $frameId = 1;
     $this->testAction('/videos/video_block_settings/index/' . $frameId, array('method' => 'get', 'return' => 'view'));
     $this->assertTextEquals('index', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect get site info by format error
  *
  * @return void
  */
 public function testEditGetSiteInfoError()
 {
     $this->setExpectedException('XmlException');
     RolesControllerTest::login($this);
     $url = 'test';
     $this->testAction('/rss_readers/rss_readers/get/181?url=' . rawurlencode($url), array('method' => 'get', 'type' => 'json', 'return' => 'contents'));
     $this->assertTextEquals('get', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * 管理者ログイン後 表示方法変更画面 表示テスト
  *
  * @return void
  */
 public function testEdit()
 {
     RolesControllerTest::login($this);
     $frameId = 1;
     $blockId = 1;
     $this->testAction('/videos/video_block_role_permissions/edit/' . $frameId . '/' . $blockId, array('method' => 'get', 'return' => 'view'));
     $this->assertTextEquals('edit', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
示例#6
0
 /**
  * test delete. DeleteFail
  *
  * @return void
  */
 public function testDeleteDeleteFail()
 {
     RolesControllerTest::login($this);
     $BlogEntryMock = $this->getMockForModel('Blogs.BlogEntry', ['deleteEntryByOriginId']);
     $BlogEntryMock->expects($this->any())->method('deleteEntryByOriginId')->will($this->returnValue(false));
     $this->setExpectedException('InternalErrorException');
     $this->testAction('/blogs/blog_entries_edit/delete/1', array('method' => 'post', 'return' => 'view', 'data' => array('BlogEntry' => array('origin_id' => 3))));
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect post add action on validation error.
  *
  * @return void
  */
 public function testPostValidationError()
 {
     RolesControllerTest::login($this);
     $frameId = 1;
     $data = array('Iframe' => array('id' => '', 'block_id' => '', 'key' => '', 'url' => '', 'height' => 300, 'display_scrollbar' => false, 'display_frame' => false), 'Frame' => array('id' => $frameId), 'Block' => array('id' => '', 'language_id' => '2', 'room_id' => '1', 'key' => '', 'plugin_key' => 'iframes', 'public_type' => Block::TYPE_PRIVATE, 'from' => '2015-04-01 12:34', 'to' => '2015-04-02 01:45'));
     $this->testAction('/iframes/iframe_blocks/add/' . $frameId, array('method' => 'post', 'data' => $data, 'return' => 'view'));
     $this->assertTextEquals('edit', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * 管理者ログイン後 表示方法変更画面 編集テスト
  *
  * @return void
  */
 public function testEditPost()
 {
     RolesControllerTest::login($this);
     $data = array();
     $frameId = 2;
     $this->testAction('/videos/videos_edit/edit/' . $frameId, array('method' => 'post', 'data' => $data, 'return' => 'view'));
     $this->assertTextEquals('edit', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
示例#9
0
 /**
  * test delete action. Post success
  *
  * @return void
  */
 public function testDeletePostSuccess()
 {
     RolesControllerTest::login($this);
     $this->controller->NetCommonsBlock->expects($this->once())->method('validateBlockId')->will($this->returnValue(true));
     $data = ['Blog' => ['key' => 'blog1'], 'Block' => ['id' => 5, 'key' => 'block_5']];
     $this->testAction('/blogs/blog_blocks/delete/1/5', array('method' => 'delete', 'data' => $data));
     $this->assertRegExp('#/blogs/blog_blocks/index/#', $this->headers['Location']);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect index action without page
  *
  * @return void
  */
 public function testPageError()
 {
     $this->setExpectedException('NotFoundException');
     RolesControllerTest::login($this);
     $frameId = '100';
     $this->testAction('/faqs/faq_blocks/index/' . $frameId . '/page:2', array('method' => 'get', 'return' => 'view'));
     $this->assertTextEquals('index', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect user with blockPermissionEditable cannot access on GET request
  *
  * @return void
  */
 public function testEditGetWOPermissionEditable()
 {
     $this->setExpectedException('ForbiddenException');
     RolesControllerTest::login($this, 'editor');
     $frameId = '100';
     $blockId = '100';
     $this->testAction('/faqs/faq_block_role_permmisions/edit/' . $frameId . '/' . $blockId, array('method' => 'get', 'return' => 'view'));
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect admin user can access view action
  *
  * @return void
  */
 public function testViewByAdmin()
 {
     RolesControllerTest::login($this);
     $view = $this->testAction('/rss_readers/rss_readers/view/181', array('method' => 'get', 'return' => 'view'));
     $this->assertTextEquals('view', $this->controller->view);
     $this->assertTextContains('nc-rss-readers-1', $view, print_r($view, true));
     $this->assertTextContains('/rss_readers/rss_readers/edit/1', $view, print_r($view, true));
     AuthGeneralControllerTest::logout($this);
 }
示例#13
0
 /**
  * testIndex. No blogs
  *
  * @return void
  */
 public function testIndexNoBlogs()
 {
     RolesControllerTest::login($this);
     // blogレコードを削除しておく
     $Blog = ClassRegistry::init('Blogs.Blog');
     $Blog->deleteAll(array(1 => 1), false, false);
     $view = $this->testAction('/blogs/blog_blocks/index/1', array('method' => 'get', 'return' => 'view'));
     $this->assertTextContains(__d('net_commons', 'Not found.'), $view);
     AuthGeneralControllerTest::logout($this);
 }
示例#14
0
 /**
  * keyword未指定のとき
  *
  * @return void
  */
 public function testEmptyKeyword()
 {
     RolesControllerTest::login($this);
     $frameId = 1;
     $keyword = '';
     $modelName = 'BlogEntry';
     $this->testAction('/tags/tags/search/' . $frameId . '/keyword:' . $keyword . '/target:' . $modelName);
     //$this->assertFalse(isset($this->vars['results']));
     AuthGeneralControllerTest::logout($this);
 }
示例#15
0
 /**
  * test view.編集リンクの表示テスト
  *
  * @param string $role ロール
  * @param bool $viewEditLink 編集リンクが表示されるか
  * @dataProvider editLinkDataProvider
  * @return void
  */
 public function testEditLink($role, $viewEditLink)
 {
     RolesControllerTest::login($this, $role);
     $view = $this->testAction('/blogs/blog_entries/view/1/origin_id:6', array('method' => 'get', 'return' => 'view'));
     $this->assertInternalType('array', $this->vars['blogEntry']);
     if ($viewEditLink) {
         $this->assertTextContains('nc-blog-edit-link', $view);
     } else {
         $this->assertTextNotContains('nc-blog-edit-link', $view);
     }
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * 管理者ログイン後  削除 例外テスト
  * 'method' => 'delete' 以外のため、エラー
  *
  * @return void
  * @throws Exception
  */
 public function testDeleteException()
 {
     $this->setExpectedException('BadRequestException');
     RolesControllerTest::login($this);
     $frameId = 2;
     try {
         $this->testAction('/videos/videos_edit/delete/' . $frameId, array('method' => 'post', 'return' => 'view'));
     } catch (Exception $e) {
         AuthGeneralControllerTest::logout($this);
         throw $e;
     }
 }
 /**
  * testAddError method
  *
  * @return void
  */
 public function testAddError()
 {
     $this->setExpectedException('InternalErrorException');
     RolesControllerTest::login($this);
     $this->generate('Frames');
     $this->controller->Frame = $this->getMockForModel('Frames.Frame', array('save'));
     $this->controller->Frame->expects($this->once())->method('save')->will($this->returnValue(false));
     $options = array('data' => array('Frame' => array('box_id' => '1', 'plugin_key' => 'model_with_after_frame_save_test_plugin', 'plugin_id' => '1', 'room_id' => '1')));
     $this->testAction('/frames/frames/add', $options);
     // It should be error assertion
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect add action
  *
  * @return void
  */
 public function testanswer()
 {
     //正常(プレ回答)
     RolesControllerTest::login($this);
     $frameId = '1';
     $questionnaireId = '1';
     $data = array('PreAnswer' => array('key_phrase' => 'aaa'));
     //	'create_option' => QuestionnairesComponent::QUESTIONNAIRE_CREATE_OPT_NEW);
     $this->testAction('/questionnaires/questionnaire_answers/answer/' . $frameId . '/' . $questionnaireId, array('method' => 'POST', 'data' => $data, 'return' => 'view'));
     //print_r($this->controller->view);
     $this->assertTextEquals('QuestionnaireAnswers/test_mode', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect admin user cannot disapprove publish request from editor w/o comments.comment
  *
  * @return void
  */
 public function testEditCommentError()
 {
     RolesControllerTest::login($this);
     $postData = array('Announcement' => array('block_id' => '1', 'key' => 'announcement_1', 'content' => 'edit content'), 'Frame' => array('id' => '1'), 'Comment' => array('plugin_key' => 'announcements', 'content_key' => 'announcement_1', 'comment' => ''), sprintf('save_%s', WorkflowComponent::STATUS_DISAPPROVED) => '');
     $view = $this->testAction('/announcements/announcements/edit/1.json', array('method' => 'post', 'data' => $postData, 'type' => 'json', 'return' => 'contents'));
     $result = json_decode($view, true);
     $this->assertArrayHasKey('code', $result, print_r($result, true));
     $this->assertEquals(400, $result['code'], print_r($result, true));
     $this->assertArrayHasKey('name', $result, print_r($result, true));
     $this->assertArrayHasKey('error', $result, print_r($result, true));
     $this->assertArrayHasKey('validationErrors', $result['error'], print_r($result, true));
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect add action
  *
  * @return void
  */
 public function testThanksNotFound()
 {
     //NotFoundException
     $this->setExpectedException('NotFoundException');
     RolesControllerTest::login($this);
     $frameId = '1';
     $questionnaireId = '0';
     $data = array();
     //	'create_option' => QuestionnairesComponent::QUESTIONNAIRE_CREATE_OPT_NEW);
     $this->testAction('/questionnaires/questionnaires/thanks/' . $frameId . '/' . $questionnaireId, array('method' => 'POST', 'data' => $data, 'return' => 'view'));
     //print_r($this->controller->view);
     $this->assertTextEquals('thanks', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect Edit action
  *
  * @return void
  */
 public function testEditSessionTimeout()
 {
     //セッションタイムアウト
     $this->setExpectedException('BadRequestException');
     RolesControllerTest::login($this);
     $frameId = '1';
     $data = array('Questionnaire' => array('title' => 'testtitle'), 'create_option' => QuestionnairesComponent::QUESTIONNAIRE_CREATE_OPT_NEW, 'past_questionnaire_id' => 1);
     $this->testAction('/questionnaires/questionnaires/edit/' . $frameId, array('method' => 'POST', 'data' => $data, 'return' => 'view'));
     $this->assertTextEquals('Edit', $this->controller->view);
     //print_r($this->headers['Location']);
     $this->assertRegExp('#/questionnaire_questions/edit#', $this->headers['Location']);
     //リダイレクト確認
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect Delete action
  *
  * @return void
  */
 public function testDeleteNothing()
 {
     //削除(削除なし deleteQuestionnaireでfalseが返却される場合)
     $questionMock = $this->getMockForModel('Questionnaires.Questionnaire', array('deleteQuestionnaire'));
     $questionMock->expects($this->once())->method('deleteQuestionnaire')->will($this->returnValue(false));
     RolesControllerTest::login($this);
     $frameId = '1';
     $data = array('Questionnaire' => array('id' => 1, 'origin_id' => 1, 'key' => 'frame_1'));
     $this->testAction('/questionnaires/questionnaires/delete/' . $frameId, array('method' => 'POST', 'data' => $data, 'return' => 'view'));
     //PENDING ↓ 「選ばれたビューファイルがありません。」
     //1) QuestionnairesControllerDeleteTest::testDeleteNothing
     //MissingViewException: View file "Questionnaires/delete.ctp" is missing.
     $this->assertTextEquals('delete', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
示例#23
0
 /**
  * test add action post success
  *
  * @return void
  */
 public function testAddPostSuccess()
 {
     $this->blogEntriesEditMock->NetCommonsWorkflow->expects($this->once())->method('parseStatus')->will($this->returnValue(1));
     RolesControllerTest::login($this);
     $data = array();
     $data['BlogEntry']['category_id'] = 0;
     $data['BlogEntry']['title'] = 'New ENtry';
     $data['BlogEntry']['body1'] = 'body1';
     $data['BlogEntry']['key'] = '';
     $data['BlogEntry']['status'] = 1;
     $data['BlogEntry']['origin_id'] = 0;
     $data['BlogEntry']['language_id'] = 1;
     $data['BlogEntry']['published_datetime'] = '2015-01-01 00:00:00';
     $data['BlogEntry']['block_id'] = 5;
     $data['BlogEntry']['blog_key'] = 'blog1';
     $data['Comment']['comment'] = '';
     $this->testAction('/blogs/blog_entries_edit/add/1', array('method' => 'post', 'data' => $data));
     $this->assertRegExp('#blogs/blog_entries/view#', $this->headers['Location']);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect Edit action
  *
  * @return void
  */
 public function testEditResultSession()
 {
     //Session
     RolesControllerTest::login($this);
     $frameId = '1';
     $data = array('Questionnaire' => array('title' => 'testtitle', 'key' => '', 'status' => 3, 'is_total_show' => 1, 'block_id' => 5, 'id' => 1), 'QuestionnairePage' => array(0 => array('id' => 1, 'key' => 'keywords', 'questionnaire_id' => 1, 'page_title' => 'pagetitle', 'page_sequence' => 0, 'route_number' => 0, 'QuestionnaireQuestion' => array(0 => array('id' => 1, 'key' => 'testkey', 'question_sequence' => 0, 'question_type' => 1, 'QuestionnaireChoice' => array(0 => array('choice_sequence' => 5)))))));
     //---モックでaddからのsessionを設定
     $this->controller->Session->expects($this->any())->method('check')->will($this->returnValueMap([['Questionnaires.questionnaire', $data]]));
     $this->controller->Session->expects($this->any())->method('read')->will($this->returnValueMap([['Questionnaires.questionnaire', $data]]));
     $this->testAction('/questionnaires/questionnaire_questions/edit_result/' . $frameId, array('method' => 'GET', 'data' => $data, 'return' => 'view'));
     $this->assertTextEquals('edit_result', $this->controller->view);
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * test edit. Post validateFail
  *
  * @return void
  */
 public function testEditPostValidateFail()
 {
     RolesControllerTest::login($this);
     $this->controller->NetCommonsBlock->expects($this->once())->method('validateBlockId')->will($this->returnValue(true));
     $data = [];
     //$data['BlogSetting']['blog_key'] = 'new_blog_key';
     $data['BlockRolePermission'] = array();
     $this->testAction('/blogs/blog_block_role_permissions/edit/1/5', array('method' => 'post', 'data' => $data));
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * testDeleteError method
  *
  * @return void
  */
 public function testDeleteError()
 {
     $this->setExpectedException('BadRequestException');
     RolesControllerTest::login($this);
     $this->controller->Frame = $this->getMockForModel('Frames.Frame', array('saveFrame'));
     $this->controller->Frame->expects($this->once())->method('saveFrame')->will($this->returnValue(false));
     $this->testAction('/frames/frames/delete/1', array('method' => 'delete'));
     // It should be error assertion
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect admin user cannot disapprove publish request from editor w/o comments.comment
  *
  * @return void
  */
 public function testEditCommentError()
 {
     RolesControllerTest::login($this);
     //データ生成
     $frameId = '181';
     $blockId = '181';
     $blockKey = 'block_' . $blockId;
     $roomId = '1';
     $data = array('Frame' => array('id' => $frameId), 'Block' => array('id' => $blockId, 'key' => $blockKey, 'room_id' => $roomId), 'RssReader' => array('key' => 'rss_reader_1', 'url' => APP . 'Plugin' . DS . 'RssReaders' . DS . 'Test' . DS . 'Fixture' . DS . 'rss_v1.xml', 'title' => 'Edit title', 'summary' => 'Edit summary', 'link' => 'http://example.com'), 'Comment' => array('comment' => ''), sprintf('save_%s', NetCommonsBlockComponent::STATUS_DISAPPROVED) => '');
     //テスト実行
     $ret = $this->testAction('/rss_readers/rss_readers/edit/' . $frameId . '.json', array('method' => 'post', 'data' => $data, 'type' => 'json', 'return' => 'contents'));
     $result = json_decode($ret, true);
     $this->assertArrayHasKey('code', $result, print_r($result, true));
     $this->assertEquals(400, $result['code'], print_r($result, true));
     $this->assertArrayHasKey('name', $result, print_r($result, true));
     $this->assertArrayHasKey('error', $result, print_r($result, true));
     $this->assertArrayHasKey('validationErrors', $result['error'], print_r($result, true));
     AuthGeneralControllerTest::logout($this);
 }
示例#28
0
 /**
  * 一度でも公開されたコンテンツの削除には公開権限が必用
  *
  * 公開権限ありで削除ボタン表示
  * 公開権限無しなら削除ボタン非表示
  *
  * @return void
  */
 public function testPublishedIsNotViewDeleteButtonForEditor()
 {
     // 公開権限なしなら公開済みコンテンツは削除NG
     RolesControllerTest::login($this, Role::ROLE_KEY_EDITOR);
     $view = $this->testAction('/blogs/blog_entries_edit/edit/1/origin_id:3', array('method' => 'get', 'return' => 'view'));
     $this->assertTextNotContains('glyphicon-trash', $view, print_r($view, true));
     AuthGeneralControllerTest::logout($this);
     // 公開権限あれば公開済みでも削除ボタンが表示される
     RolesControllerTest::login($this, Role::ROLE_KEY_SYSTEM_ADMINISTRATOR);
     $view = $this->testAction('/blogs/blog_entries_edit/edit/1/origin_id:3', array('method' => 'get', 'return' => 'view'));
     $this->assertTextContains('glyphicon-trash', $view, print_r($view, true));
     AuthGeneralControllerTest::logout($this);
 }
 /**
  * Expect download action
  *
  * @return void
  */
 public function testdownloaderr()
 {
     //エラー
     RolesControllerTest::login($this);
     $frameId = 1;
     $questionnaireId = 10;
     $data = array();
     $this->testAction('/questionnaires/questionnaire_blocks/download/' . $frameId . '/' . $questionnaireId, array('method' => 'POST', 'data' => $data, 'return' => 'vars'));
     $this->assertTextEquals('download', $this->controller->view);
     //print_r($this->controller->response);
     AuthGeneralControllerTest::logout($this);
 }
示例#30
0
 /**
  * Expect visitor can search latest contents
  *
  * @return void
  */
 public function testVisitorSearchLatest()
 {
     RolesControllerTest::login($this, Role::ROLE_KEY_VISITOR);
     $this->testAction('/topics/topics/search/191', array('method' => 'get', 'data' => array('status' => 1)));
     $this->assertNotEmpty($this->vars['topics']);
     AuthGeneralControllerTest::logout($this);
 }