當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractElement::expects方法代碼示例

本文整理匯總了PHP中Magento\Framework\Data\Form\Element\AbstractElement::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractElement::expects方法的具體用法?PHP AbstractElement::expects怎麽用?PHP AbstractElement::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Data\Form\Element\AbstractElement的用法示例。


在下文中一共展示了AbstractElement::expects方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testPrepareElementHtml

 /**
  * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::prepareElementHtml
  * @param string $elementValue
  * @param integer|null $modelBlockId
  *
  * @dataProvider prepareElementHtmlDataProvider
  */
 public function testPrepareElementHtml($elementValue, $modelBlockId)
 {
     $elementId = 1;
     $uniqId = '126hj4h3j73hk7b347jhkl37gb34';
     $sourceUrl = 'cms/block_widget/chooser/126hj4h3j73hk7b347jhkl37gb34';
     $config = ['key1' => 'value1'];
     $fieldsetId = 2;
     $html = 'some html';
     $title = 'some title';
     $this->this->setConfig($config);
     $this->this->setFieldsetId($fieldsetId);
     $this->elementMock->expects($this->atLeastOnce())->method('getId')->willReturn($elementId);
     $this->mathRandomMock->expects($this->atLeastOnce())->method('getUniqueHash')->with($elementId)->willReturn($uniqId);
     $this->urlBuilderMock->expects($this->atLeastOnce())->method('getUrl')->with('cms/block_widget/chooser', ['uniq_id' => $uniqId])->willReturn($sourceUrl);
     $this->layoutMock->expects($this->atLeastOnce())->method('createBlock')->with('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->willReturn($this->chooserMock);
     $this->chooserMock->expects($this->atLeastOnce())->method('setElement')->with($this->elementMock)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setConfig')->with($config)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setFieldsetId')->with($fieldsetId)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setSourceUrl')->with($sourceUrl)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setUniqId')->with($uniqId)->willReturnSelf();
     $this->elementMock->expects($this->atLeastOnce())->method('getValue')->willReturn($elementValue);
     $this->blockFactoryMock->expects($this->any())->method('create')->willReturn($this->modelBlockMock);
     $this->modelBlockMock->expects($this->any())->method('load')->with($elementValue)->willReturnSelf();
     $this->modelBlockMock->expects($this->any())->method('getId')->willReturn($modelBlockId);
     $this->modelBlockMock->expects($this->any())->method('getTitle')->willReturn($title);
     $this->chooserMock->expects($this->any())->method('setLabel')->with($title)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('toHtml')->willReturn($html);
     $this->elementMock->expects($this->atLeastOnce())->method('setData')->with('after_element_html', $html)->willReturnSelf();
     $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock));
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:37,代碼來源:ChooserTest.php

示例2: testRender

 /**
  * Run test for render method
  *
  * @return void
  */
 public function testRender()
 {
     $formMock = $this->getMockBuilder('Magento\\Framework\\Data\\Form')->setMethods(['getFieldNameSuffix'])->disableOriginalConstructor()->getMock();
     $this->elementMock->expects($this->any())->method('getHtmlId')->willReturn('test-html-id');
     $this->elementMock->expects($this->once())->method('getTooltip')->willReturn('');
     $this->elementMock->expects($this->any())->method('getForm')->willReturn($formMock);
     $formMock->expects($this->any())->method('getFieldNameSuffix')->willReturn('');
     $this->assertContains(self::EXPECTED_ATTRIBUTE, $this->abstractEnable->render($this->elementMock));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:14,代碼來源:AbstractEnableTest.php

示例3: testRender

 public function testRender()
 {
     $rule = $this->getMockBuilder('Magento\\Rule\\Model\\AbstractModel')->setMethods(['getConditions', '__sleep', '__wakeup'])->disableOriginalConstructor()->getMockForAbstractClass();
     $conditions = $this->getMock('\\Magento\\Rule\\Model\\Condition\\Combine', ['asHtmlRecursive'], [], '', false);
     $this->_element->expects($this->any())->method('getRule')->will($this->returnValue($rule));
     $rule->expects($this->any())->method('getConditions')->will($this->returnValue($conditions));
     $conditions->expects($this->once())->method('asHtmlRecursive')->will($this->returnValue('conditions html'));
     $this->assertEquals('conditions html', $this->conditions->render($this->_element));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:9,代碼來源:ConditionsTest.php

示例4: testRender

 public function testRender()
 {
     $rule = $this->getMock('\\Magento\\Rule\\Model\\Rule', ['getActions', '__sleep', '__wakeup'], [], '', false);
     $actions = $this->getMock('\\Magento\\Rule\\Model\\Action\\Collection', ['asHtmlRecursive'], [], '', false);
     $this->_element->expects($this->any())->method('getRule')->will($this->returnValue($rule));
     $rule->expects($this->any())->method('getActions')->will($this->returnValue($actions));
     $actions->expects($this->once())->method('asHtmlRecursive')->will($this->returnValue('action html'));
     $this->assertEquals('action html', $this->actions->render($this->_element));
 }
開發者ID:buskamuza,項目名稱:magento2-skeleton,代碼行數:9,代碼來源:ActionsTest.php

示例5: setUp

 protected function setUp()
 {
     $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_element = $this->getMockForAbstractClass('Magento\\Framework\\Data\\Form\\Element\\AbstractElement', [], '', false, true, true, ['getHtmlId', 'getElementHtml', 'getName']);
     $this->_element->expects($this->any())->method('getHtmlId')->will($this->returnValue('html id'));
     $this->_element->expects($this->any())->method('getElementHtml')->will($this->returnValue('element html'));
     $this->_element->expects($this->any())->method('getName')->will($this->returnValue('name'));
     $this->_request = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface');
     $this->_jsHelper = $this->getMock('Magento\\Framework\\View\\Helper\\Js', [], [], '', false);
     $this->_url = $this->getMock('Magento\\Backend\\Model\\Url', [], [], '', false);
     $this->_model = $helper->getObject('Magento\\Paypal\\Block\\Adminhtml\\System\\Config\\Field\\Country', ['request' => $this->_request, 'jsHelper' => $this->_jsHelper, 'url' => $this->_url]);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:12,代碼來源:CountryTest.php

示例6: setUp

 protected function setUp()
 {
     $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_group = $this->getMock('Magento\\Backend\\Model\\Config\\Structure\\Element\\Group', [], [], '', false);
     $this->_element = $this->getMockForAbstractClass('Magento\\Framework\\Data\\Form\\Element\\AbstractElement', [], '', false, true, true, ['getHtmlId', 'getElementHtml', 'getName', 'getElements', 'getId']);
     $this->_element->expects($this->any())->method('getHtmlId')->will($this->returnValue('html id'));
     $this->_element->expects($this->any())->method('getElementHtml')->will($this->returnValue('element html'));
     $this->_element->expects($this->any())->method('getName')->will($this->returnValue('name'));
     $this->_element->expects($this->any())->method('getElements')->will($this->returnValue([]));
     $this->_element->expects($this->any())->method('getId')->will($this->returnValue('id'));
     $this->_backendConfig = $this->getMock('Magento\\Backend\\Model\\Config', [], [], '', false);
     $this->_model = $helper->getObject('Magento\\Paypal\\Block\\Adminhtml\\System\\Config\\Fieldset\\Payment', ['backendConfig' => $this->_backendConfig]);
     $this->_model->setGroup($this->_group);
 }
開發者ID:,項目名稱:,代碼行數:14,代碼來源:

示例7: testPrepareElementHtml

 /**
  * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::prepareElementHtml
  *
  * @param string $elementValue
  * @param integer|null $cmsPageId
  *
  * @dataProvider prepareElementHtmlDataProvider
  */
 public function testPrepareElementHtml($elementValue, $cmsPageId)
 {
     //$elementValue = 12345;
     //$cmsPageId    = 1;
     $elementId = 1;
     $uniqId = '126hj4h3j73hk7b347jhkl37gb34';
     $sourceUrl = 'cms/page_widget/chooser/126hj4h3j73hk7b347jhkl37gb34';
     $config = ['key1' => 'value1'];
     $fieldsetId = 2;
     $html = 'some html';
     $title = 'some "><img src=y onerror=prompt(document.domain)>; title';
     $titleEscaped = 'some &quot;&gt;&lt;img src=y onerror=prompt(document.domain)&gt;; title';
     $this->this->setConfig($config);
     $this->this->setFieldsetId($fieldsetId);
     $this->elementMock->expects($this->atLeastOnce())->method('getId')->willReturn($elementId);
     $this->mathRandomMock->expects($this->atLeastOnce())->method('getUniqueHash')->with($elementId)->willReturn($uniqId);
     $this->urlBuilderMock->expects($this->atLeastOnce())->method('getUrl')->with('cms/page_widget/chooser', ['uniq_id' => $uniqId])->willReturn($sourceUrl);
     $this->layoutMock->expects($this->atLeastOnce())->method('createBlock')->with('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->willReturn($this->chooserMock);
     $this->chooserMock->expects($this->atLeastOnce())->method('setElement')->with($this->elementMock)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setConfig')->with($config)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setFieldsetId')->with($fieldsetId)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setSourceUrl')->with($sourceUrl)->willReturnSelf();
     $this->chooserMock->expects($this->atLeastOnce())->method('setUniqId')->with($uniqId)->willReturnSelf();
     $this->elementMock->expects($this->atLeastOnce())->method('getValue')->willReturn($elementValue);
     $this->pageFactoryMock->expects($this->any())->method('create')->willReturn($this->cmsPageMock);
     $this->cmsPageMock->expects($this->any())->method('load')->with((int) $elementValue)->willReturnSelf();
     $this->cmsPageMock->expects($this->any())->method('getId')->willReturn($cmsPageId);
     $this->cmsPageMock->expects($this->any())->method('getTitle')->willReturn($title);
     $this->chooserMock->expects($this->atLeastOnce())->method('toHtml')->willReturn($html);
     if (!empty($elementValue) && !empty($cmsPageId)) {
         $this->escaper->expects($this->atLeastOnce())->method('escapeHtml')->willReturn($titleEscaped);
         $this->chooserMock->expects($this->atLeastOnce())->method('setLabel')->with($titleEscaped)->willReturnSelf();
     }
     $this->elementMock->expects($this->atLeastOnce())->method('setData')->with('after_element_html', $html)->willReturnSelf();
     $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock));
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:44,代碼來源:ChooserTest.php


注:本文中的Magento\Framework\Data\Form\Element\AbstractElement::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。