<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; Doctrine::loadData(sfConfig::get('sf_data_dir') . '/fixtures'); $browser = new sfTestFunctional(new sfBrowser()); $browser->setTester('doctrine', 'sfTesterDoctrine'); $browser->call('usermodel/1/concept/200.html', 'put', array('bloom_evaluation' => 0, 'concept_id' => 200, '_with_csrf' => true))->with('doctrine')->begin()->check('UserModel', array('bloom_evaluation' => 0, 'concept_id' => 200))->end();
$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 ? $test_browser->get($location)->with('request')->begin()->isParameter('module', 'subredditdeadline')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->end()->with('json.response')->begin()->isJson()->end(); // Update ? $test_browser->call($location, 'put', array('content' => json_encode($entity_array)))->with('request')->begin()->isParameter('module', 'subredditdeadline')->isParameter('action', 'update')->end()->with('response')->begin()->isStatusCode(200)->end(); // Delete ? $test_browser->call($location, 'delete')->with('request')->begin()->isParameter('module', 'subredditdeadline')->isParameter('action', 'delete')->end()->with('response')->begin()->isStatusCode(200)->end(); } else { $test_browser->test()->fail("The last response doesn't have any Location header!"); }
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; Doctrine::loadData(sfConfig::get('sf_test_dir') . '/fixtures'); $browser = new sfTestFunctional(new sfBrowser()); #$browser->setTester('doctrine', 'sfTesterDoctrine'); $browser->get('domain.json')->with('request')->isFormat('json')->with('response')->begin()->end(); $browser->setTester('doctrine', 'sfTesterDoctrine'); $browser->call('domain/security', 'put', array('concept_name' => 'prova', '_with_csrf' => true));
public function call($uri, $method = 'get', $parameters = array(), $changeStack = true) { $conn = Doctrine::getConnectionByTableName('sf_guard_user'); $conn->clear(); return parent::call($uri, $method, $parameters, $changeStack); }
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $test = $browser->test(); $conn = Doctrine::getConnectionByTableName('location'); $conn->beginTransaction(); $browser->call('/location/831', 'GET', array())->with('request')->begin()->isParameter('module', 'location')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/profit/13', 'GET', array())->with('request')->begin()->isParameter('module', 'profit')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/event/22', 'GET', array())->with('request')->begin()->isParameter('module', 'event')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->end(); $conn->rollback();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $test = $browser->test(); $conn = Doctrine::getConnectionByTableName('location'); $conn->beginTransaction(); $browser->call('/login', 'GET', array())->with('request')->begin()->isParameter('module', 'sfGuardAuth')->isParameter('action', 'signin')->end()->with('response')->begin()->isStatusCode(401)->end(); $browser->call('/sfJqueryFormVal/FloginForm.js', 'GET', array())->with('request')->begin()->isParameter('module', 'sfJqueryFormVal')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/login', 'POST', array('signin' => array('username' => 'testuser', 'password' => 'testuser'), 'menu' => 'sf_guard_signin'))->with('request')->begin()->isParameter('module', 'sfGuardAuth')->isParameter('action', 'signin')->end()->info('user not registered')->with('form')->begin()->hasErrors(true)->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/sfJqueryFormVal/FloginForm.js', 'GET', array())->with('request')->begin()->isParameter('module', 'sfJqueryFormVal')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/user/new', 'GET', array())->with('request')->begin()->isParameter('module', 'sfApply')->isParameter('action', 'apply')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/sfJqueryFormVal/FRegistrationForm.js', 'GET', array())->with('request')->begin()->isParameter('module', 'sfJqueryFormVal')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/sfJqueryFormVal/remote/FRegistrationForm/sfValidatorDoctrineUnique', 'GET', array('column' => 'username', 'sfApplyApply' => array('username' => 'limitium')))->with('request')->begin()->isParameter('module', 'sfJqueryFormVal')->isParameter('action', 'remote')->end()->with('response')->begin()->isStatusCode(200)->info("user name limitium busy")->matches("/false/")->end(); $browser->call('/sfJqueryFormVal/remote/FRegistrationForm/sfValidatorDoctrineUnique', 'GET', array('column' => 'username', 'sfApplyApply' => array('username' => 'testuser')))->with('request')->begin()->isParameter('module', 'sfJqueryFormVal')->isParameter('action', 'remote')->end()->with('response')->begin()->isStatusCode(200)->info("user name testuser free")->matches("/true/")->end(); $browser->call('/sfJqueryFormVal/remote/FRegistrationForm/sfValidatorDoctrineUnique', 'GET', array('column' => 'email', 'sfApplyApply' => array('email' => '*****@*****.**')))->with('request')->begin()->isParameter('module', 'sfJqueryFormVal')->isParameter('action', 'remote')->end()->with('response')->begin()->isStatusCode(200)->matches("/false/")->info("email limitium busy")->end(); $browser->call('/sfJqueryFormVal/remote/FRegistrationForm/sfValidatorDoctrineUnique', 'GET', array('column' => 'email', 'sfApplyApply' => array('email' => '*****@*****.**')))->with('request')->begin()->isParameter('module', 'sfJqueryFormVal')->isParameter('action', 'remote')->end()->with('response')->begin()->isStatusCode(200)->info("email testuser free")->matches("/true/")->end(); $browser->get('/user/new')->click('.button_01', array('sfApplyApply' => array('username' => 'testuser', 'password' => 'testuser', 'email' => '*****@*****.**', 'email2' => '*****@*****.**'), array('_with_csrf' => true)))->info("create user")->with('request')->begin()->isParameter('module', 'sfApply')->isParameter('action', 'apply')->end()->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isRedirected(1)->isStatusCode(302)->end()->followRedirect(); $browser->with('request')->begin()->isParameter('module', 'collector')->isParameter('action', 'locations')->end()->with('response')->begin()->isStatusCode(200)->matches("/Поздравляем с успешной регистрацией/")->end(); $browser->call('/my_edit', 'GET', array())->with('request')->begin()->isParameter('module', 'profile')->isParameter('action', 'editMy')->end(); $browser->with('request')->begin()->isForwardedTo('profile', 'edit')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/profile/city', 'GET', array('q' => 'моск', 'limit' => '10', 'timestamp' => '1319706599403'))->with('request')->begin()->isParameter('module', 'profile')->isParameter('action', 'city')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->get('/my_edit')->click('.button_01', array('sf_medtod' => 'put', 'profile' => array('first_name' => 'tetst', 'last_name' => 'test', 'birth_date' => '12.10.2011', 'city_id' => '2242', 'description' => ' <p>test</p>', 'sex' => 'on', 'id' => $testuser->user_id), array('_with_csrf' => true), 'id' => $testuser->user_id))->with('request')->begin()->isParameter('module', 'profile')->isParameter('action', 'update')->end(); $browser->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isRedirected(1)->isStatusCode(302)->end()->followRedirect(); $browser->with('request')->begin()->isParameter('module', 'profile')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/logout', 'GET', array())->with('request')->begin()->isParameter('module', 'sfGuardAuth')->isParameter('action', 'signout')->end(); $browser->with('response')->begin()->isRedirected(1)->isStatusCode(302)->end()->followRedirect(); $browser->with('request')->begin()->isParameter('module', 'collector')->isParameter('action', 'locations')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/data', 'GET', array())->with('request')->begin()->isParameter('module', 'collector')->isParameter('action', 'data')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->call('/login', 'GET', array())->with('request')->begin()->isParameter('module', 'sfGuardAuth')->isParameter('action', 'signin')->end()->with('response')->begin()->isStatusCode(401)->end();