当前位置: 首页>>代码示例>>PHP>>正文


PHP TranslatorInterface::expects方法代码示例

本文整理汇总了PHP中Symfony\Component\Translation\TranslatorInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslatorInterface::expects方法的具体用法?PHP TranslatorInterface::expects怎么用?PHP TranslatorInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Translation\TranslatorInterface的用法示例。


在下文中一共展示了TranslatorInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFormatPriceTypeLabels

 /**
  * @param array $inputData
  * @param array $expectedData
  *
  * @dataProvider formatPriceTypeLabelsProvider
  */
 public function testFormatPriceTypeLabels(array $inputData, array $expectedData)
 {
     $this->translator->expects($this->any())->method('trans')->will($this->returnCallback(function ($type) {
         return $type;
     }));
     $this->assertSame($expectedData, $this->formatter->formatPriceTypeLabels($inputData));
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:13,代码来源:QuoteProductOfferFormatterTest.php

示例2: testGetSubtotals

 public function testGetSubtotals()
 {
     $this->translator->expects($this->once())->method('trans')->with(sprintf('orob2b.order.subtotals.%s', Subtotal::TYPE_SUBTOTAL))->willReturn(ucfirst(Subtotal::TYPE_SUBTOTAL));
     $order = new Order();
     $perUnitLineItem = new OrderLineItem();
     $perUnitLineItem->setPriceType(OrderLineItem::PRICE_TYPE_UNIT);
     $perUnitLineItem->setPrice(Price::create(20, 'USD'));
     $perUnitLineItem->setQuantity(2);
     $bundledUnitLineItem = new OrderLineItem();
     $bundledUnitLineItem->setPriceType(OrderLineItem::PRICE_TYPE_BUNDLED);
     $bundledUnitLineItem->setPrice(Price::create(2, 'USD'));
     $bundledUnitLineItem->setQuantity(10);
     $otherCurrencyLineItem = new OrderLineItem();
     $otherCurrencyLineItem->setPriceType(OrderLineItem::PRICE_TYPE_UNIT);
     $otherCurrencyLineItem->setPrice(Price::create(10, 'EUR'));
     $otherCurrencyLineItem->setQuantity(10);
     $emptyLineItem = new OrderLineItem();
     $order->addLineItem($perUnitLineItem);
     $order->addLineItem($bundledUnitLineItem);
     $order->addLineItem($emptyLineItem);
     $order->addLineItem($otherCurrencyLineItem);
     $order->setCurrency('USD');
     $subtotals = $this->provider->getSubtotals($order);
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $subtotals);
     $subtotal = $subtotals->get(Subtotal::TYPE_SUBTOTAL);
     $this->assertInstanceOf('OroB2B\\Bundle\\OrderBundle\\Model\\Subtotal', $subtotal);
     $this->assertEquals(Subtotal::TYPE_SUBTOTAL, $subtotal->getType());
     $this->assertEquals(ucfirst(Subtotal::TYPE_SUBTOTAL), $subtotal->getLabel());
     $this->assertEquals($order->getCurrency(), $subtotal->getCurrency());
     $this->assertInternalType('float', $subtotal->getAmount());
     $this->assertEquals(142.0, $subtotal->getAmount());
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:32,代码来源:SubtotalsProviderTest.php

示例3: testGetFailedMessage

 public function testGetFailedMessage()
 {
     $message = 'test message';
     $this->router->expects($this->never())->method($this->anything());
     $this->translator->expects($this->once())->method('trans')->willReturn($message);
     $this->assertEquals($message, $this->generator->getFailedMessage());
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:7,代码来源:MessageGeneratorTest.php

示例4: testBuildFormRegularGuesser

 /**
  * @param bool $withRelations
  *
  * @dataProvider testDataProvider
  */
 public function testBuildFormRegularGuesser($withRelations)
 {
     $entityName = 'Test\\Entity';
     $this->doctrineHelperMock->expects($this->once())->method('getEntityIdentifierFieldNames')->with($entityName)->willReturn(['id']);
     $fields = [['name' => 'oneField', 'type' => 'string', 'label' => 'One field'], ['name' => 'anotherField', 'type' => 'string', 'label' => 'Another field']];
     if ($withRelations) {
         $fields[] = ['name' => 'relField', 'relation_type' => 'ref-one', 'label' => 'Many to One field'];
     }
     $this->entityFieldMock->expects($this->once())->method('getFields')->willReturn($fields);
     $this->formConfigMock->expects($this->at(0))->method('getConfig')->with($entityName, 'oneField')->willReturn(new Config(new FieldConfigId('form', $entityName, 'someField'), ['is_enabled' => false]));
     $this->formConfigMock->expects($this->at(1))->method('getConfig')->with($entityName, 'anotherField')->willReturn(new Config(new FieldConfigId('form', $entityName, 'anotherField'), ['is_enabled' => true]));
     if ($withRelations) {
         $this->formConfigMock->expects($this->at(2))->method('getConfig')->with($entityName, 'relField')->willReturn(new Config(new FieldConfigId('form', $entityName, 'relField'), ['is_enabled' => true]));
         $this->translatorMock->expects($this->at(0))->method('trans')->with('oro.entity.form.entity_fields')->willReturn('Fields');
         $this->translatorMock->expects($this->at(1))->method('trans')->with('oro.entity.form.entity_related')->willReturn('Relations');
     }
     $form = $this->factory->create($this->type, null, ['entity' => $entityName, 'with_relations' => $withRelations]);
     $view = $form->createView();
     $this->assertEquals('update_field_choice', $view->vars['full_name'], 'Failed asserting that field name is correct');
     $this->assertNotEmpty($view->vars['configs']['component']);
     $this->assertEquals('entity-field-choice', $view->vars['configs']['component']);
     $this->assertEquals('update_field_choice', $form->getConfig()->getType()->getName(), 'Failed asserting that correct underlying type was used');
     if ($withRelations) {
         $this->assertCount(2, $view->vars['choices'], 'Failed asserting that choices are grouped');
     } else {
         $this->assertCount(1, $view->vars['choices'], 'Failed asserting that choices exists');
         /** @var ChoiceView $choice */
         $choice = reset($view->vars['choices']);
         $this->assertEquals('Another field', $choice->label);
     }
 }
开发者ID:trustify,项目名称:oroplatform-mass-update-bundle,代码行数:36,代码来源:UpdateFieldChoiceTypeTest.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     /** @var TranslatorInterface $translator */
     $this->translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $this->translator->expects($this->any())->method('trans')->with('orob2b.fallback.type.parent_locale')->willReturn('Parent Locale');
     $this->formType = new FallbackPropertyType($this->translator);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:8,代码来源:FallbackPropertyTypeTest.php

示例6: setUp

 protected function setUp()
 {
     $this->translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $this->translator->expects($this->any())->method('trans')->willReturnCallback(function ($id) {
         return $id . '.trans';
     });
     $this->doctrineHelper = $this->getMockBuilder('Oro\\Bundle\\EntityBundle\\ORM\\DoctrineHelper')->disableOriginalConstructor()->getMock();
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:8,代码来源:FormViewListenerTestCase.php

示例7: setUp

 protected function setUp()
 {
     $this->translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $this->translator->expects($this->any())->method('trans')->willReturnCallback(function ($message) {
         return $message . '.trans';
     });
     $this->formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
     $this->componentRegistry = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Model\\ComponentProcessorRegistry')->disableOriginalConstructor()->getMock();
     $this->handler = new QuickAddHandler($this->translator, $this->formFactory, $this->componentRegistry);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:10,代码来源:QuickAddHandlerTest.php

示例8: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $this->translator->expects(static::any())->method('trans')->will(static::returnCallback(function ($id, array $params) {
         return $id . ':' . $params['{title}'];
     }));
     $this->formType = new ProductRemovedSelectType();
     $this->formType->setTranslator($this->translator);
     parent::setUp();
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:13,代码来源:ProductRemovedSelectTypeTest.php

示例9: testOnPostSubmitWithInvalidForm

 public function testOnPostSubmitWithInvalidForm()
 {
     $event = $this->createFormEventMock();
     $event->expects($this->once())->method('getForm')->will($this->returnValue($form = $this->createFormMock()));
     $form->expects($this->once())->method('isValid')->will($this->returnValue(false));
     $this->session->expects($this->once())->method('getFlashBag')->will($this->returnValue($flashBag = $this->createFlashBagMock()));
     $this->translator->expects($this->once())->method('trans')->with($this->identicalTo('lug.resource.csrf.error'), $this->identicalTo([]), $this->identicalTo('flashes'))->will($this->returnValue($translation = 'translation'));
     $flashBag->expects($this->once())->method('add')->with($this->identicalTo('error'), $this->identicalTo($translation));
     $this->flashCsrfProtectionSubscriber->onPostSubmit($event);
 }
开发者ID:php-lug,项目名称:lug,代码行数:10,代码来源:FlashCsrfProtectionSubscriberTest.php

示例10: setUp

 protected function setUp()
 {
     $this->configProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
     $this->activityManager = $this->getMockBuilder('Oro\\Bundle\\ActivityBundle\\Manager\\ActivityManager')->disableOriginalConstructor()->getMock();
     $this->translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $this->translator->expects($this->any())->method('trans')->willReturn('Items');
     $this->listener = new MergeListener($this->translator, $this->configProvider, $this->activityManager);
     $this->entityMetadata = $this->getMockBuilder('Oro\\Bundle\\EntityMergeBundle\\Metadata\\EntityMetadata')->setMethods(['getClassName', 'addFieldMetadata'])->disableOriginalConstructor()->getMock();
     $this->entityMetadata->expects($this->any())->method('getClassName')->will($this->returnValue(get_class($this->createEntity())));
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:MergeListenerTest.php

示例11: setUp

 protected function setUp()
 {
     $this->translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $this->translator->expects($this->any())->method('trans')->with($this->isType('string'))->willReturnCallback(function ($id, array $params = []) {
         $id = str_replace(array_keys($params), array_values($params), $id);
         return $id . '.trans';
     });
     $this->doctrineHelper = $this->getMockBuilder('Oro\\Bundle\\EntityBundle\\ORM\\DoctrineHelper')->disableOriginalConstructor()->getMock();
     $this->priceListRequestHandler = $this->getMockBuilder('OroB2B\\Bundle\\PricingBundle\\Model\\PriceListRequestHandler')->disableOriginalConstructor()->getMock();
     $this->listener = new ProductPriceDatagridListener($this->translator, $this->doctrineHelper, $this->priceListRequestHandler);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:11,代码来源:ProductPriceDatagridListenerTest.php

示例12: testGetWidgetDefinitions

 public function testGetWidgetDefinitions()
 {
     $placement = 'left';
     $title = 'Foo';
     $definitions = new ArrayCollection();
     $definitions->set('test', array('title' => $title, 'icon' => 'test.ico', 'module' => 'widget/foo', 'placement' => 'left'));
     $this->widgetDefinitionsRegistry->expects($this->once())->method('getWidgetDefinitionsByPlacement')->with($placement)->will($this->returnValue($definitions));
     $this->translator->expects($this->once())->method('trans')->with($title)->will($this->returnValue('trans' . $title));
     $expected = array('test' => array('title' => 'transFoo', 'icon' => 'test.ico', 'module' => 'widget/foo', 'placement' => 'left'));
     $this->assertEquals($expected, $this->extension->getWidgetDefinitions($placement));
 }
开发者ID:Maksold,项目名称:platform,代码行数:11,代码来源:SidebarExtensionTest.php

示例13: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->translator = $this->getMock('Symfony\\Component\\Translation\\TranslatorInterface');
     $this->translator->expects(static::any())->method('trans')->willReturnCallback(function ($id, array $params) {
         return isset($params['{title}']) ? $id . ':' . $params['{title}'] : $id;
     });
     $productUnitLabelFormatter = new ProductUnitLabelFormatter($this->translator);
     $this->formType = new ProductUnitRemovedSelectionType($productUnitLabelFormatter, $this->translator);
     $this->formType->setEntityClass('OroB2B\\Bundle\\ProductBundle\\Entity\\ProductUnit');
     parent::setUp();
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:14,代码来源:ProductUnitRemovedSelectionTypeTest.php

示例14: setUp

 /**
  * setup mocks
  */
 protected function setUp()
 {
     $this->loader = $this->getMock('\\Twig_Loader_String');
     $this->securityPolicy = $this->getMockBuilder('\\Twig_Sandbox_SecurityPolicy')->disableOriginalConstructor()->getMock();
     $this->sandbox = $this->getMockBuilder('\\Twig_Extension_Sandbox')->disableOriginalConstructor()->getMock();
     $this->sandbox->expects($this->once())->method('getName')->will($this->returnValue('sandbox'));
     $this->sandbox->expects($this->once())->method('getSecurityPolicy')->will($this->returnValue($this->securityPolicy));
     $this->variablesProvider = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Provider\\VariablesProvider')->disableOriginalConstructor()->getMock();
     $this->cache = $this->getMockBuilder('Doctrine\\Common\\Cache\\Cache')->disableOriginalConstructor()->getMock();
     $this->translation = $this->getMockBuilder('Symfony\\Component\\Translation\\TranslatorInterface')->getMock();
     $this->translation->expects($this->any())->method('trans')->will($this->returnArgument(0));
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:EmailRendererTest.php

示例15: testBuild

 public function testBuild()
 {
     $this->translator->expects($this->once())->method('trans')->with('orob2b.customer.menu.account_user_logout.label')->willReturn('Logout');
     $child = $this->getMock('Knp\\Menu\\ItemInterface');
     $child->expects($this->once())->method('setLabel')->with('')->willReturnSelf();
     $child->expects($this->once())->method('setAttribute')->with('class', 'divider')->willReturnSelf();
     /** @var \PHPUnit_Framework_MockObject_MockObject|\Knp\Menu\ItemInterface $menu */
     $menu = $this->getMock('Knp\\Menu\\ItemInterface');
     $menu->expects($this->at(0))->method('setExtra')->with('type', 'dropdown');
     $menu->expects($this->at(1))->method('addChild')->willReturn($child);
     $menu->expects($this->at(2))->method('addChild')->with('Logout', ['route' => 'orob2b_customer_account_user_security_logout', 'linkAttributes' => ['class' => 'no-hash']]);
     $this->builder->build($menu);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:13,代码来源:AccountUserMenuBuilderTest.php


注:本文中的Symfony\Component\Translation\TranslatorInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。