コード例 #1
0
 /**
  * viewアクションのテスト(編集権限、公開権限なし)
  *
  * @param array $urlOptions URLオプション
  * @param array $assert テストの期待値
  * @param string|null $exception Exception
  * @param string $return testActionの実行後の結果
  * @dataProvider dataProviderViewByEditable
  * @return void
  */
 public function testViewByEditable($urlOptions, $assert, $exception = null, $return = 'view')
 {
     //ログイン
     TestAuthGeneral::login($this, Role::ROOM_ROLE_KEY_EDITOR);
     //テスト実施
     $url = Hash::merge(array('plugin' => $this->plugin, 'controller' => $this->_controller, 'action' => 'view'), $urlOptions);
     $this->_testGetAction($url, $assert, $exception, $return);
     //ログアウト
     TestAuthGeneral::logout($this);
 }
コード例 #2
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     //ログアウト
     TestAuthGeneral::logout($this);
     parent::tearDown();
 }
コード例 #3
0
 /**
  * editアクションのPOSTテスト
  *
  * @param array $data POSTデータ
  * @param string|null $exception Exception
  * @param string $return testActionの実行後の結果
  * @dataProvider dataProviderEditPost
  * @return void
  */
 public function testEditPost($data, $exception = null, $return = 'view')
 {
     //ログイン
     TestAuthGeneral::login($this);
     $frameId = '6';
     $blockId = '4';
     $blockKey = 'block_2';
     $roomId = '1';
     $permissions = $this->_getPermissionData(true, Hash::check($data, '{s}.use_comment_approval'));
     $RolesRoomFixture = new RolesRoomFixture();
     $rolesRooms = Hash::extract($RolesRoomFixture->records, '{n}[room_id=' . $roomId . ']');
     $default['Block'] = array('id' => $blockId, 'key' => $blockKey);
     foreach ($permissions as $permission => $roles) {
         foreach ($roles as $role) {
             $rolesRoom = Hash::extract($rolesRooms, '{n}[role_key=' . $role . ']');
             $default['BlockRolePermission'][$permission][$role] = array('roles_room_id' => $rolesRoom[0]['id'], 'block_key' => $blockKey, 'permission' => $permission, 'value' => '1');
         }
     }
     //テスト実施
     $url = array('action' => 'edit', 'frame_id' => $frameId, 'block_id' => $blockId);
     $result = $this->_testPostAction('post', Hash::merge($default, $data), $url, $exception, $return);
     //正常の場合、リダイレクト
     if (!isset($exception)) {
         $header = $this->controller->response->header();
         $this->assertNotEmpty($header['Location']);
     }
     //ログアウト
     TestAuthGeneral::logout($this);
     return $result;
 }
コード例 #4
0
 /**
  * editアクションのValidateionErrorテスト
  *
  * @param array $data POSTデータ
  * @param array $urlOptions URLオプション
  * @param string|null $validationError ValidationError
  * @dataProvider dataProviderEditValidationError
  * @return void
  */
 public function testEditValidationError($data, $urlOptions, $validationError = null)
 {
     //ログイン
     TestAuthGeneral::login($this);
     //テスト実施
     $this->_testActionOnValidationError('put', $data, Hash::merge(array('action' => 'edit'), $urlOptions), $validationError);
     //ログアウト
     TestAuthGeneral::logout($this);
 }
コード例 #5
0
 /**
  * index()のページネーションテスト
  *
  * @param int $page ページ番号
  * @param bool $isFirst 最初のページかどうか
  * @param bool $isLast 最後のページかどうか
  * @dataProvider dataProviderPaginator
  * @return void
  */
 public function testIndexPaginator($page, $isFirst, $isLast)
 {
     TestAuthGeneral::login($this);
     //テスト実施
     $frameId = '16';
     $url = array('plugin' => $this->plugin, 'controller' => $this->_controller, 'action' => 'index', 'frame_id' => $frameId);
     if (!$isFirst) {
         $url[] = 'page:' . $page;
     }
     $result = $this->_testNcAction($url, array('method' => 'get'));
     //チェック
     $this->assertRegExp('/' . preg_quote('<ul class="pagination">', '/') . '/', $result);
     if ($isFirst) {
         $this->assertNotRegExp('/<li><a.*?rel="first".*?<\\/a><\\/li>/', $result);
     } else {
         $this->assertRegExp('/<li><a.*?rel="first".*?<\\/a><\\/li>/', $result);
     }
     $this->assertRegExp('/<li class="active"><a>' . $page . '<\\/a><\\/li>/', $result);
     if ($isLast) {
         $this->assertNotRegExp('/<li><a.*?rel="last".*?<\\/a><\\/li>/', $result);
     } else {
         $this->assertRegExp('/<li><a.*?rel="last".*?<\\/a><\\/li>/', $result);
     }
     TestAuthGeneral::logout($this);
 }
コード例 #6
0
 /**
  * index()のブロックなしテスト
  *
  * @return void
  */
 public function testIndexNoneBlock()
 {
     //ログイン
     TestAuthGeneral::login($this);
     //テスト実施
     $frameId = '18';
     $url = array('plugin' => $this->plugin, 'controller' => $this->_controller, 'action' => 'index', 'frame_id' => $frameId);
     $result = $this->_testNcAction($url, array('method' => 'get'), null, 'viewFile');
     //チェック
     $this->assertTextEquals('Blocks.Blocks/not_found', $result);
     //ログアウト
     TestAuthGeneral::logout($this);
 }
コード例 #7
0
 /**
  * delete()のテスト
  *
  * @param array $data 削除データ
  * @dataProvider dataProviderDelete
  * @return void
  */
 public function testDelete($data)
 {
     //ログイン
     TestAuthGeneral::login($this);
     $frameId = '6';
     $blockId = '4';
     //アクション実行
     $url = NetCommonsUrl::actionUrl(array('plugin' => $this->plugin, 'controller' => $this->_controller, 'action' => 'delete', 'frame_id' => $frameId, 'block_id' => $blockId));
     $params = array('method' => 'delete', 'return' => 'view', 'data' => $data);
     $this->testAction($url, $params);
     //チェック
     $header = $this->controller->response->header();
     $asserts = array(array('method' => 'assertNotEmpty', 'value' => $header['Location']));
     $this->asserts($asserts, $this->contents);
     //ログアウト
     TestAuthGeneral::logout($this);
 }
コード例 #8
0
 /**
  * deleteアクションのPOSTテスト
  *
  * @param array $data POSTデータ
  * @param string $role ロール
  * @param array $urlOptions URLオプション
  * @param string|null $exception Exception
  * @param string $return testActionの実行後の結果
  * @dataProvider dataProviderDeletePost
  * @return void
  */
 public function testDeletePost($data, $role, $urlOptions, $exception = null, $return = 'view')
 {
     //ログイン
     if (isset($role)) {
         TestAuthGeneral::login($this, $role);
     }
     //テスト実施
     $this->_testPostAction('delete', $data, Hash::merge(array('action' => 'delete'), $urlOptions), $exception, $return);
     //正常の場合、リダイレクト
     if (!$exception) {
         $header = $this->controller->response->header();
         $this->assertNotEmpty($header['Location']);
     }
     //ログアウト
     if (isset($role)) {
         TestAuthGeneral::logout($this);
     }
 }