/**
  * Check the Rules serialization module
  */
 public function testRuleSerialisation()
 {
     $stubTranslator = $this->getMockBuilder('\\Thelia\\Core\\Translation\\Translator')->disableOriginalConstructor()->getMock();
     /** @var FacadeInterface $stubFacade */
     $stubFacade = $this->getMockBuilder('\\Thelia\\Coupon\\BaseFacade')->disableOriginalConstructor()->getMock();
     $stubFacade->expects($this->any())->method('getTranslator')->will($this->returnValue($stubTranslator));
     $stubFacade->expects($this->any())->method('getConditionEvaluator')->will($this->returnValue(new ConditionEvaluator()));
     $currencies = CurrencyQuery::create();
     $currencies = $currencies->find();
     $stubFacade->expects($this->any())->method('getAvailableCurrencies')->will($this->returnValue($currencies));
     $stubContainer = $this->getMockBuilder('\\Symfony\\Component\\DependencyInjection\\Container')->disableOriginalConstructor()->getMock();
     $stubContainer->expects($this->any())->method('get')->will($this->returnValue(new MatchForTotalAmount($stubFacade)));
     $stubContainer->expects($this->any())->method('has')->will($this->returnValue(true));
     $stubFacade->expects($this->any())->method('getContainer')->will($this->returnValue($stubContainer));
     $condition1 = new MatchForTotalAmount($stubFacade);
     $operators = array(MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL);
     $values = array(MatchForTotalAmount::CART_TOTAL => 40.0, MatchForTotalAmount::CART_CURRENCY => 'EUR');
     $condition1->setValidatorsFromForm($operators, $values);
     $condition2 = new MatchForTotalAmount($stubFacade);
     $operators = array(MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL);
     $values = array(MatchForTotalAmount::CART_TOTAL => 400.0, MatchForTotalAmount::CART_CURRENCY => 'EUR');
     $condition2->setValidatorsFromForm($operators, $values);
     $conditions = new ConditionCollection();
     $conditions[] = $condition1;
     $conditions[] = $condition2;
     $conditionFactory = new ConditionFactory($stubContainer);
     $serializedConditions = $conditionFactory->serializeConditionCollection($conditions);
     $unserializedConditions = $conditionFactory->unserializeConditionCollection($serializedConditions);
     $expected = (string) $conditions;
     $actual = (string) $unserializedConditions;
     $this->assertEquals($expected, $actual);
 }