public function topページ_初期表示(\AcceptanceTester $I) { $I->wantTo('EF0101-UC01-T01 TOPページ 初期表示'); $I->amOnPage('/'); // カテゴリ選択ボックス(キーワード検索用)、キーワード検索入力欄、虫眼鏡ボタンが表示されている $I->see('全ての商品', '#search #category_id'); $I->see('', '#search #name'); $I->see('', '#search .bt_search'); // カテゴリ名(カテゴリ検索用)が表示されている $categories = Fixtures::get('categories'); foreach ($categories as $category) { $I->see($category->getName(), '#search #category_id option'); } //管理側のコンテンツ管理(新着情報管理)に設定されている情報が、順位順に表示されている $today = new DateTime(); $minus1 = $today->sub(new DateInterval('P1D')); $minus2 = $today->sub(new DateInterval('P2D')); $I->haveInDatabase('dtb_news', array('news_id' => rand(999, 9999), 'news_date' => $minus1->format('Y-m-d 00:00:00'), 'news_title' => 'タイトル1', 'news_comment' => 'コメント1', 'creator_id' => 1, 'rank' => 2, 'create_date' => $today->format('Y-m-d 00:00:00'), 'update_date' => $today->format('Y-m-d 00:00:00'))); $I->haveInDatabase('dtb_news', array('news_id' => rand(999, 9999), 'news_date' => $minus2->format('Y-m-d 00:00:00'), 'news_title' => 'タイトル2', 'news_comment' => 'コメント2', 'creator_id' => 1, 'rank' => 3, 'create_date' => $today->format('Y-m-d 00:00:00'), 'update_date' => $today->format('Y-m-d 00:00:00'))); $I->reloadPage(); $news = Fixtures::get('news'); $newsset = array(); $newsset[] = array('date' => $news[0]->getDate(), 'title' => $news[0]->getTitle(), 'comment' => $news[0]->getComment()); $newsset[] = array('date' => $minus1->format('Y-m-d 00:00:00'), 'title' => 'タイトル1', 'comment' => 'コメント1'); $newsset[] = array('date' => $minus2->format('Y-m-d 00:00:00'), 'title' => 'タイトル2', 'comment' => 'コメント2'); foreach ($newsset as $key => $news) { $I->see($news['title'], '#news_area .newslist dl:nth-child(' . (count($newsset) - $key) . ') .news_title'); } }
/** * Loads fixture data. * * @return void * @since 0.1.0 */ public function loadRuntimeFixtures() { $serverName = false; if (isset($_SERVER['SERVER_NAME'])) { $serverName = $_SERVER['SERVER_NAME']; } $maps = array('users' => array('username' => 'login', 'rawPassword' => 'password'), 'posts' => array('name' => 'title', 'user_id' => 'author', 'category_id' => 'category'), 'categories' => array('name' => 'title')); $dbFixtures = \Yii::app()->fixtureManager->getFixtures(); foreach ($maps as $fixture => $map) { $data = (require $dbFixtures[$fixture]); $index = 0; $keyBase = "data:{$fixture}"; foreach ($data as $item) { Fixtures::add($keyBase, $item); foreach ($item as $field => $value) { if (isset($map[$field])) { $key = $keyBase . "[{$index}]:" . $map[$field]; } else { $key = $keyBase . "[{$index}]:" . $field; } Fixtures::add($key, $value); } $index++; } Fixtures::add($keyBase . ':length', $index); } Fixtures::add('data:random:int', mt_rand(0, PHP_INT_MAX)); Fixtures::add('data:random:string', md5(Fixtures::get('data:random:int'))); Fixtures::add('defaults:app:language', \Yii::app()->language); Fixtures::add('defaults:app:name', \Yii::app()->name); Fixtures::add('defaults:app:theme', \Yii::app()->theme->name); Fixtures::add('defaults:server:host', $serverName); }
public function setStock($pid, $stock = 0) { if (!$pid) { return; } $app = Fixtures::get('app'); if (!is_array($stock)) { $pc = $app['orm.em']->getRepository('Eccube\\Entity\\ProductClass')->findOneBy(array('Product' => $pid)); $pc->setStock($stock); $pc->setStockUnlimited(Constant::DISABLED); $ps = $app['orm.em']->getRepository('Eccube\\Entity\\ProductStock')->findOneBy(array('ProductClass' => $pc->getId())); $ps->setStock($stock); $app['orm.em']->persist($pc); $app['orm.em']->persist($ps); $app['orm.em']->flush(); } else { $pcs = $app['orm.em']->getRepository('Eccube\\Entity\\ProductClass')->createQueryBuilder('o')->where('o.Product = ' . $pid)->andwhere('o.ClassCategory1 > 0')->getQuery()->getResult(); foreach ($pcs as $key => $pc) { $pc->setStock($stock[$key]); $pc->setStockUnlimited(Constant::DISABLED); $pc->setSaleLimit(2); $ps = $app['orm.em']->getRepository('Eccube\\Entity\\ProductStock')->findOneBy(array('ProductClass' => $pc->getId())); $ps->setStock($stock[$key]); $app['orm.em']->persist($pc); $app['orm.em']->persist($ps); $app['orm.em']->flush(); } } }
public function basicinfo_特定商取引法(\AcceptanceTester $I) { $I->wantTo('EA0702-UC01-T01 特定商取引法'); $faker = Fixtures::get('faker'); $email = microtime(true) . '.' . $faker->safeEmail; TradelawSettingPage::go($I)->入力_販売業者('販売業者')->入力_運営責任者('運営責任者')->入力_郵便番号1('530')->入力_郵便番号2('0001')->入力_都道府県('大阪府')->入力_市区町村名('大阪市北区')->入力_番地_ビル名('梅田2-4-9 ブリーゼタワー13F')->入力_電話番号1('111')->入力_電話番号2('111')->入力_電話番号3('111')->入力_Eメール($email)->入力_URL('http://www.ec-cube.net')->入力_商品代金以外の必要料金('term01')->入力_注文方法('term02')->入力_支払方法('term03')->入力_支払期限('term04')->入力_引き渡し時期('term05')->入力_返品交換について('term06')->登録(); $I->see('登録が完了しました。', TradelawSettingPage::$登録完了メッセージ); }
/** * Resets application settings. * * @return void * @since 0.1.0 */ public function resetApplicationSettings() { $appModel = new \ApplicationModel(); $appModel->language = Fixtures::get('defaults:app:language'); $appModel->name = Fixtures::get('defaults:app:name'); $appModel->theme = Fixtures::get('defaults:app:theme'); $appModel->save(); }
protected function _after() { $defaultServerName = Fixtures::get('defaults:server:host'); if ($defaultServerName) { $_SERVER['SERVER_NAME'] = $defaultServerName; } else { unset($_SERVER['SERVER_NAME']); } }
/** * Define custom actions here */ function checkIfLogin(\AcceptanceTester $I) { //if ($I->loadSessionSnapshot('login')) return; $I->amOnPage('/login'); $I->fillField(['name' => 'email'], Fixtures::get('username')); $I->fillField(['name' => 'password'], Fixtures::get('password')); $I->click('Let\'s go'); //$I->saveSessionSnapshot('login'); }
public function topページ_初期表示(\AcceptanceTester $I) { $I->wantTo('EA0101-UC01-T01 TOPページ 初期表示'); // TOP画面に現在の受注状況、お知らせ、売り上げ状況、ショップ状況が表示されている $I->see('受注状況', TopPage::$受付状況); $I->see('お知らせ', TopPage::$お知らせ); $I->see('売り上げ状況', TopPage::$売上状況); $I->see('ショップ状況', TopPage::$ショップ状況); // 新規受付をクリックすると受注管理画面に遷移することを確認 $I->click(TopPage::$受付状況_新規受付); $I->see('受注マスター', self::ページタイトル); $I->goToAdminPage(); // 購入された商品が受注管理画面のページにて反映されていることを確認 $config = Fixtures::get('config'); $findOrders = Fixtures::get('findOrders'); $NewOrders = array_filter($findOrders(), function ($Order) use($config) { return $Order->getOrderStatus()->getId() == $config['order_new']; }); $I->see(count($NewOrders), TopPage::$受付状況_新規受付数); // FIXME [issue] ソート順が指定されていないのでテストが失敗する // https://github.com/EC-CUBE/ec-cube/issues/1908 // // 入金待ちをクリックすると「受注管理>入金待ち」のページに遷移することを確認 // $I->click(TopPage::$受付状況_入金待ち); // $I->see('受注マスター', self::ページタイトル); // $I->seeInField(OrderManagePage::$検索条件_受注ステータス, '2'/*入金待ち*/); // $I->goToAdminPage(); // // // 入金済みをクリックすると「受注管理>入金済み」のページに遷移することを確認 // $I->click(TopPage::$受付状況_入金済み); // $I->see('受注マスター', self::ページタイトル); // $I->seeInField(OrderManagePage::$検索条件_受注ステータス, '6'/*入金済み*/); // $I->goToAdminPage(); // // // 取り寄せ中をクリックすると「受注管理>取り寄せ」のページに遷移することを確認 // $I->click(TopPage::$受付状況_取り寄せ中); // $I->see('受注マスター', self::ページタイトル); // $I->seeInField(OrderManagePage::$検索条件_受注ステータス, '4'/*取り寄せ中*/); // $I->goToAdminPage(); // お知らせの記事をクリックすると設定されたURLに遷移することを確認 $I->executeJS('document.querySelector("iframe.link_list_wrap").setAttribute("name", "news_frame")'); $I->switchToIFrame("news_frame"); $I->click(['css' => '.news_area .link_list .tableish a:nth-child(3)']); $I->switchToNewWindow(); $I->seeInTitle("全商品 / ECサイト構築・リニューアルは「ECオープンプラットフォームEC-CUBE」"); $I->switchToWindow(); $I->switchToIFrame(); // ショップ情報の在庫切れ商品をクリックすると商品管理ページに遷移することを確認 $I->click(TopPage::$ショップ状況_在庫切れ商品); $I->see('商品マスター', self::ページタイトル); $I->goToAdminPage(); // ショップ情報の会員数をクリックすると会員管理に遷移することを確認 $I->click(TopPage::$ショップ状況_会員数); $I->see('会員マスター', self::ページタイトル); $I->dontSeeCheckboxIsChecked(CustomerManagePage::$検索条件_仮会員); $I->seeCheckboxIsChecked(CustomerManagePage::$検索条件_本会員); }
public function onlinePayment(AcceptanceTester $I) { $I->wantTo('test an online payment'); $clientEmail = $this->faker->safeEmail; $productKey = $this->faker->text(10); // set gateway info $I->wantTo('create a gateway'); $I->amOnPage('/company/payments'); if (strpos($I->grabFromCurrentUrl(), 'create') > 0) { $I->fillField(['name' => '23_apiKey'], Fixtures::get('gateway_key')); $I->selectOption('#token_billing_type_id', 4); $I->click('Save'); $I->see('Successfully created gateway'); } // create client $I->amOnPage('/clients/create'); $I->fillField(['name' => 'email'], $clientEmail); $I->click('Save'); $I->see($clientEmail); // create product $I->amOnPage('/products/create'); $I->fillField(['name' => 'product_key'], $productKey); $I->fillField(['name' => 'notes'], $this->faker->text(80)); $I->fillField(['name' => 'cost'], $this->faker->numberBetween(1, 20)); $I->click('Save'); $I->see($productKey); // create invoice $I->amOnPage('/invoices/create'); $I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle'); $I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey); $I->click('Save'); $I->see($clientEmail); // enter payment $clientId = $I->grabFromDatabase('contacts', 'client_id', ['email' => $clientEmail]); $invoiceId = $I->grabFromDatabase('invoices', 'id', ['client_id' => $clientId]); $invitationKey = $I->grabFromDatabase('invitations', 'invitation_key', ['invoice_id' => $invoiceId]); $clientSession = $I->haveFriend('client'); $clientSession->does(function (AcceptanceTester $I) use($invitationKey) { $I->amOnPage('/view/' . $invitationKey); $I->click('Pay Now'); $I->fillField(['name' => 'first_name'], $this->faker->firstName); $I->fillField(['name' => 'last_name'], $this->faker->lastName); $I->fillField(['name' => 'address1'], $this->faker->streetAddress); $I->fillField(['name' => 'address2'], $this->faker->streetAddress); $I->fillField(['name' => 'city'], $this->faker->city); $I->fillField(['name' => 'state'], $this->faker->state); $I->fillField(['name' => 'postal_code'], $this->faker->postcode); $I->selectDropdown($I, 'United States', '.country-select .dropdown-toggle'); $I->fillField(['name' => 'card_number'], '4242424242424242'); $I->fillField(['name' => 'cvv'], '1234'); $I->selectOption('#expiration_month', 12); $I->selectOption('#expiration_year', date('Y')); $I->click('.btn-success'); $I->see('Successfully applied payment'); }); }
protected function getValueFromArray($param) { $value = null; preg_match_all(static::$regEx['array'], $param, $args); $array = Fixtures::get($args['var'][0]); if (array_key_exists($args['key'][0], $array)) { $value = $array[$args['key'][0]]; } return $value; }
private function sendRequest($url, $data, $type = 'POST') { $url = Fixtures::get('url') . '/api/v1/' . $url; $data = json_encode($data); $curl = curl_init(); $opts = [CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => $type, CURLOPT_POST => $type === 'POST' ? 1 : 0, CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Content-Length: ' . strlen($data), 'X-Ninja-Token: ' . $this->token]]; curl_setopt_array($curl, $opts); $response = curl_exec($curl); curl_close($curl); return json_decode($response); }
protected function _before() { $grav = Fixtures::get('grav'); $this->grav = $grav(); $this->pages = $this->grav['pages']; $this->grav['config']->set('system.home.alias', '/home'); /** @var UniformResourceLocator $locator */ $locator = $this->grav['locator']; $locator->addPath('page', '', 'tests/fake/simple-site/user/pages', false); $this->pages->init(); }
/** * { @inheritdoc } */ protected function setUp() { parent::setUp(); if (Codeception\Codecept::VERSION >= '2.1.0') { $this->module = $this->moduleContainer->getModule('\\Codeception\\Module\\Drupal7\\Drupal7'); } else { $this->module = $this->getModule('\\Codeception\\Module\\Drupal7\\Drupal7'); } $this->validConfig = Fixtures::get('validModuleConfig'); $this->invalidConfig = Fixtures::get('invalidModuleConfig'); }
public function testClassIsInitializedProperly() { $this->assertEquals("schema", $this->import->type, "the type is set to 'schema'"); $this->assertEquals("updatedata.csv", $this->import->file, "the file is set to 'updatedata.csv'"); $this->assertEquals(81, $this->import->vocabId, "the vocabid is set to '81'"); $this->assertTrue(is_integer($this->import->vocabId), "the vocabid is an integer"); $this->assertEquals( Fixtures::get("importFolder")."updatedata.csv", $this->import->importFolder . $this->import->file, "the path is set" ); }
public function tryToTest(AcceptanceTester $I) { $I->wantTo('perform actions and see result'); $I->amOnPage('/'); $I->see('くらしを楽しむライフスタイルグッズ', '.copy'); $shopName = $I->grabFromDatabase('dtb_base_info', 'shop_name'); $I->assertEquals('EC-CUBE3 SHOP', $shopName); $products = $I->grabFromDatabase('dtb_product', 'status', array('product_id' => 1)); codecept_debug($products); $bi = Fixtures::get('baseinfo'); codecept_debug($bi->getShopName()); foreach (Fixtures::get('categories') as $category) { codecept_debug($category->getName()); } }
/** * Scrape a category with pages */ public function testCanScrapePaginatedPage() { $broadside = array_fill(0, 20, Fixtures::get('broadside')); $responses = array_merge([Fixtures::get('aleAndStout')], $broadside, [Fixtures::get('aleAndStoutPage2')], $broadside, [Fixtures::get('aleAndStoutPage3')], $broadside, [Fixtures::get('aleAndStoutPage4')], $broadside, [Fixtures::get('aleAndStoutPage5')], $broadside, [Fixtures::get('aleAndStoutPage6')], $broadside, [Fixtures::get('aleAndStoutPage7')], array_fill(0, 16, Fixtures::get('broadside'))); $this->scraper->setHttpClient($this->getHttpClient($responses)); $output = $this->scraper->scrape('http://www.sainsburys.mock/shop/gb/groceries/drinks/ale-stout'); $this->assertInternalType('object', $output, "Scrape must return an object"); $this->assertInternalType('array', $output->results, "Scrape must an array of results"); $this->assertEquals(136, count($output->results), "The results contains the correct number of products"); $this->assertEquals("410.1", $output->total, "The total unit price is correct"); $this->assertEquals("Adnams Broadside Ale 500ml", $output->results[0]->title, "The product title is correct"); $this->assertEquals("2.00", $output->results[0]->unit_price, "The product unit price is correct"); $this->assertEquals("40.46kb", $output->results[0]->size, "The product HTML page size is correct"); $this->assertContains("Broadside is brewed to commemorate the Battle of Sole Bay (1672). This dark ruby red beer is full of fruitcake flavours and is great savoured with some strong cheddar.", $output->results[0]->description, "The product description is correct"); }
public function testAuthentication() { $username = Fixtures::get('data:users[0]:login'); $password = Fixtures::get('data:users[0]:password'); \Yii::app()->fixtureManager->prepare(); // setting inexsiting username $identity = new \UserIdentity(md5(mt_rand(0, PHP_INT_MAX)), $password); $this->assertFalse($identity->authenticate()); $this->assertSame($identity->errorCode, \UserIdentity::ERROR_USERNAME_INVALID); // setting inexisting password $identity->password = $identity->username; $identity->username = $username; $this->assertFalse($identity->authenticate()); $this->assertSame($identity->errorCode, \UserIdentity::ERROR_PASSWORD_INVALID); $identity->password = $password; $this->assertTrue($identity->authenticate()); $this->assertSame($identity->errorCode, \UserIdentity::ERROR_NONE); }
/** * Clean up after acceptance test suite run. * * We will copy the configs and database used to cache for inspection, really * only useful on test development runs but little impact overall. * * @param \Codeception\Event\SuiteEvent $e */ private function afterSuiteAcceptance(SuiteEvent $e) { // Empty the cache $this->nut('cache:clear'); $fs = new Filesystem(); $rundir = INSTALL_ROOT . '/app/cache/codeception-run-' . time() . '/'; $fs->mkdir($rundir); // Restore our backed up files, and make copies of them in app/cache/ for review $backups = Fixtures::get('backups'); foreach ($backups as $file => $keep) { if ($fs->exists("{$file}.codeception-backup")) { $this->writeln("Restoring {$file}"); $fs->copy($file, $rundir . basename($file)); $fs->rename("{$file}.codeception-backup", $file, true); } } if ($fs->exists(INSTALL_ROOT . '/app/config/extensions/testerevents.bolt.yml')) { $fs->remove(INSTALL_ROOT . '/app/config/extensions/testerevents.bolt.yml'); } }
protected function _before() { $grav = Fixtures::get('grav'); $this->grav = $grav(); $this->pages = $this->grav['pages']; $this->config = $this->grav['config']; $this->uri = $this->grav['uri']; $this->language = $this->grav['language']; $this->old_home = $this->config->get('system.home.alias'); $this->config->set('system.home.alias', '/item1'); $this->config->set('system.absolute_urls', false); $this->config->set('system.languages.supported', []); unset($this->grav['language']); $this->grav['language'] = new Language($this->grav); /** @var UniformResourceLocator $locator */ $locator = $this->grav['locator']; $locator->addPath('page', '', 'tests/fake/nested-site/user/pages', false); $this->pages->init(); $defaults = ['extra' => false, 'auto_line_breaks' => false, 'auto_url_links' => false, 'escape_markup' => false, 'special_chars' => ['>' => 'gt', '<' => 'lt']]; $page = $this->pages->dispatch('/item2/item2-2'); $this->parsedown = new Parsedown($page, $defaults); }
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 . ' が異なります'); }
/** * Tests validation rules. * * @depends testFetching * * @return void * @since 0.1.0 */ public function testValidation() { $username = Fixtures::get('data:users[0]:login'); // duplicate username $user = new \User(); $user->username = $username; $user->password = '******'; $this->assertFalse($user->validate()); $user = \User::model()->findByUsername($username); $user->scenario = 'usernameUpdate'; $this->assertTrue($user->validate()); $user->username = Fixtures::get('data:users[1]:login'); $this->assertFalse($user->validate()); // too short $user->username = '******'; $this->assertFalse($user->validate()); // ok now $user->username = '******'; $this->assertTrue($user->validate()); // wrong password $user->scenario = 'passwordUpdate'; $user->password = '******'; $user->newPassword = '******'; $user->newPasswordRepeat = 'passpasspass'; $this->assertFalse($user->validate()); $user->password = Fixtures::get('data:users[0]:password'); $user->newPassword = '******'; // short new password $this->assertFalse($user->validate()); //different from second confirmation password $user->newPassword = '******'; $this->assertFalse($user->validate()); //ok now $user->newPasswordRepeat = 'passpasspass1'; $this->assertTrue($user->validate()); }
/** * @param \AcceptanceTester $I */ public function _before(\AcceptanceTester $I) { $this->user = Fixtures::get('users'); }
/** * ページに移動。 * @param $url string URL * @param $pageTitle string ページタイトル * @return $this */ protected function goPage($url, $pageTitle) { $config = Fixtures::get('config'); $this->tester->amOnPage('/' . $config['admin_route'] . $url); return $this->atPage($pageTitle); }
protected function _before() { $this->grav = Fixtures::get('grav'); $this->gpm = new GpmStub(); }
<?php use Codeception\Util\Fixtures; for ($k = 0; $k < Fixtures::get('data:posts:length'); $k++) { if (Fixtures::get("data:posts[{$k}]:author") === 1) { $postSlug = Fixtures::get("data:posts[{$k}]:slug"); $postId = $k + 1; break; } } if (!isset($postSlug, $postId)) { throw new \RuntimeException('Couldn\'t find post written by first user.'); } $firstCategorySlug = Fixtures::get('data:categories[0]:slug'); return array('admin/index', 'admin/help', 'admin/devHelp', 'admin/options', 'admin/flushCache', 'admin/status', 'admin/recalculate', 'user/dashboard', 'user/new', 'user/profile', 'user/suicide', 'user/updateUsername', 'user/updatePassword', 'post/dashboard', 'post/new', array('post/checkSlug', 'opts' => array('slug' => 'sluggity')), array('post/edit', 'opts' => array('id' => $postId)), array('post/delete', 'opts' => array('id' => $postId)), 'category/dashboard', array('category/edit', 'opts' => array('slug' => $firstCategorySlug)), array('category/save', 'opts' => array('slug' => $firstCategorySlug)), array('category/delete', 'opts' => array('slug' => $firstCategorySlug)), array('comment/delete', 'opts' => array('postSlug' => $postSlug, 'id' => 1)));
<?php use Codeception\Util\Fixtures; /** @type \Codeception\Scenario $scenario */ $scenario->groups('front', 'user-management'); \Yii::app()->fixtureManager->prepare(); $I = new TestGuy($scenario); $I->wantTo('Delete my account'); $I->expectTo('Lose ability to sign in under my regular account and all my posts'); $login = Fixtures::get('data:users[0]:login'); $password = Fixtures::get('data:users[0]:password'); $I->amOnPage(\AuthorFeedPage::route(1)); // confirming that test landed on required page $I->see($login, \AuthorFeedPage::$postSelector); $I->amOnPage(\LoginPage::$url); $I->submitForm(\LoginPage::$formSelector, array(\LoginPage::$loginField => $login, \LoginPage::$passwordField => $password)); $I->amOnPage(\SuicideBoothPage::$url); $I->click(\SuicideBoothPage::$benderButtonXPath); $I->seeCurrentUrlEquals('/'); $I->amOnPage(\LoginPage::$url); $I->submitForm(\LoginPage::$formSelector, array(\LoginPage::$loginField => $login, \LoginPage::$passwordField => $password)); $I->see('auth.login.fail'); $I->amOnPage(\AuthorFeedPage::route(1)); $I->see('pageTitle.site.error', \AuthorFeedPage::$pageHeaderSelector); $I->seeResponseCodeIs(404); $h = fopen(\Yii::getPathOfAlias('application.runtime.login'), 'a'); fwrite($h, $login . PHP_EOL); fclose($h); $I->assertNull(\User::findByUsername($login, false)); $I->assertEmpty(\Post::model()->with(array('author' => array('condition' => 'author.username = :login', 'params' => array(':login' => $login))))->findAll());
<?php use Codeception\Util\Fixtures; /** @var Faker\Generator $faker */ $faker = Fixtures::get('faker'); $devs = Fixtures::get('devs'); $I = new ApiTester($scenario); $I->wantTo('get the user price based on the GitHub API'); $I->amGoingTo('Get a non-existent user'); $I->sendGET('dev/' . $faker->lexify('??????????')); $I->seeResponseCodeIs(404); $I->amGoingTo('Get an existent user'); $I->sendGET('dev/' . $devs[array_rand($devs)]); $I->seeResponseCodeIs(200); $dev = json_decode($I->grabResponse()); $I->assertTrue(is_numeric($dev->rate), 'rate is numeric'); $I->assertTrue(is_string($dev->username) && strlen($dev->username) != 0, 'username is present and is string');
/** * @param \AcceptanceTester $I */ public function _before(\AcceptanceTester $I) { $this->tokenNames = Fixtures::get('tokenNames'); }
<?php $I = new FunctionalTester($scenario); $rabman = new \Rabman\ResourceFactory(\Codeception\Util\Fixtures::get('rabman-opt')); $items = $rabman->nodes()->columns(['exchange_types.name']); $count = count($items); $I->assertTrue($count > 0); $expected = [['name' => 'direct'], ['name' => 'headers'], ['name' => 'topic'], ['name' => 'fanout']]; $I->assertEquals($expected, $items[0]['exchange_types']);
public function onlinePayment(AcceptanceTester $I) { $I->wantTo('test an online payment'); $clientEmail = $this->faker->safeEmail; $productKey = $this->faker->text(10); // set gateway info $I->wantTo('create a gateway'); $I->amOnPage('/settings/online_payments'); if (strpos($I->grabFromCurrentUrl(), 'create') !== false) { $I->fillField(['name' => '23_apiKey'], env('stripe_secret_key') ?: Fixtures::get('stripe_secret_key')); // Fails to load StripeJS causing "ReferenceError: Can't find variable: Stripe" //$I->fillField(['name' =>'stripe_publishable_key'], env('stripe_secret_key') ?: Fixtures::get('stripe_publishable_key')); $I->selectOption('#token_billing_type_id', 4); $I->click('Save'); $I->see('Successfully created gateway'); } // create client $I->amOnPage('/clients/create'); $I->fillField(['name' => 'contacts[0][email]'], $clientEmail); $I->click('Save'); $I->see($clientEmail); // create product $I->amOnPage('/products/create'); $I->fillField(['name' => 'product_key'], $productKey); $I->fillField(['name' => 'notes'], $this->faker->text(80)); $I->fillField(['name' => 'cost'], $this->faker->numberBetween(1, 20)); $I->click('Save'); $I->wait(1); $I->see($productKey); // create invoice $I->amOnPage('/invoices/create'); $I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle'); $I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey); $I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable'); $I->click('Save'); $I->see($clientEmail); // enter payment $clientId = $I->grabFromDatabase('contacts', 'client_id', ['email' => $clientEmail]); $invoiceId = $I->grabFromDatabase('invoices', 'id', ['client_id' => $clientId]); $invitationKey = $I->grabFromDatabase('invitations', 'invitation_key', ['invoice_id' => $invoiceId]); $clientSession = $I->haveFriend('client'); $clientSession->does(function (AcceptanceTester $I) use($invitationKey) { $I->amOnPage('/view/' . $invitationKey); $I->click('Pay Now'); /* $I->fillField(['name' => 'first_name'], $this->faker->firstName); $I->fillField(['name' => 'last_name'], $this->faker->lastName); $I->fillField(['name' => 'address1'], $this->faker->streetAddress); $I->fillField(['name' => 'address2'], $this->faker->streetAddress); $I->fillField(['name' => 'city'], $this->faker->city); $I->fillField(['name' => 'state'], $this->faker->state); $I->fillField(['name' => 'postal_code'], $this->faker->postcode); $I->selectDropdown($I, 'United States', '.country-select .dropdown-toggle'); */ $I->fillField('#card_number', '4242424242424242'); $I->fillField('#cvv', '1234'); $I->selectOption('#expiration_month', 12); $I->selectOption('#expiration_year', date('Y')); $I->click('.btn-success'); $I->wait(3); $I->see('Successfully applied payment'); }); $I->wait(1); // create recurring invoice and auto-bill $I->amOnPage('/recurring_invoices/create'); $I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle'); $I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey); $I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable'); $I->checkOption('#auto_bill'); $I->executeJS('preparePdfData(\'email\')'); $I->wait(3); $I->see("\$0.00"); }