/**
  * Retrieve Page from uimap data configuration by MCA
  *
  * @param string $area Application area ('frontend'|'admin')
  * @param string $pageKey UIMap page key
  * @param Mage_Selenium_Helper_Params $paramsDecorator Params decorator instance
  *
  * @return Mage_Selenium_Uimap_Page|Null
  */
 public function getUimapPageByMca($area, $mca, $paramsDecorator = null)
 {
     $mca = trim($mca, ' /\\');
     if (isset($this->_uimapData[$area])) {
         foreach ($this->_uimapData[$area] as &$page) {
             // get mca without any modifications
             $page_mca = trim($page->getMca(new Mage_Selenium_Helper_Params()), ' /\\');
             if ($page_mca !== false && $page_mca !== null) {
                 if ($paramsDecorator) {
                     $page_mca = $paramsDecorator->replaceParametersWithRegexp($page_mca);
                 }
                 if (preg_match(';^' . $page_mca . '$;', $mca)) {
                     $page->assignParams($paramsDecorator);
                     return $page;
                 }
             }
         }
     }
 }
Beispiel #2
0
 /**
  * @param array $paramsArray
  * @param string $sourceToReplace
  * @param string $regexp
  * @param string $expected
  *
  * @covers Mage_Selenium_Helper_Params::replaceParametersWithRegexp
  * @dataProvider testReplaceParametersWithRegexpDataProvider
  */
 public function testReplaceParametersWithRegexp($paramsArray, $sourceToReplace, $regexp, $expected)
 {
     $params = new Mage_Selenium_Helper_Params($paramsArray);
     $result = $params->replaceParametersWithRegexp($sourceToReplace, $regexp);
     $this->assertEquals($result, $expected);
 }
Beispiel #3
0
 /**
  * Retrieve Page from UIMap data configuration by MCA
  *
  * @param string $area Application area
  * @param string $mca a part of current URL opened in browser
  * @param null|Mage_Selenium_Helper_Params $paramsDecorator Params decorator instance
  *
  * @return Mage_Selenium_Uimap_Page
  * @throws OutOfRangeException
  */
 public function getUimapPageByMca($area, $mca, $paramsDecorator = null)
 {
     $mca = trim($mca, ' /\\');
     $appropriatePages = array();
     foreach ($this->_uimapData[$area] as $page) {
         //Get mca without any modifications
         $pageMca = trim($page->getMca(new Mage_Selenium_Helper_Params()), ' /\\');
         if ($pageMca === false || $pageMca === null) {
             continue;
         }
         $pageMca = preg_quote($pageMca);
         if ($paramsDecorator) {
             $pageMca = $paramsDecorator->replaceParametersWithRegexp($pageMca);
         }
         if (preg_match(';^' . $pageMca . '$;', $mca)) {
             $appropriatePages[] = $page;
         }
     }
     if (!empty($appropriatePages)) {
         if (count($appropriatePages) == 1) {
             return array_shift($appropriatePages);
         }
         foreach ($appropriatePages as $page) {
             //Get mca with actual modifications
             $pageMca = trim($page->getMca($paramsDecorator), ' /\\');
             if ($pageMca === $mca) {
                 $page->assignParams($paramsDecorator);
                 return $page;
             }
         }
     }
     throw new OutOfRangeException('Cannot find page with mca "' . $mca . '" in "' . $area . '" area');
 }