<?php /** @type \Codeception\Scenario $scenario */ $scenario->groups('front', 'posts', 'cache'); $I = new WebGuy\MemberSteps($scenario); $I->am('Web developer'); $I->wantTo('Test cache system by writing post and tweaking service settings'); $I->expectTo('See changes instantly'); $I->autoLogin(); // if any other category is modified but the top one, categories may change // positions in sidebar, and this behavior would be much harder to test. $categoryNumber = 0; $I->flushCache(); $stats = \ServiceStatusPage::of($I)->grabStats(); $totalPostsNumber = $stats['totalPosts']; $postsTodayNumber = $stats['postsToday']; $commentsTodayNumber = $stats['commentsToday']; $totalCommentsNumber = $stats['totalComments']; $I->amOnPage(\BlogFeedPage::$url); $categoryTitle = \BlogFeedPage::of($I)->grabCategoryTitle($categoryNumber); $categoryPostCount = \BlogFeedPage::of($I)->grabCategoryPostCount($categoryNumber); $posts = array(); // there were issues with stall cache after series of fast posts, so this // construct verifies that it doesn't happen again for ($i = 0; $i < 5; $i++) { $title = md5(time()) . $i; $I->amOnPage(\BlogFeedPage::$url); $I->dontSee($title); $I->writePost($title, 'superpost is superposted', null, $categoryTitle); $elemId = $I->grabAttributeFrom(\PostPage::$postSelector, 'id'); preg_match('#\\d+#', $elemId, $matches);
<?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);