protected function generateFile($module) { // get javascript by calling the mmwExtjs action $browser = new sfBrowser(); $browser->get('/' . $module . '/mmwExtjs/'); $javascript = $browser->getResponse()->getContent(); $file = sfMmwExtjsUtil::getJavascriptPath($module, 'base', true); file_put_contents($file, $javascript); chmod($file, 0666); $this->showMessage($module); }
public function call($uri, $method = 'get', $parameters = array(), $changeStack = true) { $browser = parent::call($uri, $method, $parameters, $changeStack); $crawler = new Crawler(); $crawler->add($browser->getResponse()->getContent()); return $crawler; }
/** * Dispatches a soap request via a sfTestBrowser to the tested application. * * @see SoapClient::__doRequest() */ public function __doRequest($request, $location, $action, $version) { $this->lastRequest = strval($request); $GLOBALS['HTTP_RAW_POST_DATA'] = $this->lastRequest; $this->browser->setHttpHeader('soapaction', strval($action)); sfFilter::$filterCalled = array(); $this->lastResponse = strval($this->browser->post('/')->getResponse()->getContent()); return $this->lastResponse; }
/** * Remembers last request data for debuging * Throws current exception */ public function call($uri, $method = 'get', $parameters = array(), $changeStack = true) { $this->cleanUp(); parent::call($uri, $method, $parameters, $changeStack); $this->_lastRequest = $this->getRequest()->getUri(); $this->_lastRequestParams = var_export($this->getRequest()->getParameterHolder()->getAll(), true); if ($e = $this->getCurrentException()) { // Throw exception if not forward404 if (!$e instanceof sfError404Exception) { $this->resetCurrentException(); throw $e; } } $content = $this->getResponse()->getContent(); if ($pos = strpos($content, sfPHPUnitObjectHelper::XSS_TOKEN)) { $start = $pos - 150 > 0 ? $pos - 150 : 0; throw new Exception("Found XSS tocken: \n\n" . substr($content, $start, 300)); } $this->notify('postCall'); }
/** * Log in as sfDoctrineGuardUser. * Only name of user should be provided. * Fetches user by it's username from sfGuardUser table. * * @param $name * @throws \Exception */ public function amLoggedAs($name) { if (!class_exists('Doctrine')) { throw new \Exception('Doctrine is not installed. Consider using \'signIn\' action instead'); } $user = \Doctrine::getTable('sfGuardUser')->findOneBy('username', $name); if (!$user) { throw new \Exception("User with name {$name} was not found in database"); } $user->clearRelated(); $browser = $this->browser; $this->browser->getContext()->getStorage()->initialize($browser->getContext()->getStorage()->getOptions()); $browser->getUser()->signIn($user); $this->debug('session: ' . json_encode($this->browser->getUser()->getAttributeHolder()->getAll())); $this->debug('user: '******'sfGuardSecurityUser'))); $this->debug('credentials: ' . json_encode($this->browser->getUser()->getCredentials())); $this->browser->getUser()->shutdown(); $this->browser->getContext()->getStorage()->shutdown(); $browser->get('/'); $this->followRedirect(); }
/** * Trigger a test failure if an uncaught exception is present. * * @return bool */ public function checkCurrentExceptionIsEmpty() { if (false === ($empty = parent::checkCurrentExceptionIsEmpty())) { $this->test()->fail(sprintf('last request threw an uncaught exception "%s: %s"', get_class($this->getCurrentException()), $this->getCurrentException()->getMessage())); } return $empty; }
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; /** * This is an example class of sfTestFunctional * It may require some attention to work with the default values (line 40). */ $browser = new sfBrowser(); $test_browser = new sfTestFunctional($browser); $test_browser->setTester('json.response', 'sfTesterJsonResponse'); $test_browser->get('/subredditdeadline')->with('request')->begin()->isParameter('module', 'subredditdeadline')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end()->with('json.response')->begin()->isJson()->end(); /** * Test the creation */ $entity = new Deadline(); $entity_array = $entity->exportTo('array'); $identifier = $entity->getTable()->getIdentifier(); /** * Please build a valid $entity_array here */ unset($entity_array[$identifier]); //$entity_array['name'] = "pony"; //$entity_array['created_at'] = date('Y-m-d H:i:s'); //$entity_array['updated_at'] = date('Y-m-d H:i:s'); $test_browser->call('/subredditdeadline', 'post', array('content' => json_encode($entity_array)))->with('request')->begin()->isParameter('module', 'subredditdeadline')->isParameter('action', 'create')->end()->with('response')->begin()->isStatusCode(200)->end(); /** * If the new entity has been created */ $location = $browser->getResponse()->getHttpHeader('Location'); if ($location) { // Get ?
public function __construct() { parent::__construct($hostname, $remote, $options); }
/** * Simulates the browser forward button. * * @return sfBrowser The current sfBrowser instance */ public function forward() { $this->test->comment('forward'); return parent::forward(); }
<?php define('MOBILE_USER_AGENT', 'KDDI-CA39 UP.Browser/6.2.0.13.1.5 (FUI) MMP/2.0'); $_SERVER['HTTP_USER_AGENT'] = MOBILE_USER_AGENT; function init() { include dirname(__FILE__) . '/../../bootstrap/functional.php'; include dirname(__FILE__) . '/../../bootstrap/database.php'; } function createUser($mailAddress, $user) { $params = array('authMailAddress' => array('mail_address' => $mailAddress, 'password' => 'password')); $user->post('/member/login/authMode/MailAddress', $params); return $user; } include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfBrowser(); $browser->setHttpHeader('User-Agent', MOBILE_USER_AGENT); $user = new sfTestFunctional($browser, new lime_test(null, new lime_output_color())); // create a test user: Mr_OpenPNE init(); $Mr_OpenPNE = createUser('*****@*****.**', $user); $Mr_OpenPNE->info('This is Mr.OpenPNE');
public function getContext($forceReload = false) { parent::getContext($forceReload); sfPropel::initialize($this->context->getEventDispatcher()); return $this->context; }
public function call($uri, $method = 'get', $parameters = array(), $changeStack = true) { parent::call($uri, $method, $parameters, $changeStack); $this->newRequestReset(); return $this; }