/** * executed before each test */ public function _before() { $this->markTestSkipped('Mocking up php functions doesnt work for zephir extensions.'); $_FILES = ['photo' => ['name' => ['f0', 'f1', ['f2', 'f3'], [[[['f4']]]]], 'type' => ['text/plain', 'text/csv', ['image/png', 'image/jpeg'], [[[['application/octet-stream']]]]], 'tmp_name' => ['t0', 't1', ['t2', 't3'], [[[['t4']]]]], 'error' => [0, 0, [0, 0], [[[[8]]]]], 'size' => [10, 20, [30, 40], [[[[50]]]]]]]; $request = new Request(); $request->setDI($this->tester->getApplication()->getDI()); $uploadedFiles = $request->getUploadedFiles(); $files = []; /** @var Request\File $file */ foreach ($uploadedFiles as $file) { $files[] = ['name' => $file->getName(), 'tmp_name' => $file->getTempName(), 'type' => $file->getType(), 'size' => $file->getSize(), 'error' => $file->getError()]; } $this->files = $files; Test::func('Phalcon\\Validation\\Validator', 'getimagesize', function ($tmpName) { $tmpSizes = ['t0' => null, 't1' => null, 't2' => [500, 500], 't3' => [1000, 1000], 't4' => null]; return $tmpSizes[$tmpName]; }); Test::func('Phalcon\\Validation\\Validator', 'finfo_open', function ($mimeType) { return null; }); Test::func('Phalcon\\Validation\\Validator', 'finfo_file', function ($tmp, $tmpName) { $tmpTypes = ['t0' => 'text/plain', 't1' => 'text/csv', 't2' => 'image/png', 't3' => 'image/jpeg', 't4' => 'application/octet-stream']; return $tmpTypes[$tmpName]; }); Test::func('Phalcon\\Validation\\Validator', 'is_uploaded_file', function ($tmpName) { return true; }); Test::func('Phalcon\\Validation\\Validator', 'finfo_close', function ($tmp, $tmpName) { }); $_SERVER["REQUEST_METHOD"] = "POST"; }
public function setUp() { $di = new DI(); $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['REQUEST_URI'] = '/path?foo=aaa&bar=bbb'; $_GET = array('_url' => '/path', 'foo' => 'aaa', 'bar' => 'bbb'); $request = new Request(); $request->setDI($di); $this->request = $request; $response = new Response(); $response->setDI($di); $this->response = $response; $eventsManager = new Manager(); $cors = new Cors(array(array('domain' => 'bar.com'))); $di->set('request', $request, true); $di->set('response', $response, true); $di->set('eventsManager', $eventsManager); $di->set('cors', $cors); $this->di = $di; $application = new Application(); $application->setDI($di); $application->setEventsManager($eventsManager); $this->application = $application; }
/** * */ public function setUp() { $di = new DI(); $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['REQUEST_URI'] = '/path?foo=aaa&bar=bbb'; $_GET = array('_url' => '/path', 'foo' => 'aaa', 'bar' => 'bbb'); $request = new Request(); $request->setDI($di); $this->request = $request; $response = new Response(); $response->setDI($di); $dispatcher = new Dispatcher(); $dispatcher->setDI($di); $this->dispatcher = $dispatcher; $cache = new BackendCache(new FrontendCache()); $di->set('viewCache', $cache); $config = new Config(array('cache' => array('enable' => true))); $di->set('config', $config); $eventsManager = new Manager(); $di->set('request', $request, true); $di->set('response', $response, true); $di->set('dispatcher', $dispatcher, true); $di->set('eventsManager', $eventsManager); $this->di = $di; $application = new Application(); $application->setDI($di); $application->setEventsManager($eventsManager); $this->application = $application; }
public function setDI(DiInterface $di) { parent::setDI($di); }