public function testInjectControllerReset() { $controller = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController($this->context, 'Standard'); \Aimeos\Controller\ExtJS\Admin\Job\Factory::injectController('\\Aimeos\\Controller\\ExtJS\\Admin\\Job\\Standard', $controller); \Aimeos\Controller\ExtJS\Admin\Job\Factory::injectController('\\Aimeos\\Controller\\ExtJS\\Admin\\Job\\Standard', null); $new = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController($this->context, 'Standard'); $this->assertNotSame($controller, $new); }
public function testRun() { $context = \TestHelper::getContext(); $aimeos = \TestHelper::getAimeos(); $name = 'ControllerJobsAdminJobDefaultRun'; $context->getConfig()->set('madmin/job/manager/name', $name); $context->getConfig()->set('controller/extjs/admin/job/name', $name); \Aimeos\MAdmin\Job\Manager\Factory::injectManager('\\Aimeos\\MAdmin\\Job\\Manager\\' . $name, $this->jobManagerStub); $adminJobCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\ExtJS\\Admin\\Job\\Standard')->setMethods(array('deleteItem'))->setConstructorArgs(array($context))->getMock(); \Aimeos\Controller\ExtJS\Admin\Job\Factory::injectController('\\Aimeos\\Controller\\ExtJS\\Admin\\Job\\' . $name, $adminJobCntlStub); $adminJobCntlStub->expects($this->once())->method('deleteItem')->will($this->returnValue(array('number' => 42))); $this->jobManagerStub->expects($this->atLeastOnce())->method('searchItems')->will($this->onConsecutiveCalls(array($this->jobItemStub), array())); $this->jobManagerStub->expects($this->once())->method('saveItem'); $this->jobItemStub->expects($this->atLeastOnce())->method('getMethod')->will($this->returnValue('Admin_Job.deleteItem')); $this->jobItemStub->expects($this->once())->method('setResult')->with($this->equalTo(array('number' => 42))); $this->jobItemStub->expects($this->once())->method('setStatus')->with($this->equalTo(-1)); $object = new \Aimeos\Controller\Jobs\Admin\Job\Standard($context, $aimeos); $object->run(); }
public function testUploadFile() { $config = $this->context->getConfig(); $config->set('controller/extjs/coupon/code/standard/uploaddir', './tmp'); $config->set('controller/extjs/coupon/code/standard/enablecheck', false); $cntlMock = $this->getMockBuilder('\\Aimeos\\Controller\\ExtJS\\Admin\\Job\\Standard')->setMethods(array('saveItems'))->setConstructorArgs(array($this->context))->getMock(); $cntlMock->expects($this->once())->method('saveItems'); $name = 'ControllerExtJSCouponCodeDefaultRun'; $this->context->getConfig()->set('controller/extjs/admin/job/name', $name); \Aimeos\Controller\ExtJS\Admin\Job\Factory::injectController('\\Aimeos\\Controller\\ExtJS\\Admin\\Job\\' . $name, $cntlMock); $testfiledir = __DIR__ . DIRECTORY_SEPARATOR . 'testfiles' . DIRECTORY_SEPARATOR; exec(sprintf('cp -r %1$s %2$s', escapeshellarg($testfiledir) . '*', escapeshellarg($this->testdir))); $_FILES['unittest'] = array('name' => 'coupon.zip', 'tmp_name' => $this->testdir . DIRECTORY_SEPARATOR . 'coupon.zip', 'error' => UPLOAD_ERR_OK); $params = new \stdClass(); $params->items = $this->testdir . DIRECTORY_SEPARATOR . 'coupon.zip'; $params->site = $this->context->getLocale()->getSite()->getCode(); $params->parentid = '-1'; $result = $this->object->uploadFile($params); $this->assertTrue(file_exists($result['items'])); unlink($result['items']); }