コード例 #1
0
 public function getURLParameter($param)
 {
     $url = $this->getCurrentURL();
     return URL::getParameter($url, $param);
 }
コード例 #2
0
 /**
  * Create a Tax Rule.
  *
  * Assumes:
  * - successfuly logged in to the back-office
  * - on a back-office page
  *
  * @return int the id of the created tax rule
  */
 public function createTaxRule($name, $rate, $enabled = true)
 {
     $shop = $this->getShop();
     $browser = $shop->getBackOfficeNavigator()->visit('AdminTaxes');
     $browser->click('#page-header-desc-tax-new_tax')->fillIn($this->i18nFieldName('#name'), $name)->fillIn('#rate', $rate)->prestaShopSwitch('active', $enabled)->click('button[name=submitAddtax]')->ensureStandardSuccessMessageDisplayed();
     $id_tax = $browser->getURLParameter('id_tax');
     if ((int) $id_tax < 1) {
         throw new \PrestaShop\PSTAF\Exception\TaxRuleCreationIncorrectException("id_tax not a positive integer");
     }
     $check_url = URL::filterParameters($browser->getCurrentURL(), ['controller', 'id_tax', 'token'], ['updatetax' => 1]);
     $browser->visit($check_url);
     $actual_name = $browser->getValue($this->i18nFieldName('#name'));
     $actual_rate = $this->i18nParse($browser->getValue('#rate'), 'float');
     $actual_enabled = $browser->prestaShopSwitchValue('active');
     if ($actual_name !== $name || $actual_rate !== (double) $rate || $actual_enabled != $enabled) {
         throw new \PrestaShop\PSTAF\Exception\TaxRuleCreationIncorrectException("stored results differ from submitted data");
     }
     return (int) $id_tax;
 }