Пример #1
0
 public function testOperatorI18n()
 {
     /** @var Translator $stubTranslator */
     $stubTranslator = $this->getMockBuilder('\\Thelia\\Core\\Translation\\Translator')->disableOriginalConstructor()->getMock();
     $stubTranslator->expects($this->any())->method('trans')->will($this->returnCallback(array($this, 'callbackI18n')));
     $actual = Operators::getI18n($stubTranslator, Operators::INFERIOR);
     $expected = 'Less than';
     $this->assertEquals($expected, $actual);
     $actual = Operators::getI18n($stubTranslator, Operators::INFERIOR_OR_EQUAL);
     $expected = 'Less than or equals';
     $this->assertEquals($expected, $actual);
     $actual = Operators::getI18n($stubTranslator, Operators::EQUAL);
     $expected = 'Equal to';
     $this->assertEquals($expected, $actual);
     $actual = Operators::getI18n($stubTranslator, Operators::SUPERIOR_OR_EQUAL);
     $expected = 'Greater than or equals';
     $this->assertEquals($expected, $actual);
     $actual = Operators::getI18n($stubTranslator, Operators::SUPERIOR);
     $expected = 'Greater than';
     $this->assertEquals($expected, $actual);
     $actual = Operators::getI18n($stubTranslator, Operators::DIFFERENT);
     $expected = 'Not equal to';
     $this->assertEquals($expected, $actual);
     $actual = Operators::getI18n($stubTranslator, Operators::IN);
     $expected = 'In';
     $this->assertEquals($expected, $actual);
     $actual = Operators::getI18n($stubTranslator, Operators::OUT);
     $expected = 'Not in';
     $this->assertEquals($expected, $actual);
     $actual = Operators::getI18n($stubTranslator, 'unexpected operator');
     $expected = 'unexpected operator';
     $this->assertEquals($expected, $actual);
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public function getSummary()
 {
     $i18nOperator = Operators::getI18n($this->translator, $this->operators[self::COUNTRIES_LIST]);
     $cntryStrList = '';
     $cntryIds = $this->values[self::COUNTRIES_LIST];
     if (null !== ($cntryList = CountryQuery::create()->findPks($cntryIds))) {
         /** @var Country $cntry */
         foreach ($cntryList as $cntry) {
             $cntryStrList .= $cntry->getTitle() . ', ';
         }
         $cntryStrList = rtrim($cntryStrList, ', ');
     }
     return $this->getSummaryLabel($cntryStrList, $i18nOperator);
 }
Пример #3
0
 /**
  * @inheritdoc
  */
 public function getSummary()
 {
     $i18nOperator = Operators::getI18n($this->translator, $this->operators[self::CART_QUANTITY]);
     $toolTip = $this->translator->trans('If cart item count is <strong>%operator%</strong> %quantity%', array('%operator%' => $i18nOperator, '%quantity%' => $this->values[self::CART_QUANTITY]));
     return $toolTip;
 }
Пример #4
0
 /**
  * @inheritdoc
  */
 public function getSummary()
 {
     $i18nOperator = Operators::getI18n($this->translator, $this->operators[self::PRODUCTS_LIST]);
     $prodStrList = '';
     $prodIds = $this->values[self::PRODUCTS_LIST];
     if (null !== ($prodList = ProductQuery::create()->findPks($prodIds))) {
         /** @var Product $prod */
         foreach ($prodList as $prod) {
             $prodStrList .= $prod->getTitle() . ', ';
         }
         $prodStrList = rtrim($prodStrList, ', ');
     }
     $toolTip = $this->translator->trans('Cart contains at least a product %op% <strong>%products_list%</strong>', ['%products_list%' => $prodStrList, '%op%' => $i18nOperator]);
     return $toolTip;
 }
Пример #5
0
 /**
  * Return all validators
  *
  * @return array
  */
 public function getValidators()
 {
     $this->validators = $this->generateInputs();
     $translatedInputs = [];
     foreach ($this->validators as $key => $validator) {
         $translatedOperators = [];
         foreach ($validator['availableOperators'] as $availableOperators) {
             $translatedOperators[$availableOperators] = Operators::getI18n($this->translator, $availableOperators);
         }
         $validator['availableOperators'] = $translatedOperators;
         $translatedInputs[$key] = $validator;
     }
     $validators = ['inputs' => $translatedInputs, 'setOperators' => $this->operators, 'setValues' => $this->values];
     return $validators;
 }
Пример #6
0
 /**
  * @inheritdoc
  */
 public function getSummary()
 {
     $i18nOperator = Operators::getI18n($this->translator, $this->operators[self::CUSTOMERS_LIST]);
     $custStrList = '';
     $custIds = $this->values[self::CUSTOMERS_LIST];
     if (null !== ($custList = CustomerQuery::create()->findPks($custIds))) {
         /** @var Customer $cust */
         foreach ($custList as $cust) {
             $custStrList .= $cust->getLastname() . ' ' . $cust->getFirstname() . ' (' . $cust->getRef() . '), ';
         }
         $custStrList = rtrim($custStrList, ', ');
     }
     $toolTip = $this->translator->trans('Customer is %op% <strong>%customer_list%</strong>', ['%customer_list%' => $custStrList, '%op%' => $i18nOperator]);
     return $toolTip;
 }
Пример #7
0
 /**
  * @inheritdoc
  */
 public function getSummary()
 {
     $i18nOperator = Operators::getI18n($this->translator, $this->operators[self::CATEGORIES_LIST]);
     $catStrList = '';
     $catIds = $this->values[self::CATEGORIES_LIST];
     if (null !== ($catList = CategoryQuery::create()->findPks($catIds))) {
         /** @var Category $cat */
         foreach ($catList as $cat) {
             $catStrList .= $cat->getTitle() . ', ';
         }
         $catStrList = rtrim($catStrList, ', ');
     }
     $toolTip = $this->translator->trans('At least one of cart products categories is %op% <strong>%categories_list%</strong>', ['%categories_list%' => $catStrList, '%op%' => $i18nOperator]);
     return $toolTip;
 }
Пример #8
0
 /**
  * @inheritdoc
  */
 public function getSummary()
 {
     $i18nOperator = Operators::getI18n($this->translator, $this->operators[self::CART_TOTAL]);
     $toolTip = $this->translator->trans('If cart total amount is <strong>%operator%</strong> %amount% %currency%', array('%operator%' => $i18nOperator, '%amount%' => $this->values[self::CART_TOTAL], '%currency%' => $this->values[self::CART_CURRENCY]));
     return $toolTip;
 }