コード例 #1
0
 public function tryToTest(AcceptanceTester $I)
 {
     $I->expectARequestToRemoteServiceWithAResponse(Phiremock::on(A::getRequest()->andUrl(Is::equalTo('/some/url')))->then(Respond::withStatusCode(203)->andBody('I am a response')));
     $response = file_get_contents('http://localhost:18080/some/url');
     $I->assertEquals('I am a response', $response);
     $I->seeRemoteServiceReceived(1, A::getRequest()->andUrl(Is::equalTo('/some/url')));
 }
コード例 #2
0
 public function tryToTest(\AcceptanceTester $I)
 {
     $I->expectRequest()->when()->methodIs('GET')->pathIs('/foo')->then()->body('mocked body')->end();
     $I->doNotExpectAnyOtherRequest();
     $response = file_get_contents('http://localhost:18080/foo');
     $I->assertEquals('mocked body', $response);
 }
コード例 #3
0
ファイル: LikesCest.php プロジェクト: gultaj/toster
 public function likes(\AcceptanceTester $I)
 {
     $answer = App\Models\Answer::get()->random();
     $user = App\Models\User::get()->random();
     \Auth::login($user);
     $likes = $answer->likes->count();
     $I->wantTo('like answer');
     $I->amOnRoute('q', ['id' => $answer->question->id]);
     $I->see($answer->question->title);
     $c = $likes ? (int) $I->grabTextFrom('li#answer_' . $answer->id . ' a.btn_like .like_count') : 0;
     $I->assertEquals($likes, $c);
     $I->click('li#answer_' . $answer->id . ' a.btn_like');
     $I->amOnRoute('q', ['id' => $answer->question->id]);
     $answer = App\Models\Answer::find($answer->id);
     $I->assertEquals($likes + 1, $answer->likes->count());
 }
コード例 #4
0
ファイル: AppCest.php プロジェクト: bbig979/shoppyst
 private function unlikeComponent(\AcceptanceTester $I)
 {
     codecept_debug('unlikeComponent');
     $I->wait($this->fill_placeholder_wait);
     $pre_like_count = $I->grabTextFrom('.likes-count');
     $I->click('.ion-ios-heart');
     $I->waitForElement('.ion-ios-heart-outline', 10);
     $post_like_count = $I->grabTextFrom('.likes-count');
     $I->assertNotEquals($pre_like_count, $post_like_count);
     $I->wait($this->send_to_server_wait);
     $I->reloadPage();
     $I->wait($this->fill_placeholder_wait);
     $reload_like_count = $I->grabTextFrom('.likes-count');
     $I->assertEquals($reload_like_count, $post_like_count);
 }
コード例 #5
0
ファイル: TKPostCest.php プロジェクト: bbig979/shoppyst
 private function unlikePostOnCard(\AcceptanceTester $I)
 {
     $I->wantTo('unlike post on card');
     $I->amOnPage('/');
     // card
     $I->waitForElement('a.unlike-post[data-id="560"]', 10);
     $pre_like_count = $I->grabTextFrom('.like-post-count[data-id="560"]');
     $I->click('a.unlike-post[data-id="560"]');
     $I->waitForElementVisible('a.like-post[data-id="560"]', 10);
     $I->waitForElementNotVisible('a.unlike-post[data-id="560"]', 10);
     $post_like_count = $I->grabTextFrom('.like-post-count[data-id="560"]');
     $I->assertEquals($pre_like_count, $post_like_count + 1);
     $I->amOnPage('/post/560');
     $I->waitForElement('.like-post-count[data-id="560"]', 10);
     $post_like_count = $I->grabTextFrom('.like-post-count[data-id="560"]');
     $I->assertEquals($pre_like_count, $post_like_count + 1);
 }
コード例 #6
0
ファイル: UserCest.php プロジェクト: bbig979/shoppyst
 private function unlikePostOnCard(\AcceptanceTester $I)
 {
     codecept_debug('unlikePostOnCard');
     $I->amOnPage('/' . $this->user_slug . '/postgroups/' . $this->postgroup_slug);
     // card
     $I->waitForElement('.btn.unlike-post[data-id="' . $this->post_id . '"]', 10);
     $pre_like_count = $I->grabTextFrom('.like-post-count[data-id="' . $this->post_id . '"]');
     $I->click('.btn.unlike-post[data-id="' . $this->post_id . '"]');
     $I->waitForElementVisible('.btn.like-post[data-id="' . $this->post_id . '"]', 10);
     $I->waitForElementNotVisible('.btn.unlike-post[data-id="' . $this->post_id . '"]', 10);
     $post_like_count = $I->grabTextFrom('.like-post-count[data-id="' . $this->post_id . '"]');
     $I->assertEquals($pre_like_count, $post_like_count + 1);
     $I->amOnPage('/post/' . $this->post_id);
     $I->waitForElement('.like-post-count[data-id="' . $this->post_id . '"]', 10);
     $post_like_count = $I->grabTextFrom('.like-post-count[data-id="' . $this->post_id . '"]');
     $I->assertEquals($pre_like_count, $post_like_count + 1);
 }
コード例 #7
0
ファイル: ClientCest.php プロジェクト: mcustiel/phiremock
 public function countExecutionsWhenNoExpectationIsSet(AcceptanceTester $I)
 {
     $I->sendDELETE('/__phiremock/executions');
     $I->sendGET('/potato');
     $I->seeResponseCodeIs(404);
     $I->sendGET('/potato');
     $count = $this->phiremock->countExecutions(A::getRequest()->andUrl(Is::equalTo('/potato')));
     $I->assertEquals(2, $count);
     $count = $this->phiremock->countExecutions(A::getRequest()->andUrl(Is::matching('~potato~')));
     $I->assertEquals(2, $count);
 }
コード例 #8
0
 public function systeminfo_ログ表示(\AcceptanceTester $I)
 {
     $I->wantTo('EA0806-UC01-T01 ログ表示');
     // 表示
     $config = Fixtures::get('config');
     $I->amOnPage('/' . $config['admin_route'] . '/setting/system/log');
     $I->see('システム設定EC-CUBE ログ表示', '#main .page-header');
     $log = $I->grabValueFrom(['id' => 'admin_system_log_files']);
     $expect = "site_" . date('Y-m-d') . ".log";
     $I->assertEquals($expect, $log);
     $I->fillField(['id' => 'line-max'], '1');
     $I->click(['css' => '#form1 button']);
     $I->dontSeeElement(['css' => '#main .container-fluid .box table tbody tr:nth-child(2)']);
 }
コード例 #9
0
 public function product_商品詳細サムネイル(\AcceptanceTester $I)
 {
     $I->wantTo('EF0202-UC01-T03 商品詳細 サムネイル');
     $I->amOnPage('/products/detail/2');
     $config = Fixtures::get('test_config');
     // デフォルトサムネイル表示確認
     $img = $I->grabAttributeFrom('#item_photo_area .slick-active img', 'src');
     $I->assertEquals('http://' . $config['hostname'] . '/upload/save_image/cafe-1.jpg', $img, $img . ' が見つかりません');
     // 2個目のサムネイルクリック
     $I->click('#item_photo_area .slick-dots li:nth-child(2) button');
     $img = $I->grabAttributeFrom('#item_photo_area .slick-active img', 'src');
     $I->assertEquals('http://' . $config['hostname'] . '/upload/save_image/cafe-2.jpg', $img, $img . ' が見つかりません');
 }
コード例 #10
0
 /**
  * @depends sendEmails
  *
  * @param \AcceptanceTester $I
  */
 public function grabFromLastEmailTo(\AcceptanceTester $I)
 {
     $I->wantTo('Grab from last email to ' . $this->getToFirstAddress());
     $result = $I->grabFromLastEmailTo($this->getToFirstAddress(), '/Body ([_a-z0-9]+)/i');
     $I->assertEquals('Body ' . sqs('second'), $result, 'Can not find matches in email body');
 }
コード例 #11
0
 public function product_商品一覧表示件数(\AcceptanceTester $I)
 {
     $I->wantTo('EF0201-UC04-T01 商品一覧ページ 表示件数');
     $I->amOnPage('/');
     // TOPページ>商品一覧(ヘッダーのいずれかのカテゴリを選択)へ遷移
     $I->moveMouseOver(['css' => '#category .category-nav li:nth-child(2)']);
     $I->wait(3);
     $I->click('#header #category ul li:nth-child(2) a');
     // 各商品のサムネイルが表示される
     $config = Fixtures::get('test_config');
     $productNum = $config['fixture_product_num'] + 2;
     $itemNum = $productNum >= 15 ? 15 : $productNum;
     $products = $I->grabMultiple('#item_list .product_item');
     $I->assertTrue(count($products) == $itemNum);
     // 表示件数の選択リストを変更する
     $I->selectOption(['css' => "#page_navi_top select[name = 'disp_number']"], '30件');
     // 変更された表示件数分が1画面に表示される
     $expected = $productNum >= 30 ? 30 : $productNum;
     $products = $I->grabMultiple('#item_list .product_item');
     $actual = count($products);
     $I->assertEquals($expected, $actual, $expected . ' と ' . $actual . ' が異なります');
 }