本文整理汇总了PHP中Magento\Framework\ObjectManagerInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManagerInterface类的具体用法?PHP ObjectManagerInterface怎么用?PHP ObjectManagerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectManagerInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@inheritDoc}
*/
protected function setUp()
{
parent::setUp();
$this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date')
->disableOriginalConstructor()
->getMock();
$this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data')
->disableOriginalConstructor()
->getMock();
$this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface')
->disableOriginalConstructor()
->getMock();
$this->objectManagerMock
->expects($this->any())
->method('get')
->willReturn($this->helperMock);
$this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->exportViewedCsv = $objectManager->getObject(
'Magento\Reports\Controller\Adminhtml\Report\Product\ExportViewedCsv',
[
'context' => $this->contextMock,
'fileFactory' => $this->fileFactoryMock,
'dateFilter' => $this->dateMock,
]
);
}
开发者ID:nblair,项目名称:magescotch,代码行数:35,代码来源:ExportViewedCsvTest.php
示例2: updateFieldForTable
/**
* Replace {{skin url=""}} with {{view url=""}} for given table field
*
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param string $table
* @param string $col
* @return void
*/
function updateFieldForTable($objectManager, $table, $col)
{
/** @var $installer \Magento\Framework\Setup\ModuleDataSetupInterface */
$installer = $objectManager->create('\\Magento\\Framework\\Setup\\ModuleDataSetupInterface');
$installer->startSetup();
$table = $installer->getTable($table);
echo '-----' . "\n";
if ($installer->getConnection()->isTableExists($table)) {
echo 'Table `' . $table . "` processed\n";
$indexList = $installer->getConnection()->getIndexList($table);
$pkField = array_shift($indexList[$installer->getConnection()->getPrimaryKeyName($table)]['fields']);
/** @var $select \Magento\Framework\DB\Select */
$select = $installer->getConnection()->select()->from($table, ['id' => $pkField, 'content' => $col]);
$result = $installer->getConnection()->fetchPairs($select);
echo 'Records count: ' . count($result) . ' in table: `' . $table . "`\n";
$logMessages = [];
foreach ($result as $recordId => $string) {
$content = str_replace('{{skin', '{{view', $string, $count);
if ($count) {
$installer->getConnection()->update($table, [$col => $content], $installer->getConnection()->quoteInto($pkField . '=?', $recordId));
$logMessages['replaced'][] = 'Replaced -- Id: ' . $recordId . ' in table `' . $table . '`';
} else {
$logMessages['skipped'][] = 'Skipped -- Id: ' . $recordId . ' in table `' . $table . '`';
}
}
if (count($result)) {
printLog($logMessages);
}
} else {
echo 'Table `' . $table . "` was not found\n";
}
$installer->endSetup();
echo '-----' . "\n";
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:42,代码来源:themes_view.php
示例3: testExecute
public function testExecute()
{
$this->objectManager->expects($this->once())
->method('get')
->with('Magento\Framework\App\Cache')
->willReturn($this->cacheMock);
$this->cacheMock->expects($this->once())->method('clean');
$writeDirectory = $this->getMock('Magento\Framework\Filesystem\Directory\WriteInterface');
$writeDirectory->expects($this->atLeastOnce())->method('delete');
$this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory);
$this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true);
$progressBar = $this->getMockBuilder(
'Symfony\Component\Console\Helper\ProgressBar'
)
->disableOriginalConstructor()
->getMock();
$this->objectManager->expects($this->once())->method('configure');
$this->objectManager
->expects($this->once())
->method('create')
->with('Symfony\Component\Console\Helper\ProgressBar')
->willReturn($progressBar);
$this->manager->expects($this->exactly(6))->method('addOperation');
$this->manager->expects($this->once())->method('process');
$tester = new CommandTester($this->command);
$tester->execute([]);
$this->assertContains(
'Generated code and dependency injection configuration successfully.',
explode(PHP_EOL, $tester->getDisplay())
);
}
开发者ID:vasiljok,项目名称:magento2,代码行数:33,代码来源:DiCompileCommandTest.php
示例4: _getSubject
/**
* Get proxied instance
*
* @return \Magento\Framework\Stdlib\DateTime\DateTime
*/
protected function _getSubject()
{
if (!$this->_subject) {
$this->_subject = true === $this->_isShared ? $this->_objectManager->get($this->_instanceName) : $this->_objectManager->create($this->_instanceName);
}
return $this->_subject;
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:12,代码来源:Proxy.php
示例5: testUnloginAction
/**
* @covers \Magento\Setup\Controller\Session::testUnloginAction
*/
public function testUnloginAction()
{
$deployConfigMock = $this->getMock('Magento\Framework\App\DeploymentConfig', ['isAvailable'], [], '', false);
$deployConfigMock->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
$stateMock = $this->getMock('Magento\Framework\App\State', ['setAreaCode'], [], '', false);
$stateMock->expects($this->once())->method('setAreaCode');
$sessionConfigMock =
$this->getMock('Magento\Backend\Model\Session\AdminConfig', ['setCookiePath'], [], '', false);
$sessionConfigMock->expects($this->once())->method('setCookiePath');
$returnValueMap = [
['Magento\Framework\App\DeploymentConfig', $deployConfigMock],
['Magento\Framework\App\State', $stateMock],
['Magento\Backend\Model\Session\AdminConfig', $sessionConfigMock]
];
$this->objectManager->expects($this->atLeastOnce())
->method('get')
->will($this->returnValueMap($returnValueMap));
$sessionMock = $this->getMock('Magento\Backend\Model\Auth\Session', ['prolong'], [], '', false);
$this->objectManager->expects($this->once())
->method('create')
->will($this->returnValue($sessionMock));
$controller = new Session($this->objectManagerProvider);
$controller->prolongAction();
}
开发者ID:razbakov,项目名称:magento2,代码行数:32,代码来源:SessionTest.php
示例6: exceptionResponse
/**
* Processing section runtime errors
*
* @return void
*/
protected function exceptionResponse()
{
$dataMock = $this->getMock('Magento\\Framework\\Json\\Helper\\Data', ['jsonEncode'], [], '', false);
$this->objectManagerMock->expects($this->once())->method('get')->will($this->returnValue($dataMock));
$dataMock->expects($this->once())->method('jsonEncode')->will($this->returnValue('{json-data}'));
$this->responseMock->expects($this->once())->method('representJson')->with('{json-data}');
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:AddCommentTest.php
示例7: setUp
/**
* Set up
*/
public function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
$this->accountManagement = $this->objectManager->create('Magento\\Customer\\Api\\AccountManagementInterface');
$this->securityManager = $this->objectManager->create('Magento\\Security\\Model\\SecurityManager');
$this->passwordResetRequestEvent = $this->objectManager->get('Magento\\Security\\Model\\PasswordResetRequestEvent');
}
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:SecurityManagerTest.php
示例8: create
/**
* Create link builder instance
*
* @param string $instance
* @param array $arguments
* @return CopyConstructorInterface
* @throws \InvalidArgumentException
*/
public function create($instance, array $arguments = [])
{
if (!is_subclass_of($instance, '\\Magento\\Catalog\\Model\\Product\\CopyConstructorInterface')) {
throw new \InvalidArgumentException($instance . ' does not implement \\Magento\\Catalog\\Model\\Product\\CopyConstructorInterface');
}
return $this->objectManager->create($instance, $arguments);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:CopyConstructorFactory.php
示例9: setUp
protected function setUp()
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->groupRepository = $this->objectManager->create('Magento\\Customer\\Api\\GroupRepositoryInterface');
$this->groupFactory = $this->objectManager->create('Magento\\Customer\\Api\\Data\\GroupInterfaceFactory');
$this->searchCriteriaBuilder = $this->objectManager->create('Magento\\Framework\\Api\\SearchCriteriaBuilder');
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:7,代码来源:GroupRepositoryTest.php
示例10: testCreate
public function testCreate()
{
$this->objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager);
$this->objectManager->expects($this->once())->method('get')->with('Magento\\Framework\\Module\\Status');
$this->moduleStatusFactory = new ModuleStatusFactory($this->objectManagerProvider);
$this->moduleStatusFactory->create();
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:ModuleStatusFactoryTest.php
示例11: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
/* parse arguments */
$argIds = $input->getArgument(static::ARG_IDS);
if (is_null($argIds)) {
$ids = null;
$output->writeln('<info>List of all products will be pulled from Odoo.<info>');
} else {
$ids = explode(',', $argIds);
$output->writeln("<info>Products with Odoo IDs ({$argIds}) will be pulled from Odoo.<info>");
}
/* setup session */
$this->_setAreaCode();
/* call service operation */
/** @var ProductsFromOdooRequest $req */
$req = $this->_manObj->create(ProductsFromOdooRequest::class);
$req->setOdooIds($ids);
/** @var ProductsFromOdooResponse $resp */
$resp = $this->_callReplicate->productsFromOdoo($req);
if ($resp->isSucceed()) {
$output->writeln('<info>Replication is done.<info>');
} else {
$output->writeln('<info>Replication is failed.<info>');
}
}
开发者ID:praxigento,项目名称:mobi_mod_mage2_odoo,代码行数:28,代码来源:Products.php
示例12: getReport
/**
* @param string $requestName
* @return AbstractCollection
* @throws \Exception
*/
public function getReport($requestName)
{
if (!isset($this->collections[$requestName])) {
throw new \Exception(sprintf('Not registered handle %s', $requestName));
}
return $this->objectManager->create($this->collections[$requestName]);
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:12,代码来源:CollectionFactory.php
示例13: _getSubject
/**
* Retrieve subject
*
* @return \Magento\Config\Model\Config\Structure\SearchInterface
*/
protected function _getSubject()
{
if (!$this->_subject) {
$this->_subject = $this->_objectManager->get('Magento\\Config\\Model\\Config\\Structure');
}
return $this->_subject;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:Proxy.php
示例14: create
/**
* @return \Magento\Framework\View\Result\Layout
*/
public function create()
{
/** @var \Magento\Framework\View\Result\Layout $resultLayout */
$resultLayout = $this->objectManager->create($this->instanceName);
$resultLayout->addDefaultHandle();
return $resultLayout;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:LayoutFactory.php
示例15: get
/**
* Retrieve indexer instance by id
*
* @param string $indexerId
* @return IndexerInterface
*/
public function get($indexerId)
{
if (!isset($this->indexers[$indexerId])) {
$this->indexers[$indexerId] = $this->objectManager->create('Magento\\Indexer\\Model\\IndexerInterface')->load($indexerId);
}
return $this->indexers[$indexerId];
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:IndexerRegistry.php
示例16: getConfigurableAttributeOptions
protected function getConfigurableAttributeOptions()
{
/** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection $optionCollection */
$optionCollection = $this->objectManager->create('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Option\\Collection');
$options = $optionCollection->setAttributeFilter($this->configurableAttribute->getId())->getData();
return $options;
}
开发者ID:tingyeeh,项目名称:magento2,代码行数:7,代码来源:ProductRepositoryTest.php
示例17: testCreate
public function testCreate()
{
$actionInterfaceMock = $this->getMockForAbstractClass('Magento\\Framework\\Indexer\\ActionInterface', [], '', false);
$this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\Indexer\\ActionInterface', [])->willReturn($actionInterfaceMock);
$this->model->create('Magento\\Framework\\Indexer\\ActionInterface');
$this->assertInstanceOf('Magento\\Framework\\Indexer\\ActionInterface', $actionInterfaceMock);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:ActionFactoryTest.php
示例18: testTransactionList
/**
* Tests list of order transactions
* @dataProvider filtersDataProvider
*/
public function testTransactionList($filters)
{
/** @var Order $order */
$order = $this->objectManager->create('Magento\\Sales\\Model\\Order');
/**
* @var $transactionRepository \Magento\Sales\Model\Order\Payment\Transaction\Repository
*/
$transactionRepository = 'Magento\\Sales\\Model\\Order\\Payment\\Transaction\\Repository';
$transactionRepository = $this->objectManager->create($transactionRepository);
$order->loadByIncrementId('100000006');
/** @var Payment $payment */
$payment = $order->getPayment();
/** @var Transaction $transaction */
$transaction = $transactionRepository->getByTransactionId('trx_auth', $payment->getId(), $order->getId());
$childTransactions = $transaction->getChildTransactions();
$childTransaction = reset($childTransactions);
/** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->create('Magento\\Framework\\Api\\SearchCriteriaBuilder');
$searchCriteriaBuilder->addFilters($filters);
$searchData = $searchCriteriaBuilder->create()->__toArray();
$requestData = ['searchCriteria' => $searchData];
$serviceInfo = ['rest' => ['resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($requestData), 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET], 'soap' => ['service' => self::SERVICE_READ_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => self::SERVICE_READ_NAME . 'getList']];
$result = $this->_webApiCall($serviceInfo, $requestData);
$this->assertArrayHasKey('items', $result);
$transactionData = $this->getPreparedTransactionData($transaction);
$childTransactionData = $this->getPreparedTransactionData($childTransaction);
$transactionData['child_transactions'][] = $childTransactionData;
$expectedData = [$transactionData, $childTransactionData];
$this->assertEquals($expectedData, $result['items']);
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:34,代码来源:TransactionTest.php
示例19: testWrongTypeException
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage WrongClass class doesn't implement \Magento\Payment\Model\MethodInterface
*/
public function testWrongTypeException()
{
$className = 'WrongClass';
$methodMock = $this->getMock($className, [], [], '', false);
$this->_objectManagerMock->expects($this->once())->method('create')->with($className, [])->will($this->returnValue($methodMock));
$this->_factory->create($className);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:FactoryTest.php
示例20: testShipmentGet
/**
* @magentoApiDataFixture Magento/Sales/_files/shipment.php
*/
public function testShipmentGet()
{
/** @var \Magento\Sales\Model\Order\Shipment $shipment */
$shipmentCollection = $this->objectManager->get('Magento\\Sales\\Model\\ResourceModel\\Order\\Shipment\\Collection');
$shipment = $shipmentCollection->getFirstItem();
$shipment->load($shipment->getId());
$serviceInfo = ['rest' => ['resourcePath' => self::RESOURCE_PATH . '/' . $shipment->getId(), 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET], 'soap' => ['service' => self::SERVICE_READ_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => self::SERVICE_READ_NAME . 'get']];
$result = $this->_webApiCall($serviceInfo, ['id' => $shipment->getId()]);
$data = $result;
$this->assertArrayHasKey('items', $result);
$this->assertArrayHasKey('tracks', $result);
unset($data['items']);
unset($data['packages']);
unset($data['tracks']);
foreach ($data as $key => $value) {
if (!empty($value)) {
$this->assertEquals($shipment->getData($key), $value, $key);
}
}
$shipmentItem = $this->objectManager->get('Magento\\Sales\\Model\\Order\\Shipment\\Item');
foreach ($result['items'] as $item) {
$shipmentItem->load($item['entity_id']);
foreach ($item as $key => $value) {
$this->assertEquals($shipmentItem->getData($key), $value, $key);
}
}
$shipmentTrack = $this->objectManager->get('Magento\\Sales\\Model\\Order\\Shipment\\Track');
foreach ($result['tracks'] as $item) {
$shipmentTrack->load($item['entity_id']);
foreach ($item as $key => $value) {
$this->assertEquals($shipmentTrack->getData($key), $value, $key);
}
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:37,代码来源:ShipmentGetTest.php
注:本文中的Magento\Framework\ObjectManagerInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论