protected function setUp()
 {
     MockAnnotations::init($this);
     $this->localeSettings->expects($this->any())->method('getTimeZone')->will($this->returnValue('UTC'));
     $this->periodFactory = new PeriodFactory($this->localeSettings);
     $this->service = new TimeSheetServiceImpl($this->worklogRepository, $this->periodFactory, $this->localeSettings);
 }
 public function testSetOrderCurrency()
 {
     $currency = 'USD';
     $this->localeSettings->expects($this->once())->method('getCurrency')->willReturn($currency);
     $order = new Order();
     $this->handler->setOrderCurrency($order);
     $this->assertEquals($currency, $order->getCurrency());
 }
 /**
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 protected function setUp()
 {
     $this->formatter = $this->getMockBuilder('Oro\\Bundle\\LocaleBundle\\Formatter\\DateTimeFormatter')->disableOriginalConstructor()->setMethods(array('getPattern'))->getMock();
     $this->formatter->expects($this->any())->method('getPattern')->will($this->returnValueMap($this->localFormatMap));
     $this->translator = $this->getMockBuilder('Symfony\\Bundle\\FrameworkBundle\\Translation\\Translator')->disableOriginalConstructor()->getMock();
     $this->translator->method('trans')->will($this->returnCallback(function ($one, $two, $tree, $locale) {
         if ($locale == self::LOCALE_EN) {
             return 'MMM d';
         }
         if ($locale == self::LOCALE_RU) {
             return 'd.MMM';
         }
         return '';
     }));
     $this->converter = $this->createFormatConverter();
 }
 /**
  * @dataProvider submitDataProvider
  *
  * @param array $allowedCurrencies
  * @param string $localeCurrency
  * @param array $inputOptions
  * @param array $expectedOptions
  * @param string $submittedData
  */
 public function testSubmit(array $allowedCurrencies, $localeCurrency, array $inputOptions, array $expectedOptions, $submittedData)
 {
     $hasCustomCurrencies = isset($inputOptions['currencies_list']) || !empty($inputOptions['full_currency_list']);
     $this->configManager->expects($hasCustomCurrencies ? $this->never() : $this->once())->method('get')->with('oro_currency.allowed_currencies')->willReturn($allowedCurrencies);
     $this->localeSettings->expects(count($allowedCurrencies) ? $this->never() : $this->once())->method('getCurrency')->willReturn($localeCurrency);
     $form = $this->factory->create($this->formType, null, $inputOptions);
     $formConfig = $form->getConfig();
     foreach ($expectedOptions as $key => $value) {
         $this->assertTrue($formConfig->hasOption($key));
         $this->assertEquals($value, $formConfig->getOption($key));
     }
     $this->assertNull($form->getData());
     $form->submit($submittedData);
     $this->assertTrue($form->isValid());
     $this->assertEquals($submittedData, $form->getData());
 }
 /**
  * @dataProvider testDenormalizeProvider
  *
  * @param \DateTime $expected
  * @param string    $data
  * @param string    $locale
  * @param string    $timezone
  * @param array     $context
  */
 public function testDenormalize($expected, $data, $locale, $timezone, $context)
 {
     if ($locale !== null) {
         $this->localeSettings->expects($this->any())->method('getLocale')->willReturn($locale);
     }
     if ($timezone !== null) {
         $this->localeSettings->expects($this->any())->method('getTimezone')->willReturn($timezone);
     }
     $this->assertEquals($expected, $this->normalizer->denormalize($data, 'DateTime', null, $context));
 }
 /**
  * @dataProvider getAddressFormatDataProvider
  *
  * @param array $addressFormats
  * @param string $localeOrRegion
  * @param string $expectedFormat
  * @param string $defaultCountry
  */
 public function testGetAddressFormat(array $addressFormats, $localeOrRegion, $expectedFormat, $defaultCountry = null)
 {
     $this->localeSettings->expects($this->once())->method('getAddressFormats')->will($this->returnValue($addressFormats));
     if (!$localeOrRegion) {
         $this->localeSettings->expects($this->once())->method('getLocale')->will($this->returnValue('en_US'));
     }
     if ($defaultCountry) {
         $this->localeSettings->expects($this->once())->method('getCountry')->will($this->returnValue($defaultCountry));
     }
     $this->assertEquals($expectedFormat, $this->addressFormatter->getAddressFormat($localeOrRegion));
 }
 protected function setUp()
 {
     $this->formatter = $this->getMockBuilder('Oro\\Bundle\\LocaleBundle\\Formatter\\DateTimeFormatter')->disableOriginalConstructor()->setMethods(array('getPattern'))->getMock();
     $this->formatter->expects($this->any())->method('getPattern')->will($this->returnValueMap($this->localFormatMap));
     $this->converter = $this->createFormatConverter();
 }