本文整理汇总了PHP中Aimeos\MShop\Factory::injectManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::injectManager方法的具体用法?PHP Factory::injectManager怎么用?PHP Factory::injectManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aimeos\MShop\Factory
的用法示例。
在下文中一共展示了Factory::injectManager方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSave
public function testSave()
{
$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
$item = $manager->findItem('CNE');
$item->setCode('jqadm-test-download');
$item->setId(null);
$manager->saveItem($item);
$param = array('download' => array('product.lists.id' => '', 'product.lists.status' => '1', 'attribute.label' => 'test'));
$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
$this->view->addHelper('param', $helper);
$file = $this->getMockBuilder('\\Psr\\Http\\Message\\UploadedFileInterface')->getMock();
$file->expects($this->any())->method('getError')->will($this->returnValue(UPLOAD_ERR_OK));
$request = $this->getMockBuilder('\\Psr\\Http\\Message\\ServerRequestInterface')->getMock();
$request->expects($this->any())->method('getUploadedFiles')->will($this->returnValue(array('download' => array('file' => $file))));
$helper = new \Aimeos\MW\View\Helper\Request\Standard($this->view, $request);
$this->view->addHelper('request', $helper);
$this->view->item = $item;
$this->object->expects($this->once())->method('storeFile')->will($this->returnValue('test/file.ext'));
$attributeStub = $this->getMockBuilder('\\Aimeos\\MShop\\Attribute\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
$attributeStub->expects($this->once())->method('saveItem');
\Aimeos\MShop\Factory::injectManager($this->context, 'attribute', $attributeStub);
\Aimeos\MShop\Factory::setCache(true);
$result = $this->object->save();
\Aimeos\MShop\Factory::setCache(false);
$item = $manager->getItem($item->getId(), array('attribute'));
$manager->deleteItem($item->getId());
$this->assertNull($this->view->get('errors'));
$this->assertNull($result);
$this->assertEquals(1, count($item->getListItems('attribute', 'hidden')));
}
示例2: testProcess
public function testProcess()
{
$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
$manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
$search = $manager->createSearch();
$search->setSlice(0, 1);
$result = $manager->searchItems($search);
if (($customerItem = reset($result)) === false) {
throw new \Exception('No customer item found');
}
$addrItem = $customerItem->getPaymentAddress();
$addrItem->setEmail('unittest@aimeos.org');
$mailStub = $this->getMockBuilder('\\Aimeos\\MW\\Mail\\None')->disableOriginalConstructor()->getMock();
$mailMsgStub = $this->getMockBuilder('\\Aimeos\\MW\\Mail\\Message\\None')->disableOriginalConstructor()->disableOriginalClone()->getMock();
$mailStub->expects($this->once())->method('createMessage')->will($this->returnValue($mailMsgStub));
$mailStub->expects($this->once())->method('send');
$this->context->setMail($mailStub);
$basketCntl = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
$basketCntl->setAddress($type, $addrItem);
$view = \TestHelperHtml::getView();
$view->orderBasket = $basketCntl->get();
$this->context->setView($view);
$this->object->setView($view);
$orderBaseStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
$customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
$orderBaseStub->expects($this->once())->method('saveItem');
$customerStub->expects($this->once())->method('saveItem');
\Aimeos\MShop\Factory::injectManager($this->context, 'customer', $customerStub);
\Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $orderBaseStub);
$this->object->process();
}
示例3: testSave
public function testSave()
{
$manager = \Aimeos\MShop\Factory::createManager($this->context, 'product');
$item = $manager->findItem('CNC');
$item->setCode('jqadm-test-image');
$item->setId(null);
$manager->saveItem($item);
$param = array('image' => array('product.lists.id' => array(''), 'media.languageid' => array('de'), 'media.label' => array('test')));
$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $param);
$this->view->addHelper('param', $helper);
$files = array('image' => array('files' => array(array('tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => 0))));
$helper = $this->getMockBuilder('\\Aimeos\\MW\\View\\Helper\\Request\\Standard')->setConstructorArgs(array($this->view, '', '', null, $files))->setMethods(array('checkUploadedFile'))->getMock();
$this->view->addHelper('request', $helper);
$this->view->item = $item;
$name = 'AdminJQAdmProductImageSave';
$this->context->getConfig()->set('controller/common/media/name', $name);
$cntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Media\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('add'))->getMock();
\Aimeos\Controller\Common\Media\Factory::injectController('\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub);
$cntlStub->expects($this->once())->method('add');
$mediaStub = $this->getMockBuilder('\\Aimeos\\MShop\\Media\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
\Aimeos\MShop\Factory::injectManager($this->context, 'media', $mediaStub);
$mediaStub->expects($this->once())->method('saveItem');
\Aimeos\MShop\Factory::setCache(true);
$result = $this->object->save();
\Aimeos\MShop\Factory::setCache(false);
$item = $manager->getItem($item->getId(), array('media'));
$manager->deleteItem($item->getId());
$this->assertNull($this->view->get('errors'));
$this->assertNull($result);
$this->assertEquals(1, count($item->getListItems('media')));
}
示例4: testProcess
public function testProcess()
{
$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
$manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($this->context);
$search = $manager->createSearch();
$search->setSlice(0, 1);
$result = $manager->searchItems($search);
if (($customerItem = reset($result)) === false) {
throw new \RuntimeException('No customer item found');
}
$addrItem = $customerItem->getPaymentAddress();
$addrItem->setEmail('unittest@aimeos.org');
$basketCntl = \Aimeos\Controller\Frontend\Basket\Factory::createController($this->context);
$basketCntl->setAddress($type, $addrItem);
$view = \TestHelperHtml::getView();
$helper = new \Aimeos\MW\View\Helper\Param\Standard($view, array('cs_option_account' => 1));
$view->addHelper('param', $helper);
$view->orderBasket = $basketCntl->get();
$this->context->setView($view);
$this->object->setView($view);
$orderBaseStub = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
$customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
$orderBaseStub->expects($this->once())->method('saveItem');
$customerStub->expects($this->once())->method('saveItem');
\Aimeos\MShop\Factory::injectManager($this->context, 'customer', $customerStub);
\Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $orderBaseStub);
$this->object->process();
}
示例5: testRun
public function testRun()
{
$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('deleteItems', 'saveItem'))->getMock();
\Aimeos\MShop\Factory::injectManager($this->context, 'product/lists', $stub);
$stub->expects($this->atLeastOnce())->method('deleteItems');
$stub->expects($this->atLeastOnce())->method('saveItem');
$this->object->run();
}
示例6: testProcessCheckDownload
public function testProcessCheckDownload()
{
$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Lists\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
$managerStub->expects($this->once())->method('saveItem');
\Aimeos\MShop\Factory::injectManager($this->context, 'customer/lists', $managerStub);
$class = new \ReflectionClass('\\Aimeos\\Client\\Html\\Account\\Download\\Standard');
$method = $class->getMethod('checkDownload');
$method->setAccessible(true);
\Aimeos\MShop\Factory::setCache(true);
$result = $method->invokeArgs($this->object, array(123, 321));
\Aimeos\MShop\Factory::setCache(false);
$this->assertTrue($result);
}
示例7: testProcessDirectDebit
public function testProcessDirectDebit()
{
$mock = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard')->setConstructorArgs(array($this->context))->setMethods(array('saveItem'))->getMock();
\Aimeos\MShop\Factory::injectManager($this->context, 'order', $mock);
$view = $this->object->getView();
$param = array('c_step' => 'process');
$helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $param);
$view->addHelper('param', $helper);
$orderid = $this->getOrder('2009-03-18 16:14:32')->getId();
$this->context->getSession()->set('aimeos/orderid', $orderid);
$this->object->process();
$this->assertEquals(0, count($view->get('standardErrorList', array())));
$this->assertEquals('POST', $view->standardMethod);
$this->assertEquals(array(), $view->standardProcessParams);
$this->assertEquals(true, $view->standardUrlExternal);
$this->assertEquals('http://baseurl/checkout/standard/?c_step=payment', $view->standardUrlPayment);
}
示例8: testUpdateStockSelection
public function testUpdateStockSelection()
{
$context = \TestHelperCntl::getContext();
$stockItem = \Aimeos\MShop\Factory::createManager($context, 'product/stock')->createItem();
$prodId = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('U:TEST')->getId();
$stockStub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Stock\\Standard')->setConstructorArgs(array($context))->setMethods(array('saveItem'))->getMock();
$stockStub->expects($this->once())->method('saveItem')->with($this->callback(function ($item) {
return $item->getStocklevel() === 300;
}));
\Aimeos\MShop\Factory::injectManager($context, 'product/stock', $stockStub);
$class = new \ReflectionClass('\\Aimeos\\Controller\\Common\\Order\\Standard');
$method = $class->getMethod('updateStockSelection');
$method->setAccessible(true);
$object = new \Aimeos\Controller\Common\Order\Standard($context);
$method->invokeArgs($object, array($prodId, 'default'));
}
示例9: getJsonSiteItem
/**
* @test
*/
public function getJsonSiteItem()
{
$ctx = $this->getMockBuilder('\\Aimeos\\MShop\\Context\\Item\\Standard')->getMock();
$siteManager = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard')->setMethods(array('createSearch', 'searchItems'))->disableOriginalConstructor()->getMock();
$items = array(new \Aimeos\MShop\Locale\Item\Site\Standard(array('id' => '1', 'label' => 'default')));
$siteManager->expects($this->once())->method('createSearch')->will($this->returnValue(new \Aimeos\MW\Criteria\PHP()));
$siteManager->expects($this->once())->method('searchItems')->will($this->returnValue($items));
\Aimeos\MShop\Factory::injectManager($ctx, 'locale/site', $siteManager);
$class = new \ReflectionClass('\\Aimeos\\Shop\\Controller\\ExtadmController');
$method = $class->getMethod('getJsonSiteItem');
$method->setAccessible(true);
$result = json_decode($method->invoke($this->object, $ctx, 'default'), true);
$this->assertInternalType('array', $result);
$this->assertArrayHasKey('locale.site.id', $result);
$this->assertArrayHasKey('locale.site.label', $result);
}