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


PHP PHPUnit_Framework_MockObject_MockObject::getData方法代码示例

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


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

示例1: testGetDataExcludesAvailableDataWhenFlagged

 public function testGetDataExcludesAvailableDataWhenFlagged()
 {
     $this->extension->setCustomData($this->customData)->setReturnAvailableData(false);
     $this->extension->expects($this->at(0))->method('yamlParse')->with('data.yml')->will($this->returnValue($this->currentData));
     $expectedResult = ['version' => '54', 'composer' => '0', 'modules' => ['php' => [], 'pear' => [], 'pecl' => []], 'ini' => ['display_errors' => 'Off'], 'timezone' => 'America/Chihuahua'];
     $this->assertEquals($expectedResult, $this->extension->getData());
 }
开发者ID:freedog96150,项目名称:puphpet,代码行数:7,代码来源:ExtensionAbstractTest.php

示例2: testPrepareValueOptions

 /**
  * @param array $setData
  * @param string $attributeObjectFrontendInput
  * @param array $attrObjectSourceAllOptionsValue
  * @param array $attrSetCollectionOptionsArray
  * @param bool $expectedAttrObjSourceAllOptionsParam
  * @param array $expectedValueSelectOptions
  * @param array $expectedValueOption
  * @dataProvider prepareValueOptionsDataProvider
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function testPrepareValueOptions($setData, $attributeObjectFrontendInput, $attrObjectSourceAllOptionsValue, $attrSetCollectionOptionsArray, $expectedAttrObjSourceAllOptionsParam, $expectedValueSelectOptions, $expectedValueOption)
 {
     foreach ($setData as $key => $value) {
         $this->_condition->setData($key, $value);
     }
     $attrObjectSourceMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\Source\\AbstractSource')->setMethods(['getAllOptions'])->disableOriginalConstructor()->getMock();
     $attrObjectSourceMock->expects(null === $expectedAttrObjSourceAllOptionsParam ? $this->never() : $this->once())->method('getAllOptions')->with($expectedAttrObjSourceAllOptionsParam)->willReturn($attrObjectSourceAllOptionsValue);
     $attributeObjectMock = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute')->setMethods(['usesSource', 'getFrontendInput', 'getSource', 'getAllOptions'])->disableOriginalConstructor()->getMock();
     $attributeObjectMock->method('usesSource')->willReturn(true);
     $attributeObjectMock->expects(null === $attributeObjectFrontendInput ? $this->never() : $this->once())->method('getFrontendInput')->willReturn($attributeObjectFrontendInput);
     $attributeObjectMock->method('getSource')->willReturn($attrObjectSourceMock);
     $entityTypeMock = $this->getMockBuilder('Magento\\Framework\\Model\\AbstractModel\\Type')->setMethods(['getId'])->disableOriginalConstructor()->getMock();
     $entityTypeMock->method('getId')->willReturn('SomeEntityType');
     $configValueMock = $this->getMock('Magento\\Eav\\Model\\Config', ['getAttribute', 'getEntityType'], [], '', false);
     $configValueMock->method('getAttribute')->willReturn($attributeObjectMock);
     $configValueMock->method('getEntityType')->willReturn($entityTypeMock);
     $configProperty = new ReflectionProperty('Magento\\Rule\\Model\\Condition\\Product\\AbstractProduct', '_config');
     $configProperty->setAccessible(true);
     $configProperty->setValue($this->_condition, $configValueMock);
     $attrSetCollectionValueMock = $this->getMockBuilder('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection')->setMethods(['setEntityTypeFilter', 'load', 'toOptionArray'])->disableOriginalConstructor()->getMock();
     $attrSetCollectionValueMock->method('setEntityTypeFilter')->will($this->returnSelf());
     $attrSetCollectionValueMock->method('load')->will($this->returnSelf());
     $attrSetCollectionValueMock->expects(null === $attrSetCollectionOptionsArray ? $this->never() : $this->once())->method('toOptionArray')->willReturn($attrSetCollectionOptionsArray);
     $attrSetCollectionProperty = new ReflectionProperty('Magento\\Rule\\Model\\Condition\\Product\\AbstractProduct', '_attrSetCollection');
     $attrSetCollectionProperty->setAccessible(true);
     $attrSetCollectionProperty->setValue($this->_condition, $attrSetCollectionValueMock);
     $testedMethod = new ReflectionMethod('Magento\\Rule\\Model\\Condition\\Product\\AbstractProduct', '_prepareValueOptions');
     $testedMethod->setAccessible(true);
     $testedMethod->invoke($this->_condition);
     $this->assertEquals($expectedValueSelectOptions, $this->_condition->getData('value_select_options'));
     $this->assertEquals($expectedValueOption, $this->_condition->getData('value_option'));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:43,代码来源:AbstractProductTest.php

示例3: testRemoveEmptyPreviewImage

 /**
  * @covers \Magento\Framework\View\Design\Theme\Image::removePreviewImage
  */
 public function testRemoveEmptyPreviewImage()
 {
     $this->_themeMock->setData($this->_getThemeSampleData());
     $this->_themeMock->setData('preview_image', null);
     $this->_filesystemMock->expects($this->never())->method('delete');
     $this->_model->removePreviewImage();
     $this->assertNull($this->_themeMock->getData('preview_image'));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:ImageTest.php

示例4: testCollect

 /**
  * @param array $orderData
  * @param array $invoiceData
  * @param array $expectedResults
  * @dataProvider collectDataProvider
  */
 public function testCollect($orderData, $invoiceData, $expectedResults)
 {
     $roundingDelta = [];
     $this->setupOrder($orderData);
     //Set up weeeData mock
     $this->weeeData->expects($this->once())->method('includeInSubtotal')->will($this->returnValue($invoiceData['include_in_subtotal']));
     //Set up invoice mock
     /** @var \Magento\Sales\Model\Order\Invoice\Item[] $invoiceItems */
     $invoiceItems = [];
     foreach ($invoiceData['items'] as $itemKey => $invoiceItemData) {
         $invoiceItems[$itemKey] = $this->getInvoiceItem($invoiceItemData);
     }
     $this->invoice->expects($this->once())->method('getAllItems')->will($this->returnValue($invoiceItems));
     $this->invoice->expects($this->once())->method('isLast')->will($this->returnValue($invoiceData['is_last']));
     foreach ($invoiceData['data_fields'] as $key => $value) {
         $this->invoice->setData($key, $value);
     }
     $this->invoice->expects($this->any())->method('roundPrice')->will($this->returnCallback(function ($price, $type) use(&$roundingDelta) {
         if (!isset($roundingDelta[$type])) {
             $roundingDelta[$type] = 0;
         }
         $roundedPrice = round($price + $roundingDelta[$type], 2);
         $roundingDelta[$type] = $price - $roundedPrice;
         return $roundedPrice;
     }));
     $this->model->collect($this->invoice);
     //verify invoice data
     foreach ($expectedResults['invoice_data'] as $key => $value) {
         $this->assertEquals($value, $this->invoice->getData($key), 'Invoice data field ' . $key . ' is incorrect');
     }
     //verify invoice item data
     foreach ($expectedResults['invoice_items'] as $itemKey => $itemData) {
         $invoiceItem = $invoiceItems[$itemKey];
         foreach ($itemData as $key => $value) {
             if ($key == 'tax_ratio') {
                 $taxRatio = unserialize($invoiceItem->getData($key));
                 $expectedTaxRatio = unserialize($itemData[$key]);
                 $this->assertEquals($expectedTaxRatio['weee'], $taxRatio['weee'], "Tax ratio is incorrect");
             } else {
                 $this->assertEquals($value, $invoiceItem->getData($key), 'Invoice item field ' . $key . ' is incorrect');
             }
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:50,代码来源:WeeeTest.php

示例5: testGetCurrentCategoryIfCurrentCategoryIsNotSet

 public function testGetCurrentCategoryIfCurrentCategoryIsNotSet()
 {
     $rootCategoryId = 333;
     $this->currentCategory->getData('current_category', null);
     $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category'))->willReturn(null);
     $this->categoryRepository->expects($this->once())->method('get')->with($rootCategoryId)->willReturn($this->category);
     $this->store->expects($this->any())->method('getRootCategoryId')->will($this->returnValue($rootCategoryId));
     $this->assertEquals($this->currentCategory, $this->model->getCurrentCategory());
     $this->assertEquals($this->currentCategory, $this->model->getData('current_category'));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:LayerTest.php

示例6: testCollect

 /**
  * @param array $orderData
  * @param array $creditmemoData
  * @param array $expectedResults
  * @dataProvider collectDataProvider
  */
 public function testCollect($orderData, $creditmemoData, $expectedResults)
 {
     $roundingDelta = [];
     //Set up order mock
     foreach ($orderData['data_fields'] as $key => $value) {
         $this->order->setData($key, $value);
     }
     //Set up creditmemo mock
     /** @var \Magento\Sales\Model\Order\Creditmemo\Item[] $creditmemoItems */
     $creditmemoItems = [];
     foreach ($creditmemoData['items'] as $itemKey => $creditmemoItemData) {
         $creditmemoItems[$itemKey] = $this->getCreditmemoItem($creditmemoItemData);
     }
     $this->creditmemo->expects($this->once())->method('getAllItems')->will($this->returnValue($creditmemoItems));
     $this->creditmemo->expects($this->any())->method('isLast')->will($this->returnValue($creditmemoData['is_last']));
     foreach ($creditmemoData['data_fields'] as $key => $value) {
         $this->creditmemo->setData($key, $value);
     }
     $this->creditmemo->expects($this->any())->method('roundPrice')->will($this->returnCallback(function ($price, $type) use(&$roundingDelta) {
         if (!isset($roundingDelta[$type])) {
             $roundingDelta[$type] = 0;
         }
         $roundedPrice = round($price + $roundingDelta[$type], 2);
         $roundingDelta[$type] = $price - $roundedPrice;
         return $roundedPrice;
     }));
     $this->model->collect($this->creditmemo);
     //verify invoice data
     foreach ($expectedResults['creditmemo_data'] as $key => $value) {
         $this->assertEquals($value, $this->creditmemo->getData($key));
     }
     //verify invoice item data
     foreach ($expectedResults['creditmemo_items'] as $itemKey => $itemData) {
         $creditmemoItem = $creditmemoItems[$itemKey];
         foreach ($itemData as $key => $value) {
             $this->assertEquals($value, $creditmemoItem->getData($key));
         }
     }
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:45,代码来源:TaxTest.php

示例7: getDataWithTypeDebugPage

 /**
  * Checks if getData() works with type "data:page"
  *
  * @test
  */
 public function getDataWithTypeDebugPage()
 {
     $uid = rand();
     $GLOBALS['TSFE']->page = array('uid' => $uid);
     $expectedResult = 'array(1item)uid=>' . $uid . '(integer)';
     $result = $this->subject->getData('debug:page');
     $cleanedResult = strip_tags($result);
     $cleanedResult = str_replace("\r", '', $cleanedResult);
     $cleanedResult = str_replace("\n", '', $cleanedResult);
     $cleanedResult = str_replace("\t", '', $cleanedResult);
     $cleanedResult = str_replace(' ', '', $cleanedResult);
     $this->assertEquals($expectedResult, $cleanedResult);
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:18,代码来源:ContentObjectRendererTest.php

示例8: verifyTotals

 /**
  * Verify that correct fields of address has been set
  *
  * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Address $address
  * @param array $addressData
  */
 public function verifyTotals($address, $addressData)
 {
     foreach ($addressData as $key => $value) {
         if ($key != self::KEY_WEEE_TOTALS && $key != self::KEY_WEEE_BASE_TOTALS) {
             // just check the output values
             $this->assertEquals($value, $address->getData($key), 'address ' . $key . ' is incorrect');
         }
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:WeeeTaxTest.php

示例9: createSampleModel

 /**
  * @param \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product
  * @param array $modelData
  * @return \Magento\Downloadable\Model\Sample|\PHPUnit_Framework_MockObject_MockObject
  */
 private function createSampleModel($product, array $modelData)
 {
     $sample = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Sample')->disableOriginalConstructor()->setMethods(['setData', 'setSampleType', 'setProductId', 'setStoreId', 'setProductWebsiteIds', 'setNumberOfDownloads', 'setSampleUrl', 'setLinkFile', 'setSampleFile', 'save'])->getMock();
     $sample->expects($this->once())->method('setData')->with($modelData)->will($this->returnSelf());
     $sample->expects($this->once())->method('setSampleType')->with($modelData['type'])->will($this->returnSelf());
     $sample->expects($this->once())->method('setProductId')->with($product->getData('id'))->willReturnSelf();
     $sample->expects($this->once())->method('setStoreId')->with($product->getStoreId())->will($this->returnSelf());
     return $sample;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:SampleTest.php

示例10: verifyAddress

 /**
  * Verify that correct fields of address has been set
  *
  * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Address $address
  * @param $addressData
  */
 public function verifyAddress($address, $addressData)
 {
     foreach ($addressData as $key => $value) {
         $this->assertEquals($value, $address->getData($key), 'address ' . $key . ' is incorrect');
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:WeeeTest.php

示例11: createLinkkModel

 /**
  * @param \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product
  * @param array $modelData
  * @param bool $isUnlimited
  * @return \Magento\Downloadable\Model\Link|\PHPUnit_Framework_MockObject_MockObject
  */
 private function createLinkkModel($product, array $modelData, $isUnlimited)
 {
     $link = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Link')->disableOriginalConstructor()->setMethods(['setData', 'setLinkType', 'setProductId', 'setStoreId', 'setWebsiteId', 'setProductWebsiteIds', 'setPrice', 'setNumberOfDownloads', 'setSampleUrl', 'setSampleType', 'setLinkFile', 'setSampleFile', 'save', 'getIsUnlimited'])->getMock();
     $link->expects($this->once())->method('setData')->with($modelData)->will($this->returnSelf());
     $link->expects($this->once())->method('setLinkType')->with($modelData['type'])->will($this->returnSelf());
     $link->expects($this->once())->method('setProductId')->with($product->getData('id'))->will($this->returnSelf());
     $link->expects($this->once())->method('setStoreId')->with($product->getStoreId())->will($this->returnSelf());
     $link->expects($this->once())->method('setWebsiteId')->with($product->getStore()->getWebsiteId())->will($this->returnSelf());
     $link->expects($this->once())->method('setPrice')->with(0);
     $link->expects($this->any())->method('setNumberOfDownloads')->with(0);
     $link->expects($this->once())->method('getIsUnlimited')->will($this->returnValue($isUnlimited));
     return $link;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:LinkTest.php

示例12: testHoldsData

 public function testHoldsData()
 {
     $testData = 'whatever';
     $this->assertSame($this->abstractCommand, $this->abstractCommand->setData($testData));
     $this->assertEquals($testData, $this->abstractCommand->getData());
 }
开发者ID:zwilias,项目名称:qman,代码行数:6,代码来源:AbstractCommandTest.php


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