本文整理匯總了PHP中Magento\Framework\View\Element\UiComponent\ContextInterface::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContextInterface::expects方法的具體用法?PHP ContextInterface::expects怎麽用?PHP ContextInterface::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\View\Element\UiComponent\ContextInterface
的用法示例。
在下文中一共展示了ContextInterface::expects方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testPrepare
/**
* Run test prepare method
*
* @param array $data
* @param array $filterData
* @param array|null $expectedCondition
* @dataProvider getPrepareDataProvider
* @return void
*/
public function testPrepare($data, $filterData, $expectedCondition)
{
$name = $data['name'];
/** @var UiComponentInterface $uiComponent */
$uiComponent = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponentInterface', [], '', false);
$uiComponent->expects($this->any())->method('getContext')->willReturn($this->contextMock);
$this->contextMock->expects($this->any())->method('getNamespace')->willReturn(Select::NAME);
$this->contextMock->expects($this->any())->method('addComponentDefinition')->with(Select::NAME, ['extends' => Select::NAME]);
$this->contextMock->expects($this->any())->method('getFiltersParams')->willReturn($filterData);
/** @var DataProviderInterface $dataProvider */
$dataProvider = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', ['addFilter'], '', false);
$this->contextMock->expects($this->any())->method('getDataProvider')->willReturn($dataProvider);
if ($expectedCondition !== null) {
$filterMock = $this->getMock('Magento\\Framework\\Api\\Filter');
$this->filterBuilderMock->expects($this->any())->method('setConditionType')->with($expectedCondition)->willReturnSelf();
$this->filterBuilderMock->expects($this->any())->method('setField')->with($name)->willReturnSelf();
$this->filterBuilderMock->expects($this->any())->method('setValue')->willReturnSelf();
$this->filterBuilderMock->expects($this->any())->method('create')->willReturn($filterMock);
$dataProvider->expects($this->any())->method('addFilter')->with($filterMock);
}
/** @var \Magento\Framework\Data\OptionSourceInterface $selectOptions */
$selectOptions = $this->getMockForAbstractClass('Magento\\Framework\\Data\\OptionSourceInterface', [], '', false);
$this->uiComponentFactory->expects($this->any())->method('create')->with($name, Select::COMPONENT, ['context' => $this->contextMock, 'options' => $selectOptions])->willReturn($uiComponent);
$date = new Select($this->contextMock, $this->uiComponentFactory, $this->filterBuilderMock, $this->filterModifierMock, $selectOptions, [], $data);
$date->prepare();
}
示例2: setUp
protected function setUp()
{
$this->objectManager = new ObjectManager($this);
$this->contextMock = $this->getMockBuilder(ContextInterface::class)->getMockForAbstractClass();
$this->processorMock = $this->getMockBuilder(Processor::class)->disableOriginalConstructor()->getMock();
$this->contextMock->expects($this->any())->method('getProcessor')->willReturn($this->processorMock);
}
示例3: setUp
/**
* Set up
*/
public function setUp()
{
$this->objectManager = new ObjectManager($this);
$this->contextMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface', [], '', false, true, true, []);
$processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
$this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor);
}
示例4: setUp
/**
* Set up
*
* @return void
*/
protected function setUp()
{
$this->uiComponentFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponentFactory')->disableOriginalConstructor()->getMock();
$this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
$processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
$this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor);
$this->multiline = new Multiline($this->contextMock, $this->uiComponentFactoryMock);
}
示例5: setup
public function setup()
{
$this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
$processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
$this->context->expects($this->any())->method('getProcessor')->willReturn($processor);
$this->uiComponentFactory = $this->getMock('Magento\\Framework\\View\\Element\\UiComponentFactory', [], [], '', false);
$this->component = new AccountLock($this->context, $this->uiComponentFactory);
}
示例6: setUp
/**
* @return void
*/
protected function setUp()
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$processorMock = $this->getMock('Magento\\Framework\\View\\Element\\UiComponent\\Processor', [], [], '', false, false);
$processorMock->expects($this->once())->method('register');
$this->contextMock = $this->getMock('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface');
$this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processorMock);
}
示例7: testPrepareSuccess
/**
* Run test for prepare method
*
* @param array $data
* @param array $expectedData
* @return void
*
* @dataProvider prepareSuccessDataProvider
*/
public function testPrepareSuccess(array $data, array $expectedData)
{
$this->uiComponentFactoryMock->expects($this->once())->method('create')->with(self::NAME, $data['config']['formElement'], $this->arrayHasKey('context'))->willReturn($this->getWrappedComponentMock());
$this->contextMock->expects($this->any())->method('getNamespace')->willReturn(self::COMPONENT_NAMESPACE);
$this->field->setData($data);
$this->field->prepare();
$result = $this->field->getData();
$this->assertEquals($expectedData, $result);
}
示例8: setup
public function setup()
{
$this->processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
$this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
$this->context->expects($this->once())->method('getProcessor')->willReturn($this->processor);
$this->uiComponentFactory = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponentFactory')->disableOriginalConstructor()->getMock();
$this->scopeConfig = $this->getMockBuilder('Magento\\Framework\\App\\Config\\ScopeConfigInterface')->getMockForAbstractClass();
$this->confirmation = new Confirmation($this->context, $this->uiComponentFactory, $this->scopeConfig, [], []);
}
示例9: setup
public function setup()
{
$this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
$processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
$this->context->expects($this->any())->method('getProcessor')->willReturn($processor);
$this->uiComponentFactory = $this->getMock('Magento\\Framework\\View\\Element\\UiComponentFactory', [], [], '', false);
$this->urlBuilder = $this->getMockForAbstractClass('Magento\\Framework\\UrlInterface', [], '', false);
$this->component = new EditAction($this->context, $this->uiComponentFactory, $this->urlBuilder, [], ['name' => 'name', 'config' => ['editUrlPath' => 'theme/design_config/edit']]);
}
示例10: setUp
protected function setUp()
{
$this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)->getMockForAbstractClass();
$this->contextMock = $this->getMockBuilder(ContextInterface::class)->getMockForAbstractClass();
$this->uiElementProcessorMock = $this->getMockBuilder(UiElementProcessor::class)->disableOriginalConstructor()->getMock();
$this->contextMock->expects(static::any())->method('getProcessor')->willReturn($this->uiElementProcessorMock);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->nameColumn = $this->objectManagerHelper->getObject(NameColumn::class, ['urlBuilder' => $this->urlBuilderMock, 'context' => $this->contextMock]);
}
示例11: testPrepareDataSource
public function testPrepareDataSource()
{
$dataSource = ['data' => ['items' => [['entity_id' => 1]]]];
$expectedDataSource = ['data' => ['items' => [['entity_id' => 1, 'name' => ['edit' => ['href' => 'http://magento.com/customer/index/edit', 'label' => new \Magento\Framework\Phrase('Edit'), 'hidden' => false]]]]]];
$this->context->expects($this->once())->method('getFilterParam')->with('store_id')->willReturn(null);
$this->urlBuilder->expects($this->once())->method('getUrl')->with('customer/*/edit', ['id' => 1, 'store' => null])->willReturn('http://magento.com/customer/index/edit');
$dataSource = $this->component->prepareDataSource($dataSource);
$this->assertEquals($expectedDataSource, $dataSource);
}
示例12: testPrepare
/**
* Run test prepare method
*
* @return void
*/
public function testPrepare()
{
$buttons = ['button1' => 'button1', 'button2' => 'button2'];
/** @var Listing $listing */
$listing = $this->objectManager->getObject('Magento\\Ui\\Component\\Listing', ['context' => $this->contextMock, 'data' => ['js_config' => ['extends' => 'test_config_extends', 'testData' => 'testValue'], 'buttons' => $buttons]]);
$this->contextMock->expects($this->at(0))->method('getNamespace')->willReturn(Listing::NAME);
$this->contextMock->expects($this->once())->method('addComponentDefinition')->with($listing->getComponentName(), ['extends' => 'test_config_extends', 'testData' => 'testValue']);
$this->contextMock->expects($this->once())->method('addButtons')->with($buttons, $listing);
$listing->prepare();
}
示例13: setup
public function setup()
{
$this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
$processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
$this->context->expects($this->any())->method('getProcessor')->willReturn($processor);
$this->uiComponentFactory = $this->getMock('Magento\\Framework\\View\\Element\\UiComponentFactory', [], [], '', false);
$this->attributeRepository = $this->getMock('Magento\\Customer\\Ui\\Component\\Listing\\AttributeRepository', [], [], '', false);
$this->attributeMetadata = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\AttributeMetadataInterface', [], '', false);
$this->component = new AttributeColumn($this->context, $this->uiComponentFactory, $this->attributeRepository);
$this->component->setData('name', 'gender');
}
示例14: setUp
protected function setUp()
{
$this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
$processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
$this->context->expects($this->any())->method('getProcessor')->willReturn($processor);
$this->columnFactory = $this->getMock('Magento\\Customer\\Ui\\Component\\ColumnFactory', ['create'], [], '', false);
$this->attributeRepository = $this->getMock('Magento\\Customer\\Ui\\Component\\Listing\\AttributeRepository', [], [], '', false);
$this->attribute = $this->getMock('Magento\\Customer\\Model\\Attribute', [], [], '', false);
$this->column = $this->getMockForAbstractClass('Magento\\Ui\\Component\\Listing\\Columns\\ColumnInterface', [], '', false);
$this->inlineEditUpdater = $this->getMockBuilder('Magento\\Customer\\Ui\\Component\\Listing\\Column\\InlineEditUpdater')->disableOriginalConstructor()->getMock();
$this->component = new Columns($this->context, $this->columnFactory, $this->attributeRepository, $this->inlineEditUpdater);
}
示例15: setUp
protected function setUp()
{
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->processorMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->setMethods([])->getMock();
$this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->disableOriginalConstructor()->setMethods([])->getMock();
$this->uiComponentFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponentFactory')->disableOriginalConstructor()->setMethods([])->getMock();
$this->systemStoreMock = $this->getMockBuilder('Magento\\Store\\Model\\System\\Store')->disableOriginalConstructor()->setMethods([])->getMock();
$this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->setMethods([])->getMock();
$this->contextMock->expects($this->atLeastOnce())->method('getProcessor')->willReturn($this->processorMock);
$this->processorMock->expects($this->atLeastOnce())->method('register');
$this->model = $objectManager->getObject('Magento\\Store\\Ui\\Component\\Listing\\Column\\Store', ['context' => $this->contextMock, 'uiComponent' => $this->uiComponentFactoryMock, 'systemStore' => $this->systemStoreMock, 'escaper' => $this->escaperMock, 'components' => [], 'data' => ['name' => $this->name]]);
}