示例#1
0
 /**
  * @test
  */
 public function changeModuleState_ChangeEnabledUsingToolbar_EnabledChanged()
 {
     $this->moduleManagerPage->addModule('Test Module');
     $state = $this->moduleManagerPage->getState('Test Module');
     $this->assertEquals('published', $state, 'Initial state should be published');
     $this->moduleManagerPage->changeModuleState('Test Module', 'unpublished');
     $state = $this->moduleManagerPage->getState('Test Module');
     $this->assertEquals('unpublished', $state, 'State should be unpublished');
     $this->moduleManagerPage->trashAndDelete('Test Module');
 }
 /**
  * create a menu with two menu items of type category blog and adding two articles in each menu item
  * create a module of type menu and verifying from the front end
  *
  * @return void
  *
  * @test
  */
 public function addModule_MenuItemsCategoryBlog_ModuleAdded()
 {
     $cfg = new SeleniumConfig();
     $cpPage = $this->doAdminLogin();
     $categoryManager = 'administrator/index.php?option=com_categories&extension=com_content';
     $moduleManager = 'administrator/index.php?option=com_modules';
     $this->driver->get($cfg->host . $cfg->path . $categoryManager);
     $salt = rand();
     $categoryName1 = 'category_ABC_1' . $salt;
     $categoryName2 = 'category_ABC_2' . $salt;
     $this->categoryManagerPage = $this->getPageObject('CategoryManagerPage');
     $this->assertFalse($this->categoryManagerPage->getRowNumber($categoryName1), 'Test Category should not be present');
     $this->assertFalse($this->categoryManagerPage->getRowNumber($categoryName2), 'Test Category should not be present');
     $this->categoryManagerPage->addCategory($categoryName1);
     $message = $this->categoryManagerPage->getAlertMessage();
     $this->assertTrue(strpos($message, 'Category successfully saved') >= 0, 'Category save should return success');
     $this->categoryManagerPage->addCategory($categoryName2);
     $message = $this->categoryManagerPage->getAlertMessage();
     $this->assertTrue(strpos($message, 'Category successfully saved') >= 0, 'Category save should return success');
     $articleManager = 'administrator/index.php?option=com_content';
     $this->driver->get($cfg->host . $cfg->path . $articleManager);
     $articleName1 = 'article_ABC_1' . $salt;
     $articleName2 = 'article_ABC_2' . $salt;
     $articleName3 = 'article_ABC_3' . $salt;
     $articleName4 = 'article_ABC_4' . $salt;
     $this->articleManagerPage = $this->getPageObject('ArticleManagerPage');
     $this->assertFalse($this->articleManagerPage->getRowNumber($articleName1), 'Test Article should not be present');
     $this->assertFalse($this->articleManagerPage->getRowNumber($articleName2), 'Test Article should not be present');
     $this->assertFalse($this->articleManagerPage->getRowNumber($articleName3), 'Test Article should not be present');
     $this->assertFalse($this->articleManagerPage->getRowNumber($articleName4), 'Test Article should not be present');
     $this->articleManagerPage->addArticle($articleName1, $categoryName1);
     $message = $this->articleManagerPage->getAlertMessage();
     $this->assertTrue(strpos($message, 'Article successfully saved') >= 0, 'Article save should return success');
     $this->articleManagerPage->addArticle($articleName2, $categoryName1);
     $message = $this->articleManagerPage->getAlertMessage();
     $this->assertTrue(strpos($message, 'Article successfully saved') >= 0, 'Article save should return success');
     $this->articleManagerPage->addArticle($articleName3, $categoryName2);
     $message = $this->articleManagerPage->getAlertMessage();
     $this->assertTrue(strpos($message, 'Article successfully saved') >= 0, 'Article save should return success');
     $this->articleManagerPage->addArticle($articleName4, $categoryName2);
     $message = $this->articleManagerPage->getAlertMessage();
     $this->assertTrue(strpos($message, 'Article successfully saved') >= 0, 'Article save should return success');
     $this->menuManagerPage = $cpPage->clickMenu('Menu Manager', 'MenuManagerPage');
     $menuName = 'Menu' . $salt;
     $type = 'menu' . $salt;
     $description = 'test menu ' . $salt;
     $this->assertFalse($this->menuManagerPage->getRowNumber($menuName), 'Test menu should not be present');
     $this->menuManagerPage->addMenu($menuName, $type, $description);
     $message = $this->menuManagerPage->getAlertMessage();
     $this->assertContains('Menu successfully saved', $message, 'Menu save should return success', true);
     $MenuItemsManager = 'administrator/index.php?option=com_menus&view=items';
     $this->driver->get($cfg->host . $cfg->path . $MenuItemsManager);
     $menuItem1 = 'Menu Item 1' . $salt;
     $menuItem2 = 'Menu Item 2' . $salt;
     $menuType = 'Category Blog';
     $this->menuItemsManagerPage = $this->getPageObject('MenuItemsManagerPage');
     $this->menuItemsManagerPage->setFilter('Menu', $menuName);
     $this->assertFalse($this->menuItemsManagerPage->getRowNumber($menuItem1), 'Test menu item should not be present');
     $this->assertFalse($this->menuItemsManagerPage->getRowNumber($menuItem2), 'Test menu item should not be present');
     $this->menuItemsManagerPage->addMenuItem($menuItem1, $menuType, $menuName, array('Category' => $categoryName1));
     $message = $this->menuItemsManagerPage->getAlertMessage();
     $this->assertContains('Menu item successfully saved', $message, 'Menu save should return success', true);
     $this->menuItemsManagerPage->addMenuItem($menuItem2, $menuType, $menuName, array('Category' => $categoryName2));
     $message = $this->menuItemsManagerPage->getAlertMessage();
     $this->assertContains('Menu item successfully saved', $message, 'Menu save should return success', true);
     $this->moduleManagerPage = $cpPage->clickMenu('Module Manager', 'ModuleManagerPage');
     $title = 'Module test ' . $salt;
     $client = 'Site';
     $type = 'Menu';
     $position = 'position-3';
     $suffix = 'mySuffix';
     $otherFields = array('Position' => $position, 'Module Class Suffix' => $suffix, 'Select Menu' => $menuName);
     $this->moduleManagerPage->setFilter('filter_client_id', $client)->searchFor($title);
     $this->assertFalse($this->moduleManagerPage->getRowNumber($title), 'Test module should not be present');
     $this->moduleManagerPage->addModule($title, $client, $type, $otherFields);
     $message = $this->moduleManagerPage->getAlertMessage();
     $this->assertTrue(strpos($message, 'Module successfully saved') >= 0, 'Module save should return success');
     $homePageUrl = 'index.php';
     $d = $this->driver;
     $d->get($cfg->host . $cfg->path . $homePageUrl);
     $this->siteHomePage = $this->getPageObject('SiteContentFeaturedPage');
     $this->assertTrue($this->siteHomePage->itemExist($title, 'h3'));
     $this->assertTrue($this->siteHomePage->itemExist($menuItem1, 'a'));
     $this->assertTrue($this->siteHomePage->itemExist($menuItem2, 'a'));
     $this->siteHomePage->itemClick($menuItem1);
     $this->assertTrue($this->siteHomePage->itemExist($articleName1, 'a'));
     $this->assertTrue($this->siteHomePage->itemExist($articleName2, 'a'));
     $this->siteHomePage->itemClick($menuItem2);
     $this->assertTrue($this->siteHomePage->itemExist($articleName3, 'a'));
     $this->assertTrue($this->siteHomePage->itemExist($articleName4, 'a'));
     $this->doAdminLogin();
     $this->driver->get($cfg->host . $cfg->path . $articleManager);
     $this->articleManagerPage = $this->getPageObject('ArticleManagerPage');
     $this->articleManagerPage->trashAndDelete($articleName1);
     $this->assertFalse($this->articleManagerPage->getRowNumber($articleName1), 'Test article should not be present');
     $this->articleManagerPage->trashAndDelete($articleName2);
     $this->assertFalse($this->articleManagerPage->getRowNumber($articleName2), 'Test article should not be present');
     $this->articleManagerPage->trashAndDelete($articleName3);
     $this->assertFalse($this->articleManagerPage->getRowNumber($articleName3), 'Test article should not be present');
     $this->articleManagerPage->trashAndDelete($articleName4);
     $this->assertFalse($this->articleManagerPage->getRowNumber($articleName4), 'Test article should not be present');
     $this->driver->get($cfg->host . $cfg->path . $categoryManager);
     $this->categoryManagerPage = $this->getPageObject('CategoryManagerPage');
     $this->categoryManagerPage->trashAndDelete($categoryName1);
     $this->assertFalse($this->categoryManagerPage->getRowNumber($categoryName1), 'Test Category should not be present');
     $this->categoryManagerPage->trashAndDelete($categoryName2);
     $this->assertFalse($this->categoryManagerPage->getRowNumber($categoryName2), 'Test Category should not be present');
     $this->driver->get($cfg->host . $cfg->path . $moduleManager);
     $this->moduleManagerPage->setFilter('filter_client_id', $client);
     $this->moduleManagerPage->trashAndDelete($title);
     $this->moduleManagerPage->searchFor($title);
     $this->assertFalse($this->moduleManagerPage->getRowNumber($title), 'Test module should not be present');
     $this->driver->get($cfg->host . $cfg->path . $MenuItemsManager);
     $this->menuItemsManagerPage->setFilter('Menu', $menuName);
     $this->menuItemsManagerPage->trashAndDelete($menuItem1);
     $this->assertFalse($this->menuItemsManagerPage->getRowNumber($menuItem1), 'Test menu should not be present');
     $this->menuItemsManagerPage->trashAndDelete($menuItem2);
     $this->assertFalse($this->menuItemsManagerPage->getRowNumber($menuItem2), 'Test menu should not be present');
     $MenuManager = 'administrator/index.php?option=com_menus&view=menus';
     $this->driver->get($cfg->host . $cfg->path . $MenuManager);
     $this->menuManagerPage->deleteMenu($menuName);
     $this->assertFalse($this->menuManagerPage->getRowNumber($menuName), 'Test menu should not be present');
 }