/** * Login admin user. * * @param FixtureInterface $fixture [optional] * @return mixed|string */ public function persist(FixtureInterface $fixture = null) { $this->adminAuthLogin->open(); $loginBlock = $this->adminAuthLogin->getLoginBlock(); if ($loginBlock->isVisible()) { $loginBlock->fill($fixture); $loginBlock->submit(); $this->dashboard->getAdminPanelHeader()->waitVisible(); } }
/** * Verify whether customer has logged in to the Backend. * * @param User $user * @param AdminAuthLogin $adminAuth * @param Dashboard $dashboard * @param User $customAdmin * @return void */ public function processAssert(User $user, AdminAuthLogin $adminAuth, Dashboard $dashboard, User $customAdmin = null) { $adminUser = $customAdmin === null ? $user : $customAdmin; $adminPanelHeader = $dashboard->getAdminPanelHeader(); if ($adminPanelHeader->isVisible()) { $adminPanelHeader->logOut(); } $adminAuth->getLoginBlock()->loginToAdminPanel($adminUser->getData()); \PHPUnit_Framework_Assert::assertTrue($adminPanelHeader->isVisible(), 'Admin user was not logged in.'); }
/** * Not allowed resources are not available on menu level. * In case if type it via URL - "Access Denied" page appeared. * * @param User $user * @param AdminAuthLogin $adminAuthLogin * @param Dashboard $dashboard * @param Browser $browser * @return void */ public function processAssert(User $user, AdminAuthLogin $adminAuthLogin, Dashboard $dashboard, Browser $browser) { $adminPanelHeader = $dashboard->getAdminPanelHeader(); if ($adminPanelHeader->isVisible()) { $adminPanelHeader->logOut(); } $adminAuthLogin->getLoginBlock()->loginToAdminPanel($user->getData()); $menuItems = $adminPanelHeader->getMenuFirstLevelItems(); \PHPUnit_Framework_Assert::assertTrue(count($menuItems) == 1 && in_array('Sales', $menuItems), 'Sales menu item is not visible or count of menu items is greater than 1.'); $browser->open($_ENV['app_backend_url'] . $this->manageProductsUrl); \PHPUnit_Framework_Assert::assertTrue(strpos($dashboard->getMainBlock()->getMainBlockText(), self::ACCESS_DENIED) !== false, self::ACCESS_DENIED . " text is not visible on dashboard page."); }
/** * Log in on backend for super admin. * * @param array $admin * @return void */ protected function loginSuperAdmin(array $admin) { $this->adminAuthLogin->open(); $loginBlock = $this->adminAuthLogin->getLoginBlock(); if ($loginBlock->isVisible()) { $loginBlock->loginToAdminPanel($admin); } }
/** * Assert that user have custom role. * * @param User $user * @param AdminAuthLogin $adminAuth * @param Dashboard $dashboard * @param CatalogCategoryIndex $categoryIndex * @param User $customAdmin [optional] * @return void */ public function processAssert(User $user, AdminAuthLogin $adminAuth, Dashboard $dashboard, CatalogCategoryIndex $categoryIndex, User $customAdmin = null) { $adminUser = $customAdmin === null ? $user : $customAdmin; $adminPanelHeader = $dashboard->getAdminPanelHeader(); if ($adminPanelHeader->isVisible()) { $adminPanelHeader->logOut(); } $adminAuth->getLoginBlock()->loginToAdminPanel($adminUser->getData()); $role = $user->getDataFieldConfig('role_id')['source']->getRole(); $menuItems = $this->getMenuItems($role); foreach ($menuItems as $item) { \PHPUnit_Framework_Assert::assertTrue($adminPanelHeader->checkMenu(ucfirst($item)), "Menu {$item} is absent on top menu."); } // Check access denied message on category page. $categoryIndex->open(); \PHPUnit_Framework_Assert::assertTrue($categoryIndex->getContentBlock()->checkAccessDeniedMessage()); }
/** * Log in to backend. * * @param array $adminData * @return void */ protected function login(array $adminData) { $this->adminAuthLogin->getLoginBlock()->loginToAdminPanel($adminData); }
/** * Assert that error message "This account is locked." is present in log in to backend page. * * @param AdminAuthLogin $adminAuth * @return void */ public function processAssert(AdminAuthLogin $adminAuth) { \PHPUnit_Framework_Assert::assertEquals(self::ERROR_MESSAGE, $adminAuth->getMessagesBlock()->getErrorMessages()); }
/** * Asserts that login form is present on page. * * @param AdminAuthLogin $adminAuth * @param Dashboard $dashboard * @return void */ public function processAssert(AdminAuthLogin $adminAuth, Dashboard $dashboard) { $dashboard->getAdminPanelHeader()->logOut(); $isLoginBlockVisible = $adminAuth->getLoginBlock()->isVisible(); \PHPUnit_Framework_Assert::assertTrue($isLoginBlockVisible, 'Admin user was not logged out.'); }
/** * Verify incorrect credentials message while login to admin. * * @param AdminAuthLogin $adminAuth * @param User $customAdmin * @return void */ public function processAssert(AdminAuthLogin $adminAuth, User $customAdmin) { $adminAuth->open(); $adminAuth->getLoginBlock()->loginToAdminPanel($customAdmin->getData()); \PHPUnit_Framework_Assert::assertEquals(self::INVALID_CREDENTIALS_MESSAGE, $adminAuth->getMessagesBlock()->getErrorMessages(), 'Message "' . self::INVALID_CREDENTIALS_MESSAGE . '" is not visible.'); }