function getRequest($params = array())
 {
     $request = new Zend_Controller_Request_HttpTestCase();
     foreach ($params as $key => $val) {
         $request->setParam($key, $val);
     }
     return $request;
 }
 /**
  * @param array $params
  * @return Ulrika_Auth_Adapter_Vk_Iframe
  */
 protected function createTestAdapter(array $params)
 {
     $request = new Zend_Controller_Request_HttpTestCase();
     $request->setParams($params);
     $config = array('appId' => self::APP_ID, 'secret' => self::APP_SECRET);
     $adapter = new Ulrika_Auth_Adapter_Vk_Widget($config);
     $adapter->setRequest($request);
     return $adapter;
 }
Example #3
0
 public function testDispatchLoopStartupWithMobileRequest()
 {
     $this->request->setModuleName('default')->setControllerName('foo')->setActionName('bar');
     $_SERVER['SERVER_NAME'] = 'mobile.domain.tld';
     $this->plugin->dispatchLoopStartup($this->request);
     $this->assertEquals('default', $this->request->getModuleName());
     $this->assertEquals('foo', $this->request->getControllerName());
     $this->assertEquals('bar', $this->request->getActionName());
     $this->assertEquals('mobile', $this->layout->getLayout());
 }
Example #4
0
 /**
  * @test
  * @group library
  */
 public function allRightsPropertyDefaultsToFalseWhenNotOverwrittenOrSetInRequest()
 {
     $request = new \Zend_Controller_Request_HttpTestCase();
     $request->setControllerName('group');
     $request->setActionName('setpagerights');
     $request->setParams(array('controller' => 'group', 'action' => 'setpagerights', 'params' => '{"id":"GROUP-edl54f03-nac4-4fdb-af34-72ebr0878rg7-GROUP","websiteId":"SITE-ae6e702f-10ac-4e1e-exwc-307e4b8765db-SITE","rights":"[]"}', 'module' => 'default'));
     $setPageRightsRequest = new \Cms\Request\Group\SetPageRights($request);
     $this->assertInternalType('boolean', $setPageRightsRequest->getAllRights());
     $this->assertSame(false, $setPageRightsRequest->getAllRights());
 }
Example #5
0
 /**
  * @test
  * @group library
  */
 public function completePropertyIsOverwrittenWhenSetInRequest()
 {
     $request = new \Zend_Controller_Request_HttpTestCase();
     $request->setControllerName('export');
     $request->setActionName('website');
     $request->setParams(array('controller' => 'export', 'action' => 'website', 'params' => '{"websiteid":"SITE-ae6e702f-10ac-4e1e-exwc-307e4b8765db-SITE","name":"test_export_0_website_complete","complete":false}', 'module' => 'default'));
     $exportWebsiteRequest = new \Cms\Request\Export\Website($request);
     $this->assertInternalType('boolean', $exportWebsiteRequest->getComplete());
     $this->assertSame(false, $exportWebsiteRequest->getComplete());
 }
Example #6
0
 public function doRequest($request)
 {
     // redirector should not exit
     $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $redirector->setExit(false);
     // json helper should not exit
     $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $zendRequest = new \Zend_Controller_Request_HttpTestCase();
     $zendRequest->setMethod($request->getMethod());
     $zendRequest->setCookies($request->getCookies());
     $zendRequest->setParams($request->getParameters());
     // Sf2's BrowserKit does not distinguish between GET, POST, PUT etc.,
     // so we set all parameters in ZF's request here to not break apps
     // relying on $request->getPost()
     $zendRequest->setPost($request->getParameters());
     $zendRequest->setRawBody($request->getContent());
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($this->extractHeaders($request));
     $_FILES = $this->remapFiles($request->getFiles());
     $_SERVER = array_merge($_SERVER, $request->getServer());
     $zendResponse = new \Zend_Controller_Response_HttpTestCase();
     $this->front->setRequest($zendRequest)->setResponse($zendResponse);
     ob_start();
     try {
         $this->bootstrap->run();
     } catch (\Exception $e) {
         ob_end_clean();
         throw $e;
     }
     ob_end_clean();
     $this->zendRequest = $zendRequest;
     $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $this->formatResponseHeaders($zendResponse));
     return $response;
 }
 function testClearingFitsOnListAction()
 {
     $vehicle = $this->createMMY(self::MAKE, self::MODEL, self::YEAR);
     $_SESSION['make'] = $vehicle->getLevel('make')->getId();
     $_SESSION['model'] = $vehicle->getLevel('model')->getId();
     $_SESSION['year'] = $vehicle->getLevel('year')->getId();
     $request = new Zend_Controller_Request_HttpTestCase();
     $request->setParams(array('make' => 0, 'model' => 0, 'year' => 0));
     $controller = new Elite_Vaf_ProductController_Test($request, new Zend_Controller_Response_HttpTestCase());
     $controller->listAction();
     $this->assertFalse(isset($_SESSION['make']), 'Controller should call storeFitInSession so that the session data gets cleared');
 }
Example #8
0
 /**
  * Sets GET values method
  *
  * @param  string|array $spec
  * @param  null|mixed   $value
  * @return Zend_Controller_Request_Http
  */
 public function setQuery($spec, $value = null)
 {
     if (!is_array($spec) && $value === null) {
         unset($_GET[$spec]);
         return $this;
     }
     return parent::setQuery($spec, $value);
 }
Example #9
0
 public function doRequest($request)
 {
     // redirector should not exit
     $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $redirector->setExit(false);
     // json helper should not exit
     $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $zendRequest = new \Zend_Controller_Request_HttpTestCase();
     $zendRequest->setMethod($request->getMethod());
     $zendRequest->setCookies($request->getCookies());
     $zendRequest->setParams($request->getParameters());
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($request->getServer());
     $_FILES = $request->getFiles();
     $_SERVER = array_merge($_SERVER, $request->getServer());
     $zendResponse = new \Zend_Controller_Response_HttpTestCase();
     $this->front->setRequest($zendRequest)->setResponse($zendResponse);
     ob_start();
     $this->bootstrap->run();
     ob_end_clean();
     $this->zendRequest = $zendRequest;
     $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $zendResponse->getHeaders());
     return $response;
 }
 /**
  * Set POST values method
  *
  * @param  string|array $spec
  * @param  null|mixed   $value
  * @return Zend_Controller_Request_Http
  */
 public function setPost($spec, $value = null)
 {
     if (!is_array($spec) && $value === null) {
         unset($_POST[$spec]);
         return $this;
     } elseif (is_array($spec) && empty($spec)) {
         $_POST = array();
         return $this;
     }
     return parent::setPost($spec, $value);
 }
Example #11
0
 public function doRequest($request)
 {
     // redirector should not exit
     $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $redirector->setExit(false);
     // json helper should not exit
     $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $zendRequest = new \Zend_Controller_Request_HttpTestCase();
     $zendRequest->setMethod($request->getMethod());
     $zendRequest->setCookies($request->getCookies());
     //$zendRequest->setParams($request->getParameters());
     if (strtoupper($request->getMethod()) == 'GET') {
         $_GET = $this->remapRequestParameters($request->getParameters());
     }
     if (strtoupper($request->getMethod()) == 'POST') {
         $_POST = $this->remapRequestParameters($request->getParameters());
     }
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($request->getServer());
     $_FILES = $this->remapFiles($request->getFiles());
     // это нужно для нормальной работы SE
     $_SERVER['HTTP_HOST'] = str_replace('http://', '', $this->host);
     if (isset($_SERVER['HTTP_REFERER'])) {
         $_SERVER['HTTP_REFERER'] = str_replace('http://localhost', '', $_SERVER['HTTP_REFERER']);
     }
     //$_SERVER['SERVER_SOFTWARE'] = '';
     $_SERVER['REQUEST_METHOD'] = strtoupper($request->getMethod());
     $_SERVER['REQUEST_URI'] = str_replace('http://localhost', '', $request->getUri());
     $zendResponse = new \Zend_Controller_Response_Http();
     $this->bootstrap->getBootstrap()->getContainer()->frontcontroller->setRequest($zendRequest)->setResponse($zendResponse);
     ob_start();
     $this->bootstrap->run();
     ob_end_clean();
     $this->zendRequest = $zendRequest;
     $headers['Content-type'] = "text/html; charset=UTF-8";
     $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $headers);
     return $response;
 }
 function getRequest($params = array())
 {
     $request = new Zend_Controller_Request_HttpTestCase();
     $request->setParams($params);
     return $request;
 }
 public function testIsExternalModuleIsFalseIfGetModuleNamesDoesntContainExternalString()
 {
     $request = new Zend_Controller_Request_HttpTestCase();
     $request->setModuleName('extern');
     $this->assertFalse($this->_sut->isExternalModule($request));
 }
 /**
  * Creates a controller for testing.
  *
  * @return Zend_Controller_Action
  */
 protected function createController()
 {
     $request = new Zend_Controller_Request_HttpTestCase();
     $request->setModuleName('my-module');
     $request->setControllerName('my-controller');
     $request->setActionName('my-action');
     $request->setDispatched(true);
     $arguments = array($request, new Zend_Controller_Response_HttpTestCase(), array());
     return $this->getMock('Zend_Controller_Action', null, $arguments);
 }
Example #15
0
 public function testFilterThemesFormForAllowedAndUnallowedElementsAndAttributes()
 {
     $dirtyHtml = '<p class="person" href="what"><strong>Bob</strong> is <em>dead</em>.</p><br />';
     $cleanHtml = '<p class="person">Bob is dead.</p><br />';
     // Create a request with dirty html for the collection description post variable
     $request = new Zend_Controller_Request_HttpTestCase();
     // post can be any nested array of strings
     $post = array('whatever' => $dirtyHtml, 'NestedArray' => array(0 => array(array('text' => $dirtyHtml), array('text' => $dirtyHtml)), 1 => array(array('text' => $dirtyHtml), array('text' => $dirtyHtml))), 'whatever2' => $dirtyHtml);
     $request->setPost($post);
     // Html purify the request
     $htmlPurifierPlugin = $this->_getHtmlPurifierPlugin(array('p', 'br'), array('*.class'));
     $htmlPurifierPlugin->filterThemesForm($request);
     // Make sure the description post variable is clean
     $post = $request->getPost();
     $this->assertEquals($cleanHtml, $post['whatever']);
     $this->assertEquals($cleanHtml, $post['NestedArray'][0][0]['text']);
     $this->assertEquals($cleanHtml, $post['NestedArray'][0][1]['text']);
     $this->assertEquals($cleanHtml, $post['NestedArray'][1][0]['text']);
     $this->assertEquals($cleanHtml, $post['NestedArray'][1][1]['text']);
     $this->assertEquals($cleanHtml, $post['whatever2']);
 }
Example #16
0
 public function testIsValidGetTrueWithQuery()
 {
     $request = new Zend_Controller_Request_HttpTestCase();
     $request->setMethod('get');
     $request->setQuery(array('foo' => 'bar'));
     Zend_Controller_Front::getInstance()->setRequest($request);
     $helper = new Waf_Zend_Controller_Action_Helper_Action_FormTest_TestFormHelper_GetDefault();
     $this->assertTrue($helper->isValidGet());
 }
 /**
  * Creates a controller for testing.
  *
  * @return Zend_Controller_Action
  */
 protected function createController()
 {
     $request = new Zend_Controller_Request_HttpTestCase();
     $request->setModuleName('my-module');
     $request->setControllerName('my-controller');
     $request->setActionName('my-action');
     $response = new Zend_Controller_Response_HttpTestCase();
     return $this->getMock('Zend_Controller_Action', null, array($request, $response));
 }
Example #18
0
 /**
  * Retrieve the list of all aliases
  *
  * @return array
  */
 public function getAliases()
 {
     if (isset($this->_routingInfo['aliases'])) {
         return $this->_routingInfo['aliases'];
     }
     return parent::getAliases();
 }
 private function _buildRequest($method, $uri)
 {
     $request = new Zend_Controller_Request_HttpTestCase();
     $request->setMethod($method)->setRequestUri($uri);
     return $request;
 }
 /**
  * Dispatches the action with the given name:
  *
  * Example:
  *
  *     $this->dispatch('my-action');
  *
  * @param string $action
  */
 protected function dispatch($action)
 {
     $this->request->setActionName($action);
     $this->controller->dispatch($this->actionNameToMethod($action));
 }