GitHub PullRequestReviewCommentEvent at 2014-10-27 08:48:51
Repository: laravel_training
Actor: fr-sato
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/comments/19392907","id":19392907,"diff_hunk":"@@ -2,91 +2,108 @@\n \n class FormTest extends TestCase {\n \n-    public function setUp()\n-    {\n+    private $input_passes = array(\n+            'last_name'            => '秋山',\n+            'first_name'           => '好古',\n+            'sex'                  => '男性',\n+            'postalcode.zone'      => '123',\n+            'postalcode.district'  => '4567',\n+            'pref_id'              => '38',\n+            'email'                => 'clouds_over_the_slope@nxk.jp',\n+            'hobby'              => array(\n+                1              => '',\n+                2              => '',\n+                3              => 'その他：',\n+                4              => '読書'\n+            )\n+        );\n+\n+    private $input_fails = array(\n+            'last_name'            => '',\n+            'first_name'           => '',\n+            'sex'                  => '',\n+            'postalcode.zone'      => '',\n+            'postalcode.district'  => '',\n+            'pref_id'              => '',\n+            'email'                => '',\n+            'hobby'              => array(\n+                1              => '',\n+                2              => '',\n+                3              => '',\n+                4              => ''\n+            )\n+        );\n+\n+    public function setUp() {\n         parent::setUp();\n     }\n \n     //routing\n-    public function testRoutingGetIndex()\n-    {\n+    public function testRoutingGetIndex() {\n         $response = $this->call('GET', '/');\n         $this->assertResponseOk();\n     }\n \n-    public function testRoutingGetForm()\n-    {\n+    public function testRoutingGetForm() {\n         $response = $this->call('GET', 'form');\n         $this->assertResponseOk();\n-\n     }\n \n-    public function testRoutingPostConfirm()\n-    {\n+    public function testRoutingPostConfirm() {\n         $response = $this->call('POST', 'confirm');\n         $this->assertResponseOk();\n     }\n \n-    public function testCsrfRouteFilter()\n-    {\n+    public function testCsrfRouteFilter() {\n         $csrf_token = csrf_token();\n         $this->session(['_token' => $csrf_token]);\n         Route::enableFilters();\n         $response = $this->call('POST', 'confirm');\n         $this->assertResponseOk();\n-\n     }\n \n-    public function testRoutingPostDone()\n-    {\n+    public function testRoutingPostDone() {\n         $response = $this->call('POST', 'done');\n         $this->assertResponseOk();\n     }\n \n-    public function testValidateRedirect()\n-    {\n-        $response = $this->call('POST', 'confirm');\n-        //$this->assertRedirectedTo('form');\n-    }\n-\n     //Controller\n-    //空白トリム後,Input,Sessionにそれぞれ空白トリム後の値が渡っているか\n-    //Controllerのテストをここまで細分化しても却って煩雑な気がする\n-    public function testInputandSessionHasTrimedValues()\n-    {\n-\n-    }\n-\n     //値を渡す必要があるControllerでViewに値を渡せてるか\n-    public function testFormReturnsView()\n-    {\n-        $this->action('GET', 'FormController@getForm');\n+    public function testFormReturnsView() {\n+        $response = $this->action('GET', 'FormController@getForm');\n+        $this->assertEquals('form', $response->original->getName());\n         $this->assertViewHas('data');\n     }\n \n-    public function testConfirmReturnsView()\n-    {\n+    public function testConfirmReturnsView() {\n         $this->action('POST', 'FormController@postConfirm');\n         $this->assertViewHas('hobby_view');\n         $this->assertViewHas('pref_view');\n     }\n \n     //Validators\n-    public function testValidate_true()\n-    {\n-        // $validator = Validator::make($input, $rules);\n-        // $validator->\n-        // $this->assertTrue($validator->passes());\n+    public function testValidate_true() {\n+        $response = $this->action('POST', 'FormController@postConfirm', array(), $this->input_passes);\n+        $this->assertEquals('confirm', $response->original->getName());\n+        $this->assertViewHas('hobby_view', 'その他： 読書');\n+        $this->assertViewHas('pref_view', '愛媛県');\n     }\n \n-    public function testValidate_false()","path":"app/tests/FormTest.php","position":128,"original_position":128,"commit_id":"ec2ac74840d3b11a2c50b6ec51965dab6ec3f3f1","original_commit_id":"ec2ac74840d3b11a2c50b6ec51965dab6ec3f3f1","user":{"login":"fr-sato","id":1913106,"avatar_url":"https://avatars.githubusercontent.com/u/1913106?v=2","gravatar_id":"","url":"https://api.github.com/users/fr-sato","html_url":"https://github.com/fr-sato","followers_url":"https://api.github.com/users/fr-sato/followers","following_url":"https://api.github.com/users/fr-sato/following{/other_user}","gists_url":"https://api.github.com/users/fr-sato/gists{/gist_id}","starred_url":"https://api.github.com/users/fr-sato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fr-sato/subscriptions","organizations_url":"https://api.github.com/users/fr-sato/orgs","repos_url":"https://api.github.com/users/fr-sato/repos","events_url":"https://api.github.com/users/fr-sato/events{/privacy}","received_events_url":"https://api.github.com/users/fr-sato/received_events","type":"User","site_admin":false},"body":"validateのテストをするのであれば、可能であれば全ての値が正常に返ってきているかをチェックした方がよいです。\r\nその際、`input_passes`を上手く使って簡潔に書くと尚良いかなと思います。","created_at":"2014-10-27T08:48:51Z","updated_at":"2014-10-27T08:48:51Z","html_url":"https://github.com/fr-itaya/laravel_training/pull/9#discussion_r19392907","pull_request_url":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/comments/19392907"},"html":{"href":"https://github.com/fr-itaya/laravel_training/pull/9#discussion_r19392907"},"pull_request":{"href":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/9","id":22767055,"html_url":"https://github.com/fr-itaya/laravel_training/pull/9","diff_url":"https://github.com/fr-itaya/laravel_training/pull/9.diff","patch_url":"https://github.com/fr-itaya/laravel_training/pull/9.patch","issue_url":"https://api.github.com/repos/fr-itaya/laravel_training/issues/9","number":9,"state":"open","locked":false,"title":"[WIP]Laravel4製フォームのテスト- Controller - Logic","user":{"login":"fr-itaya","id":7111591,"avatar_url":"https://avatars.githubusercontent.com/u/7111591?v=2","gravatar_id":"","url":"https://api.github.com/users/fr-itaya","html_url":"https://github.com/fr-itaya","followers_url":"https://api.github.com/users/fr-itaya/followers","following_url":"https://api.github.com/users/fr-itaya/following{/other_user}","gists_url":"https://api.github.com/users/fr-itaya/gists{/gist_id}","starred_url":"https://api.github.com/users/fr-itaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fr-itaya/subscriptions","organizations_url":"https://api.github.com/users/fr-itaya/orgs","repos_url":"https://api.github.com/users/fr-itaya/repos","events_url":"https://api.github.com/users/fr-itaya/events{/privacy}","received_events_url":"https://api.github.com/users/fr-itaya/received_events","type":"User","site_admin":false},"body":"# WIP!\r\n## 概要\r\n研修で作成したフォームのコントローラのテストを記述します。\r\n当該箇所のテストはhttps://github.com/fr-itaya/laravel_training/pull/6 にてPENDINGとしましたが、次の方策で書き直します。\r\n- 正常系・異常系のテストにとどめる\r\n- バリデートが通る場合、通らない場合の入力値を設定する\r\n- 上記をそれぞれコントローラの各メソッドに通した場合、期待される動作について記述する\r\n- 今回uniqueを設定しているカラムがないので同一カラムに同じデータ(ex.email)が存在していても無視する\r\n\r\n## TODO\r\n###### 前PRからの修正\r\n- [x] 全ファイル不要な空行を詰める\r\n- [x] クラス定義・関数定義の波括弧の開始位置を統一する\r\n  - 列ハイライトを設定している関係上括弧が並ぶと見辛いので、閉じ括弧と並ばないようにします。\r\n\r\n###### 本題\r\n- 入力が正常である場合\r\n  - ~~TOP画面ではセッションは値を持っていない~~ top画面アクセスした時点でcsrf_tokenをセッションに埋め込んでいるので無し。\r\n  - [x] バリデータが通っていたら、一部の入力データを確認画面表示用に加工してViewと共に渡している\r\n  - [x] $hobby_viewには入力値を全て結合した文字列が入っている\r\n  - [x] $pref_viewにはpref_idに対応した都道府県名が入っている\r\n  - [x] 完了画面のViewを返している\r\n  - [ ] DBのusersテーブルにレコードが挿入されている\r\n\r\n- 入力値が異常である場合(バリデータの機能はUserValidatorTest.phpで担保されているのでここでは未入力とする)\r\n  - [x] postConfirmでバリデートが通らず、formへリダイレクトされる\r\n  - [x] リダイレクト時、セッションが直前の入力値を持っている\r\n  - [x] リダイレクト時、セッションがエラーを持っている\r\n\r\n## 懸案事項\r\n残るテスト項目は下記の通り。\r\n現在DB周りの操作をコントローラで行っていますが、テストをどこでやるべきか検討中です。\r\n  - ~~都道府県IDと都道府県名を取得する操作@フォーム画面~~\r\n  - ~~入力データをDBのUsersに挿入する操作@完了画面~~","created_at":"2014-10-15T08:15:31Z","updated_at":"2014-10-27T08:48:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"162f85622d58b66b200124afcbaf63deed52e12d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/9/commits","review_comments_url":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/9/comments","review_comment_url":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/comments/{number}","comments_url":"https://api.github.com/repos/fr-itaya/laravel_training/issues/9/comments","statuses_url":"https://api.github.com/repos/fr-itaya/laravel_training/statuses/ec2ac74840d3b11a2c50b6ec51965dab6ec3f3f1","head":{"label":"fr-itaya:feature/44_laravel_with_PHPUnit_Controller","ref":"feature/44_laravel_with_PHPUnit_Controller","sha":"ec2ac74840d3b11a2c50b6ec51965dab6ec3f3f1","user":{"login":"fr-itaya","id":7111591,"avatar_url":"https://avatars.githubusercontent.com/u/7111591?v=2","gravatar_id":"","url":"https://api.github.com/users/fr-itaya","html_url":"https://github.com/fr-itaya","followers_url":"https://api.github.com/users/fr-itaya/followers","following_url":"https://api.github.com/users/fr-itaya/following{/other_user}","gists_url":"https://api.github.com/users/fr-itaya/gists{/gist_id}","starred_url":"https://api.github.com/users/fr-itaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fr-itaya/subscriptions","organizations_url":"https://api.github.com/users/fr-itaya/orgs","repos_url":"https://api.github.com/users/fr-itaya/repos","events_url":"https://api.github.com/users/fr-itaya/events{/privacy}","received_events_url":"https://api.github.com/users/fr-itaya/received_events","type":"User","site_admin":false},"repo":{"id":21406889,"name":"laravel_training","full_name":"fr-itaya/laravel_training","owner":{"login":"fr-itaya","id":7111591,"avatar_url":"https://avatars.githubusercontent.com/u/7111591?v=2","gravatar_id":"","url":"https://api.github.com/users/fr-itaya","html_url":"https://github.com/fr-itaya","followers_url":"https://api.github.com/users/fr-itaya/followers","following_url":"https://api.github.com/users/fr-itaya/following{/other_user}","gists_url":"https://api.github.com/users/fr-itaya/gists{/gist_id}","starred_url":"https://api.github.com/users/fr-itaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fr-itaya/subscriptions","organizations_url":"https://api.github.com/users/fr-itaya/orgs","repos_url":"https://api.github.com/users/fr-itaya/repos","events_url":"https://api.github.com/users/fr-itaya/events{/privacy}","received_events_url":"https://api.github.com/users/fr-itaya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fr-itaya/laravel_training","description":"","fork":false,"url":"https://api.github.com/repos/fr-itaya/laravel_training","forks_url":"https://api.github.com/repos/fr-itaya/laravel_training/forks","keys_url":"https://api.github.com/repos/fr-itaya/laravel_training/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fr-itaya/laravel_training/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fr-itaya/laravel_training/teams","hooks_url":"https://api.github.com/repos/fr-itaya/laravel_training/hooks","issue_events_url":"https://api.github.com/repos/fr-itaya/laravel_training/issues/events{/number}","events_url":"https://api.github.com/repos/fr-itaya/laravel_training/events","assignees_url":"https://api.github.com/repos/fr-itaya/laravel_training/assignees{/user}","branches_url":"https://api.github.com/repos/fr-itaya/laravel_training/branches{/branch}","tags_url":"https://api.github.com/repos/fr-itaya/laravel_training/tags","blobs_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/refs{/sha}","trees_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fr-itaya/laravel_training/statuses/{sha}","languages_url":"https://api.github.com/repos/fr-itaya/laravel_training/languages","stargazers_url":"https://api.github.com/repos/fr-itaya/laravel_training/stargazers","contributors_url":"https://api.github.com/repos/fr-itaya/laravel_training/contributors","subscribers_url":"https://api.github.com/repos/fr-itaya/laravel_training/subscribers","subscription_url":"https://api.github.com/repos/fr-itaya/laravel_training/subscription","commits_url":"https://api.github.com/repos/fr-itaya/laravel_training/commits{/sha}","git_commits_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/commits{/sha}","comments_url":"https://api.github.com/repos/fr-itaya/laravel_training/comments{/number}","issue_comment_url":"https://api.github.com/repos/fr-itaya/laravel_training/issues/comments/{number}","contents_url":"https://api.github.com/repos/fr-itaya/laravel_training/contents/{+path}","compare_url":"https://api.github.com/repos/fr-itaya/laravel_training/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fr-itaya/laravel_training/merges","archive_url":"https://api.github.com/repos/fr-itaya/laravel_training/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fr-itaya/laravel_training/downloads","issues_url":"https://api.github.com/repos/fr-itaya/laravel_training/issues{/number}","pulls_url":"https://api.github.com/repos/fr-itaya/laravel_training/pulls{/number}","milestones_url":"https://api.github.com/repos/fr-itaya/laravel_training/milestones{/number}","notifications_url":"https://api.github.com/repos/fr-itaya/laravel_training/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fr-itaya/laravel_training/labels{/name}","releases_url":"https://api.github.com/repos/fr-itaya/laravel_training/releases{/id}","created_at":"2014-07-02T00:57:46Z","updated_at":"2014-10-14T03:38:05Z","pushed_at":"2014-10-27T08:45:36Z","git_url":"git://github.com/fr-itaya/laravel_training.git","ssh_url":"git@github.com:fr-itaya/laravel_training.git","clone_url":"https://github.com/fr-itaya/laravel_training.git","svn_url":"https://github.com/fr-itaya/laravel_training","homepage":null,"size":1292,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"fr-itaya:feature/44_laravel_with_PHPUnit_Model_Validate","ref":"feature/44_laravel_with_PHPUnit_Model_Validate","sha":"0f2d74efeb73b90dddf364dffe592d13159984cb","user":{"login":"fr-itaya","id":7111591,"avatar_url":"https://avatars.githubusercontent.com/u/7111591?v=2","gravatar_id":"","url":"https://api.github.com/users/fr-itaya","html_url":"https://github.com/fr-itaya","followers_url":"https://api.github.com/users/fr-itaya/followers","following_url":"https://api.github.com/users/fr-itaya/following{/other_user}","gists_url":"https://api.github.com/users/fr-itaya/gists{/gist_id}","starred_url":"https://api.github.com/users/fr-itaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fr-itaya/subscriptions","organizations_url":"https://api.github.com/users/fr-itaya/orgs","repos_url":"https://api.github.com/users/fr-itaya/repos","events_url":"https://api.github.com/users/fr-itaya/events{/privacy}","received_events_url":"https://api.github.com/users/fr-itaya/received_events","type":"User","site_admin":false},"repo":{"id":21406889,"name":"laravel_training","full_name":"fr-itaya/laravel_training","owner":{"login":"fr-itaya","id":7111591,"avatar_url":"https://avatars.githubusercontent.com/u/7111591?v=2","gravatar_id":"","url":"https://api.github.com/users/fr-itaya","html_url":"https://github.com/fr-itaya","followers_url":"https://api.github.com/users/fr-itaya/followers","following_url":"https://api.github.com/users/fr-itaya/following{/other_user}","gists_url":"https://api.github.com/users/fr-itaya/gists{/gist_id}","starred_url":"https://api.github.com/users/fr-itaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fr-itaya/subscriptions","organizations_url":"https://api.github.com/users/fr-itaya/orgs","repos_url":"https://api.github.com/users/fr-itaya/repos","events_url":"https://api.github.com/users/fr-itaya/events{/privacy}","received_events_url":"https://api.github.com/users/fr-itaya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fr-itaya/laravel_training","description":"","fork":false,"url":"https://api.github.com/repos/fr-itaya/laravel_training","forks_url":"https://api.github.com/repos/fr-itaya/laravel_training/forks","keys_url":"https://api.github.com/repos/fr-itaya/laravel_training/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fr-itaya/laravel_training/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fr-itaya/laravel_training/teams","hooks_url":"https://api.github.com/repos/fr-itaya/laravel_training/hooks","issue_events_url":"https://api.github.com/repos/fr-itaya/laravel_training/issues/events{/number}","events_url":"https://api.github.com/repos/fr-itaya/laravel_training/events","assignees_url":"https://api.github.com/repos/fr-itaya/laravel_training/assignees{/user}","branches_url":"https://api.github.com/repos/fr-itaya/laravel_training/branches{/branch}","tags_url":"https://api.github.com/repos/fr-itaya/laravel_training/tags","blobs_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/refs{/sha}","trees_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fr-itaya/laravel_training/statuses/{sha}","languages_url":"https://api.github.com/repos/fr-itaya/laravel_training/languages","stargazers_url":"https://api.github.com/repos/fr-itaya/laravel_training/stargazers","contributors_url":"https://api.github.com/repos/fr-itaya/laravel_training/contributors","subscribers_url":"https://api.github.com/repos/fr-itaya/laravel_training/subscribers","subscription_url":"https://api.github.com/repos/fr-itaya/laravel_training/subscription","commits_url":"https://api.github.com/repos/fr-itaya/laravel_training/commits{/sha}","git_commits_url":"https://api.github.com/repos/fr-itaya/laravel_training/git/commits{/sha}","comments_url":"https://api.github.com/repos/fr-itaya/laravel_training/comments{/number}","issue_comment_url":"https://api.github.com/repos/fr-itaya/laravel_training/issues/comments/{number}","contents_url":"https://api.github.com/repos/fr-itaya/laravel_training/contents/{+path}","compare_url":"https://api.github.com/repos/fr-itaya/laravel_training/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fr-itaya/laravel_training/merges","archive_url":"https://api.github.com/repos/fr-itaya/laravel_training/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fr-itaya/laravel_training/downloads","issues_url":"https://api.github.com/repos/fr-itaya/laravel_training/issues{/number}","pulls_url":"https://api.github.com/repos/fr-itaya/laravel_training/pulls{/number}","milestones_url":"https://api.github.com/repos/fr-itaya/laravel_training/milestones{/number}","notifications_url":"https://api.github.com/repos/fr-itaya/laravel_training/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fr-itaya/laravel_training/labels{/name}","releases_url":"https://api.github.com/repos/fr-itaya/laravel_training/releases{/id}","created_at":"2014-07-02T00:57:46Z","updated_at":"2014-10-14T03:38:05Z","pushed_at":"2014-10-27T08:45:36Z","git_url":"git://github.com/fr-itaya/laravel_training.git","ssh_url":"git@github.com:fr-itaya/laravel_training.git","clone_url":"https://github.com/fr-itaya/laravel_training.git","svn_url":"https://github.com/fr-itaya/laravel_training","homepage":null,"size":1292,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/9"},"html":{"href":"https://github.com/fr-itaya/laravel_training/pull/9"},"issue":{"href":"https://api.github.com/repos/fr-itaya/laravel_training/issues/9"},"comments":{"href":"https://api.github.com/repos/fr-itaya/laravel_training/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/fr-itaya/laravel_training/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/fr-itaya/laravel_training/statuses/ec2ac74840d3b11a2c50b6ec51965dab6ec3f3f1"}}}}