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


PHP expects函数代码示例

本文整理汇总了PHP中expects函数的典型用法代码示例。如果您正苦于以下问题:PHP expects函数的具体用法?PHP expects怎么用?PHP expects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testGetShippingDataObject

 /**
  * @param array $addressData
  * @param bool $useBaseCurrency
  * @param string $shippingTaxClass
  * @param bool shippingPriceInclTax
  * @param array $expectedValue
  * @dataProvider getShippingDataObjectDataProvider
  */
 public function testGetShippingDataObject(array $addressData, $useBaseCurrency, $shippingTaxClass, $shippingPriceInclTax)
 {
     $baseShippingAmount = $addressData['base_shipping_amount'];
     $shippingAmount = $addressData['shipping_amount'];
     $itemMock = $this->getMock('Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterface');
     $this->taxConfig->expects($this->any())->method('getShippingTaxClass')->with($this->store)->will($this->returnValue($shippingTaxClass));
     $this->taxConfig->expects($this->any())->method('shippingPriceIncludesTax')->with($this->store)->will($this->returnValue($shippingPriceInclTax));
     $this->address->expects($this->atLeastOnce())->method('getShippingDiscountAmount')->willReturn($shippingAmount);
     if ($shippingAmount) {
         if ($useBaseCurrency && $shippingAmount != 0) {
             $this->address->expects($this->once())->method('getBaseShippingDiscountAmount')->willReturn($baseShippingAmount);
             $this->quoteDetailsItemBuilderMock->expects($this->once())->method('setDiscountAmount')->with($baseShippingAmount);
         } else {
             $this->address->expects($this->never())->method('getBaseShippingDiscountAmount');
             $this->quoteDetailsItemBuilderMock->expects($this->once())->method('setDiscountAmount')->with($shippingAmount);
         }
     }
     foreach ($addressData as $key => $value) {
         $this->address->setData($key, $value);
     }
     $this->taxClassKeyBuilderMock->expects($this->any())->method('setType')->willReturnSelf();
     $this->taxClassKeyBuilderMock->expects($this->any())->method('setValue')->with($shippingTaxClass)->willReturnSelf();
     $this->quoteDetailsItemBuilderMock->expects($this->once())->method('create')->willReturn($itemMock);
     $this->assertEquals($itemMock, $this->commonTaxCollector->getShippingDataObject($this->address, $useBaseCurrency));
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:33,代码来源:CommonTaxCollectorTest.php

示例2: testParse

 public function testParse()
 {
     $expectedResult = [['phrase' => 'phrase1', 'file' => 'file1', 'line' => 15, 'quote' => '']];
     $this->_phraseCollectorMock->expects($this->once())->method('parse')->with('file1');
     $this->_phraseCollectorMock->expects($this->once())->method('getPhrases')->will($this->returnValue([['phrase' => 'phrase1', 'file' => 'file1', 'line' => 15]]));
     $this->_adapter->parse('file1');
     $this->assertEquals($expectedResult, $this->_adapter->getPhrases());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:8,代码来源:PhpTest.php

示例3: testExecute

 /**
  * @param array $options
  * @param ItemStub $actualContext
  * @param ItemStub $expectedContext
  * @param array $expectedData
  * @dataProvider optionsDataProvider
  */
 public function testExecute(array $options, ItemStub $actualContext, ItemStub $expectedContext, array $expectedData = array())
 {
     $expectedWorkflowName = $expectedContext->workflowName;
     $expectedEntity = !empty($options['entity']) ? $expectedContext->entityValue : null;
     $expectedTransition = !empty($options['transition']) ? $expectedContext->startTransition : null;
     $expectedWorkflowItem = $expectedContext->workflowItem;
     $this->workflowManager->expects($this->once())->method('startWorkflow')->with($expectedWorkflowName, $expectedEntity, $expectedTransition, $expectedData)->will($this->returnValue($expectedWorkflowItem));
     $this->action->initialize($options);
     $this->action->execute($actualContext);
     $this->assertEquals($expectedContext->getData(), $actualContext->getData());
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:18,代码来源:StartWorkflowTest.php

示例4: setUp

 /**
  * Set up
  */
 protected function setUp()
 {
     $this->resultPage = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Page', ['setActiveMenu', 'getConfig', 'getTitle', 'prepend', 'addBreadcrumb'], [], '', false);
     $this->resultPage->expects($this->any())->method('getConfig')->willReturnSelf();
     $this->resultPage->expects($this->any())->method('getTitle')->willReturnSelf();
     $this->resultFactory = $this->getMock('Magento\\Framework\\Controller\\ResultFactory', ['create'], [], '', false);
     $this->resultFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getResultFactory'], [], '', false);
     $this->context->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactory);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->indexController = $this->objectManagerHelper->getObject('Magento\\ImportExport\\Controller\\Adminhtml\\History\\Index', ['context' => $this->context]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:IndexTest.php

示例5: should_parse_variable_contains_operators

 public function should_parse_variable_contains_operators()
 {
     expects($this->parse('org'))->should_be(array(':org'));
     expects($this->parse('dand'))->should_be(array(':dand'));
     expects($this->parse('xor'))->should_be(array(':xor'));
     expects($this->parse('notd'))->should_be(array(':notd'));
 }
开发者ID:tonjoo,项目名称:tiga-framework,代码行数:7,代码来源:parser_spec.php

示例6: testAuthorize

 /**
  * Test method
  * with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
  */
 public function testAuthorize()
 {
     $this->initializationAuthorizeMock();
     $this->buildRequestData();
     $paymentTokenMock = $this->getMock(PaymentTokenInterface::class);
     $extensionAttributes = $this->getMockBuilder('Magento\\Sales\\Api\\Data\\OrderPaymentExtensionInterface')->disableOriginalConstructor()->setMethods(['setVaultPaymentToken'])->getMock();
     $ccDetails = ['cc_type' => 'VI', 'cc_number' => '1111'];
     $this->responseMock->setData('result_code', Payflowpro::RESPONSE_CODE_APPROVED);
     $this->responseMock->setData('origresult', 0);
     $this->responseMock->setData('pnref', 'test-pnref');
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
     $this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
     $this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
     $this->paymentMock->expects($this->once())->method('getCcExpYear')->willReturn('2017');
     $this->paymentMock->expects($this->once())->method('getCcExpMonth')->willReturn('12');
     $this->paymentMock->expects(static::any())->method('getAdditionalInformation')->willReturnMap([[Transparent::CC_DETAILS, $ccDetails], [Transparent::PNREF, 'test-pnref']]);
     $this->paymentTokenFactory->expects(static::once())->method('create')->willReturn($paymentTokenMock);
     $paymentTokenMock->expects(static::once())->method('setGatewayToken')->with('test-pnref');
     $paymentTokenMock->expects(static::once())->method('setTokenDetails')->with(json_encode($ccDetails));
     $paymentTokenMock->expects(static::once())->method('setExpiresAt')->with('2018-01-01 00:00:00');
     $this->paymentMock->expects(static::once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
     $extensionAttributes->expects(static::once())->method('setVaultPaymentToken')->with($paymentTokenMock);
     $this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:TransparentTest.php

示例7: should_parse_variable_contains_operators

 function should_parse_variable_contains_operators()
 {
     expects($this->parse("org"))->should_be(array(':org', 'expression_end'));
     expects($this->parse("dand"))->should_be(array(':dand', 'expression_end'));
     expects($this->parse("xor"))->should_be(array(':xor', 'expression_end'));
     expects($this->parse("notd"))->should_be(array(':notd', 'expression_end'));
 }
开发者ID:hgezim,项目名称:h2o-php,代码行数:7,代码来源:parser_spec.php

示例8: testShouldAcceptOnlyREQSockets

 /**
  * @test should accept only REQ sockets
  */
 public function testShouldAcceptOnlyREQSockets()
 {
     $this->socket = $this->getMockBuilder('\\ZMQSocket')->disableOriginalConstructor()->getMock();
     $this->socket->expects($this->any())->method('getSocketType')->will($this->returnValue(\ZMQ::SOCKET_PUSH));
     $this->setExpectedException('\\InvalidArgumentException', 'Invalid socket type');
     new ZeroMQClientTransport($this->socket);
 }
开发者ID:wookieb,项目名称:zorro-rpc,代码行数:10,代码来源:ZeroMQClientTransportTest.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     \Locale::setDefault('en');
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $this->requestStack = new RequestStack();
     /* @var Request $request */
     $request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $this->requestStack->push($request);
     $this->router->expects($this->any())->method('generate')->will($this->returnCallback(function ($param) {
         return '/' . $param;
     }));
     $this->factory = Forms::createFormFactoryBuilder()->addExtensions($this->getExtensions())->addTypeExtension(new ChoiceSelect2TypeExtension($this->dispatcher, $this->requestStack, $this->router, $this->getExtensionTypeName(), 10))->getFormFactory();
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
 }
开发者ID:mcdir,项目名称:SonatraFormExtensionsBundle,代码行数:17,代码来源:AbstractSelect2TypeExtensionTest.php

示例10: should_be_able_to_include_in_nested_fashion

 public function should_be_able_to_include_in_nested_fashion()
 {
     $h2o = new H2o('page.html', $this->option);
     $result = $h2o->render();
     expects($result)->should_match('/layout text/');
     expects($result)->should_match('/Page footer/');
     expects($result)->should_match('/page menu/');
 }
开发者ID:tonjoo,项目名称:tiga-framework,代码行数:8,代码来源:include_spec.php

示例11: testExecute

 public function testExecute()
 {
     $context = new StubStorage(array('array' => array('key_1' => 'value_1', 'key_2' => 'value_2'), 'key' => null, 'value' => null, 'new_array' => array()));
     $options = array(Traverse::OPTION_KEY_ARRAY => new PropertyPath('array'), Traverse::OPTION_KEY_KEY => new PropertyPath('key'), Traverse::OPTION_KEY_VALUE => new PropertyPath('value'), Traverse::OPTION_KEY_ACTIONS => array('actions', 'configuration'));
     $this->configurableAction->expects($this->once())->method('initialize')->with($options[Traverse::OPTION_KEY_ACTIONS]);
     $this->configurableAction->expects($this->any())->method('execute')->with($context)->will($this->returnCallback(function (StubStorage $context) {
         $key = $context['key'];
         $value = $context['value'];
         $newArray = $context['new_array'];
         $newArray[$key] = $value;
         $context['new_array'] = $newArray;
     }));
     $this->action->initialize($options);
     $this->action->execute($context);
     $this->assertNull($context['key']);
     $this->assertNull($context['value']);
     $this->assertEquals($context['array'], $context['new_array']);
 }
开发者ID:Maksold,项目名称:platform,代码行数:18,代码来源:TraverseTest.php

示例12: setUp

 public function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->taxConfig = $this->getMockBuilder('\\Magento\\Tax\\Model\\Config')->disableOriginalConstructor()->setMethods(['getShippingTaxClass', 'shippingPriceIncludesTax'])->getMock();
     $this->store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock();
     $this->quote = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['__wakeup', 'getStore'])->getMock();
     $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->address = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Address')->disableOriginalConstructor()->getMock();
     $this->address->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
     $methods = ['create'];
     $this->quoteDetailsItemDataObject = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Quote\\ItemDetails');
     $this->taxClassKeyDataObject = $objectManager->getObject('Magento\\Tax\\Model\\TaxClass\\Key');
     $this->quoteDetailsItemDataObjectFactoryMock = $this->getMock('Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterfaceFactory', $methods, [], '', false);
     $this->quoteDetailsItemDataObjectFactoryMock->expects($this->any())->method('create')->willReturn($this->quoteDetailsItemDataObject);
     $this->taxClassKeyDataObjectFactoryMock = $this->getMock('Magento\\Tax\\Api\\Data\\TaxClassKeyInterfaceFactory', $methods, [], '', false);
     $this->taxClassKeyDataObjectFactoryMock->expects($this->any())->method('create')->willReturn($this->taxClassKeyDataObject);
     $this->commonTaxCollector = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Total\\Quote\\CommonTaxCollector', ['taxConfig' => $this->taxConfig, 'quoteDetailsItemDataObjectFactory' => $this->quoteDetailsItemDataObjectFactoryMock, 'taxClassKeyDataObjectFactory' => $this->taxClassKeyDataObjectFactoryMock]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:CommonTaxCollectorTest.php

示例13: testAuthorize

 /**
  * Test method
  * with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
  */
 public function testAuthorize()
 {
     $this->initializationAuthorizeMock();
     $this->buildRequestData();
     $this->responseMock->expects($this->any())->method('getResultCode')->willReturn(Payflowpro::RESPONSE_CODE_APPROVED);
     $this->responseMock->expects($this->any())->method('getOrigresult')->willReturn(0);
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
     $this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
     $this->responseMock->expects($this->once())->method('getPnref')->willReturn('test-pnref');
     $this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
     $this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
 }
开发者ID:nja78,项目名称:magento2,代码行数:17,代码来源:TransparentTest.php

示例14: testGetSearchCriteriaAnd

 public function testGetSearchCriteriaAnd()
 {
     // Test ((A > 1) and (B > 1))
     $fieldA = 'A';
     $fieldB = 'B';
     $value = 1;
     $sortOrder = $this->sortOrderBuilder->setField('name')->setDirection(SortOrder::SORT_ASC)->create();
     /** @var SearchCriteria $expectedSearchCriteria */
     $expectedSearchCriteria = $this->searchCriteriaBuilder->setCurrentPage(1)->setPageSize(0)->addSortOrder($sortOrder)->addFilters([$this->filterBuilder->setField($fieldA)->setConditionType('gt')->setValue($value)->create()])->addFilters([$this->filterBuilder->setField($fieldB)->setConditionType('gt')->setValue($value)->create()])->create();
     // Verifies that the search criteria Data Object created by the serviceCollection matches expected
     $this->groupRepositoryMock->expects($this->once())->method('getList')->with($this->equalTo($expectedSearchCriteria))->will($this->returnValue($this->searchResults));
     // Now call service collection to load the data.  This causes it to create the search criteria Data Object
     $this->serviceCollection->addFieldToFilter($fieldA, ['gt' => $value]);
     $this->serviceCollection->addFieldToFilter($fieldB, ['gt' => $value]);
     $this->serviceCollection->setOrder('name', ServiceCollection::SORT_ORDER_ASC);
     $this->serviceCollection->loadData();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:ServiceCollectionTest.php

示例15: setUp

 /**
  * Set up
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function setUp()
 {
     parent::setUp();
     //connection and sql query results
     $this->connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $adapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $adapter->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $this->select->expects($this->any())->method('getAdapter')->willReturn($adapter);
     $this->connectionMock->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $this->connectionMock->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connectionMock->expects($this->any())->method('delete')->willReturnSelf();
     $this->connectionMock->expects($this->any())->method('quoteInto')->willReturn('');
     //constructor arguments:
     // 1. $attrSetColFac
     $this->attrSetColFacMock = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->attrSetColMock = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->attrSetColMock->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     // 2. $prodAttrColFac
     $this->prodAttrColFacMock = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
     $attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection', [], [], '', false);
     $attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->prodAttrColFacMock->expects($this->any())->method('create')->will($this->returnValue($attrCollection));
     // 3. $resource
     $this->resourceMock = $this->getMock('Magento\\Framework\\App\\ResourceConnection', ['getConnection', 'getTableName'], [], '', false);
     $this->resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->connectionMock));
     $this->resourceMock->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     // 4. $params
     $this->entityModelMock = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product', ['addMessageTemplate', 'getEntityTypeId', 'getBehavior', 'getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getParameters', 'addRowError'], [], '', false);
     $this->entityModelMock->expects($this->any())->method('addMessageTemplate')->will($this->returnSelf());
     $this->entityModelMock->expects($this->any())->method('getEntityTypeId')->will($this->returnValue(5));
     $this->entityModelMock->expects($this->any())->method('getParameters')->will($this->returnValue([]));
     $this->paramsArray = [$this->entityModelMock, 'downloadable'];
     $this->uploaderMock = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Uploader', ['move'], [], '', false);
     // 6. $filesystem
     $this->directoryWriteMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     // 7. $fileHelper
     $this->uploaderHelper = $this->getMock('\\Magento\\DownloadableImportExport\\Helper\\Uploader', ['getUploader'], [], '', false);
     $this->uploaderHelper->expects($this->any())->method('getUploader')->willReturn($this->uploaderMock);
     $this->downloadableHelper = $this->getMock('\\Magento\\DownloadableImportExport\\Helper\\Data', ['prepareDataForSave'], [], '', false);
     $this->downloadableHelper->expects($this->any())->method('prepareDataForSave')->willReturn([]);
 }
开发者ID:IlyaGluschenko,项目名称:protection,代码行数:49,代码来源:DownloadableTest.php


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