コード例 #1
0
 public function NotGetting500(Tester $I)
 {
     $I->wantToTest('whether we are getting any 500 error');
     $I->haveHttpHeader("apikey", $this->apiInfo[Helper::CSV_ORDER_APIKEY]);
     $I->sendGET("currenttime", ["source" => $this->apiInfo[Helper::CSV_ORDER_SOURCE]]);
     $I->dontSeeResponseCodeIs(500);
 }
コード例 #2
0
 /**
  * @test
  * it should insert a comment when hitting the endpoint with valid params
  */
 public function it_should_insert_a_comment_when_hitting_the_endpoint_with_valid_params(\FunctionalTester $I)
 {
     $post_id = $I->havePostInDatabase(['post_title' => 'Some post']);
     $I->amOnPage('/');
     $wp_rest_nonce = $I->grabValueFrom('input[name="rest_nonce"]');
     $I->haveHttpHeader('X-WP-Nonce', $wp_rest_nonce);
     $I->sendAjaxPostRequest('/wp-json/idlikethis/v1/button-click', ['post_id' => $post_id, 'content' => 'Some Content']);
     $I->seeResponseCodeIs(200);
     $I->seeCommentInDatabase(['comment_post_ID' => $post_id]);
 }
コード例 #3
0
 /**
  * @test
  * it should reset comments when post id is valid
  */
 public function it_should_reset_comments_when_post_id_is_valid(\FunctionalTester $I)
 {
     $post_id = $I->havePostInDatabase();
     $comment_ids = $I->haveManyCommentsInDatabase(3, $post_id, ['comment_type' => 'idlikethis']);
     $I->loginAsAdmin();
     $I->amEditingPostWithId($post_id);
     $wp_rest_nonce = $I->grabValueFrom('input[name="rest_nonce"]');
     $I->haveHttpHeader('X-WP-Nonce', $wp_rest_nonce);
     $I->sendAjaxPostRequest('/wp-json/idlikethis/v1/admin/reset-all', ['post_id' => $post_id]);
     $I->seeResponseCodeIs(200);
     foreach ($comment_ids as $comment_id) {
         $I->dontSeeCommentInDatabase(['comment_ID' => $comment_id, 'comment_post_ID' => $post_id]);
     }
 }
コード例 #4
0
 /**
  * @test
  * it should consolidate comments when post id is valid and user can edit posts
  */
 public function it_should_consolidate_comments_when_post_id_is_valid_and_user_can_edit_posts(\FunctionalTester $I)
 {
     $post_id = $I->havePostInDatabase();
     $comment_ids = $I->haveManyCommentsInDatabase(3, $post_id, ['comment_type' => 'idlikethis', 'comment_content' => '{{n}} - foo']);
     $I->loginAsAdmin();
     $I->amEditingPostWithId($post_id);
     $wp_rest_nonce = $I->grabValueFrom('input[name="rest_nonce"]');
     $I->haveHttpHeader('X-WP-Nonce', $wp_rest_nonce);
     $I->sendAjaxPostRequest('/wp-json/idlikethis/v1/admin/consolidate-all', ['post_id' => $post_id]);
     $I->seeResponseCodeIs(200);
     foreach ($comment_ids as $comment_id) {
         $I->dontSeeCommentInDatabase(['comment_ID' => $comment_id, 'comment_post_ID' => $post_id]);
     }
     $I->seePostMetaInDatabase(['post_id' => $post_id, 'meta_key' => '_idlikethis_votes', 'meta_value' => serialize(['foo' => 3])]);
 }
コード例 #5
0
 public function _before(FunctionalTester $I)
 {
     Artisan::call('db:truncate');
     $I->haveHttpHeader('Accept', 'application/json');
 }
コード例 #6
0
 public function OtherVerb(Tester $I)
 {
     $time = time();
     $I->wantTo('Test invalid Verb');
     $I->haveHttpHeader("apikey", $this->apikey);
     $I->haveHttpHeader("timestamp", $time);
     $I->haveHttpHeader("fingerprint", Helper::createFingerPrint($this->apikey, $this->secret, $time, 'POST', $this->resourceURL, $this->nric, $this->amount, $this->date, $this->source));
     $I->haveHttpHeader("Content-Type", 'application/x-www-form-urlencoded');
     $I->sendOPTIONS("updates", Helper::assemblePostData($this->nric, $this->amount, $this->date, $this->source));
     $I->seeResponseCodeIs(405);
 }