<?php /** @type Codeception\Scenario $scenario */ $scenario->groups(array('nonauthenticated', 'blog')); $I = new WebGuy\MemberSteps($scenario); $I->wantTo('Play with comments'); $I->amGoingTo('Be very stupid and leave comment several times until blog ' . 'will consider it correct'); $I->logout(); $I->amOnPage(\BlogFeedPage::$url); $I->click(\BlogFeedPage::$postTitleSelector); $I->see('text.commentThisPost'); $currentUrl = $I->grabFromCurrentUrl('~(.*)~'); $I->submitCommentForm(); $I->seeCurrentUrlMatches('~^' . $currentUrl . '~'); \PostPage::of($I)->hasErrors(); $I->submitCommentForm('tralalal'); $I->seeCurrentUrlMatches('~^' . $currentUrl . '~'); \PostPage::of($I)->hasErrors(); $I->submitCommentForm('Hey, look at my local email address!', 'marabou', 'marabou@localhost'); $I->seeCurrentUrlMatches('~^' . $currentUrl . '~'); \PostPage::of($I)->hasErrors(); // checking form saving $I->seeInField(\PostPage::$commentTextArea, 'Hey, look at my local email address!'); $I->seeInField(\PostPage::$commentUsernameField, 'marabou'); $I->seeInField(\PostPage::$commentEmailField, 'marabou@localhost'); $I->submitCommentForm('This is first correct comment', 'marabou', ''); $I->seeCurrentUrlMatches('~^' . $currentUrl . '~'); \PostPage::of($I)->hasNoErrors(); $I->see('This is first correct comment'); $I->submitCommentForm('Second correct comment, now using gravatar', 'marabou', '*****@*****.**'); $I->seeCurrentUrlMatches('~^' . $currentUrl . '~');
<?php /** @type \Codeception\Scenario $scenario */ $scenario->groups('content'); $I = new WebGuy\MemberSteps($scenario); $I->wantTo('Publish my post'); $I->amGoingTo('Write a post, edit it, delete it, write lots of posts'); $I->autoLogin(); $I->writePost('', ''); $I->seeCurrentUrlEquals(\PostFormPage::$newPostUrl); \PostFormPage::of($I)->hasErrors(); $I->writePost('What a title', ''); $I->seeCurrentUrlEquals(\PostFormPage::$newPostUrl); \PostFormPage::of($I)->hasErrors(); $I->writePost('What a title', 'whatapost'); $I->seeCurrentUrlEquals(\PostFormPage::$newPostUrl); \PostFormPage::of($I)->hasErrors(); $I->writePost('', 'whatapostapost'); $I->seeCurrentUrlEquals(\PostFormPage::$newPostUrl); \PostFormPage::of($I)->hasErrors(); $I->writePost('What a title', '*whatapostapost*'); $I->dontSeeInCurrentUrl(\PostFormPage::$newPostUrl); \PostFormPage::of($I)->hasNoErrors(); $I->seeCurrentUrlEquals(\PostPage::route('what-a-title')); $I->see('whatapostapost', 'article em'); $I->seeInTitle('What a title'); $I->seeLink('link.edit'); $I->click('link.edit'); $id = $I->grabFromCurrentUrl('~(\\d+)~'); $I->amOnPage(\BlogFeedPage::$url); $I->see('What a title', '.sidebar');
<?php /** @type \Codeception\Scenario $scenario */ $scenario->groups('admin', 'settings'); $I = new \WebGuy\MemberSteps($scenario); $I->wantTo('Play with settings'); $I->amGoingTo('Tweak themes, languages and names'); $I->autoLogin(); $I->amOnPage(\OptionsPage::$url); $I->seeCurrentUrlEquals(\OptionsPage::$url); $I->setCookie('useDefaultLanguage', 'true'); \OptionsPage::of($I)->updateOptions('Horse Tickler\'s Dagger Fan Club', 'ru', 'ambinight'); $I->seeCurrentUrlEquals(\OptionsPage::$url); $I->seeInTitle('Horse Tickler\'s Dagger Fan Club'); $I->seeOptionIsSelected(\OptionsPage::$siteLanguageList, 'ru'); $I->seeOptionIsSelected(\OptionsPage::$themeList, 'ambinight'); $I->see('Настройки', \OptionsPage::$pageHeaderSelector); \OptionsPage::of($I)->hasNoErrorFlashMessages(); $I->amOnPage(\BlogFeedPage::$url); $I->see('Категории', \BlogFeedPage::$sidebarSelector); $I->resetApplicationSettings(); $I->resetCookie('useDefaultLanguage');
<?php use Codeception\Util\Fixtures; /** @type \Codeception\Scenario $scenario */ $scenario->groups('blog', 'front', 'auth'); $lastPost = Fixtures::get('data:posts:length') - 1; $penultimatePagePost = $lastPost - 5; $I = new \WebGuy\MemberSteps($scenario); $I->wantTo('read blog'); $I->amGoingTo('read posts from different pages on the main feed and category/author page'); $I->expectTo('see blog posts and encounter 404 on invalid pages'); $I->amOnPage(\BlogFeedPage::$url); $I->see('heading.lastPosts'); $I->see('heading.categories'); $I->see(Fixtures::get("data:posts[{$lastPost}]:title"), 'article'); $I->dontSee(Fixtures::get("data:posts[{$penultimatePagePost}]:title"), 'article'); $I->see('2', 'ul.pagination'); $I->click('2', 'ul.pagination'); $I->seeCurrentUrlEquals(\BlogFeedPage::route(2)); $I->see(Fixtures::get("data:posts[{$penultimatePagePost}]:title"), 'article'); $I->dontSee(Fixtures::get("data:posts[{$lastPost}]:title"), 'article'); $I->amOnPage(\BlogFeedPage::route(ceil(Fixtures::get('data:posts:length') / 5) + 1)); $I->seeHttpErrorPage(404); // categories $I->amOnPage(\BlogFeedPage::$url); $category = \BlogFeedPage::of($I)->getSidebarCategoryTitle(1); $otherCategory = \BlogFeedPage::of($I)->getSidebarCategoryTitle(2); $I->click($category, '.sidebar'); $I->seeCurrentUrlMatches(\CategoryFeedPage::$urlRegexp); $I->seeInTitle($category); $I->see($category, \CategoryFeedPage::$pageHeaderSelector);