コード例 #1
0
<?php

/**
 * Test for creating "need stuff" resource entries
 */
include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new dnTestFunctional(new sfBrowser());
$browser->loadData();
$submitValues = array('title' => 'I need some stufffs', 'email' => '*****@*****.**', 'privacy' => 'web_form', 'description' => 'I need some money', 'neighborhood' => 'Downtown Nashville');
$dbValues = $submitValues;
$dbValues['transaction_type'] = 'need';
$browser->info('1 - You need stuff, fill out the form')->get('/need/stuff/add')->with('response')->begin()->checkForm('NeedStuffResourceForm')->end()->info('  1.1 - Fill out a blank form, check for errors')->click('form[name=stuff_resource] input[type=submit]')->with('request')->begin()->isParameter('module', 'stuff')->isParameter('action', 'addNeedCreate')->end()->with('form')->begin()->hasErrors(true)->end()->info('  1.2 - Fill out a real form')->click('form[name=stuff_resource] input[type=submit]', array('stuff_resource' => $submitValues))->with('form')->begin()->hasErrors(false)->end()->info('  1.3 - See that we sent the person an email')->with('mailer')->begin()->withMessage('*****@*****.**')->end()->with('doctrine')->begin()->info('  1.4 - See that the user was created an account')->check('sfGuardUser', array('username' => $submitValues['email'], 'email_address' => $submitValues['email']))->end();
$user = Doctrine_Core::getTable('sfGuardUser')->findOneByUsername($submitValues['email']);
$dbValues['owner_id'] = $user->id;
$browser->with('doctrine')->begin()->info('  1.5 - Check that the StuffResource entry itself was saved correctly')->check('StuffResource', $dbValues)->end()->with('response')->isRedirected()->followRedirect()->with('request')->begin()->isParameter('module', 'stuff')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->matches('/' . $submitValues['title'] . '/')->end();
コード例 #2
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new dnTestFunctional(new sfBrowser());
$browser->loadData();
$submitValues = array('resource_date' => date('Y-m-d', time() + 86400), 'start_time' => '17:30', 'end_time' => '19:30', 'title' => 'A test volunteer event', 'email' => '*****@*****.**', 'privacy' => 'web_form', 'description' => 'we\'re going to work on some stuffs', 'neighborhood' => 'Downtown Nashville');
$dbValues = $submitValues;
$dbValues['transaction_type'] = 'need';
$browser->info('1 - You need time, fill out the form')->get('/need/time/add')->with('response')->begin()->checkForm('NeedTimeResourceForm')->end()->info('  1.1 - Fill out a blank form, check for errors')->click('form[name=time_resource] input[type=submit]')->with('request')->begin()->isParameter('module', 'time')->isParameter('action', 'addNeedCreate')->end()->with('form')->begin()->hasErrors(true)->end()->info('  1.2 - Fill out a real form')->click('form[name=time_resource] input[type=submit]', array('time_resource' => $submitValues))->with('form')->begin()->hasErrors(false)->end()->info('  1.3 - See that we sent the person an email')->with('mailer')->begin()->withMessage('*****@*****.**')->end()->with('doctrine')->begin()->info('  1.4 - See that the user was created an account')->check('sfGuardUser', array('username' => $submitValues['email'], 'email_address' => $submitValues['email']))->end()->with('user')->begin()->info('  1.4.1 - What, you think because you created an account that you\'re logged in?  Not a chance.')->isAuthenticated(false)->end();
$user = Doctrine_Core::getTable('sfGuardUser')->findOneByUsername($submitValues['email']);
$dbValues['owner_id'] = $user->id;
$browser->with('doctrine')->begin()->info('  1.5 - Check that the TimeResource entry itself was saved correctly')->check('TimeResource', $dbValues)->end()->with('response')->isRedirected()->followRedirect()->with('request')->begin()->isParameter('module', 'time')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->matches('/' . $submitValues['title'] . '/')->end();
コード例 #3
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new dnTestFunctional(new sfBrowser());
$browser->loadData();
$user = Doctrine_Query::create()->from('sfGuardUser')->fetchOne();
$browser->info('1 - Test the user authentication hash system')->info('  1.1 - Try an invalid authentication')->get('/auth/fake')->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'authenticate')->end()->with('response')->begin()->isStatusCode(401)->matches('/Invalid Token/')->end()->info('  1.2 - Use the auth with a real key')->get('/auth/' . $user->password)->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'authenticate')->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->info('  1.3 - The user is now authenticated')->with('user')->begin()->isAuthenticated(true)->end()->info('  1.4 - Page is redirected to user resource')->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'resource')->end();
$browser->info('2 - Request my login token')->get('/user/send-token')->with('response')->begin()->isStatusCode(200)->checkForm('sendLoginTokenForm')->end()->info('  2.1 - Submit an invalid form')->click('form[id=send-token-form] input[type=submit]', array('send_login' => array('email' => '*****@*****.**')))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'sendLoginTokenProcess')->end()->with('form')->begin()->hasErrors(true)->end()->info('  2.2 - Submit a valid form')->click('form[id=send-token-form] input[type=submit]', array('send_login' => array('email' => '*****@*****.**')))->with('mailer')->begin()->hasSent(1)->withMessage('*****@*****.**')->end()->with('response')->begin()->matches('/Please check your email/')->end();
コード例 #4
0
<?php

/**
 * Test for creating "have stuff" resource entries
 */
include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new dnTestFunctional(new sfBrowser());
$browser->loadData();
$submitValues = array('title' => 'I have some stufffs', 'email' => '*****@*****.**', 'privacy' => 'web_form', 'description' => 'some stuffs', 'neighborhood' => 'Downtown Nashville');
$dbValues = $submitValues;
$dbValues['transaction_type'] = 'have';
$browser->info('1 - You have stuff, fill out the form')->get('/have/stuff/add')->with('response')->begin()->checkForm('HaveStuffResourceForm')->end()->info('  1.1 - Fill out a blank form, check for errors')->click('form[name=stuff_resource] input[type=submit]')->with('request')->begin()->isParameter('module', 'stuff')->isParameter('action', 'addHaveCreate')->end()->with('form')->begin()->hasErrors(true)->end()->info('  1.2 - Fill out a real form')->click('form[name=stuff_resource] input[type=submit]', array('stuff_resource' => $submitValues))->with('form')->begin()->hasErrors(false)->end()->info('  1.3 - See that we sent the person an email')->with('mailer')->begin()->withMessage($submitValues['email'])->checkBody('/auth\\//')->end()->with('doctrine')->begin()->info('  1.4 - See that the user was created an account')->check('sfGuardUser', array('username' => $submitValues['email'], 'email_address' => $submitValues['email']))->end();
$user = Doctrine_Core::getTable('sfGuardUser')->findOneByUsername($submitValues['email']);
$dbValues['owner_id'] = $user->id;
$browser->with('doctrine')->begin()->info('  1.5 - Check that the StuffResource entry itself was saved correctly')->check('StuffResource', $dbValues)->end()->with('response')->isRedirected()->followRedirect()->with('request')->begin()->isParameter('module', 'stuff')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->matches('/' . $submitValues['title'] . '/')->end();
$user = Doctrine_Core::getTable('sfGuardUser')->findOneByUsername($submitValues['email']);
$browser->info('going to the link from the email and verify we have an account')->get('/auth/foo-bar')->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'authenticate')->end()->with('user')->isAuthenticated(false)->get('/auth/' . $user->password)->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'authenticate')->end()->with('user')->isAuthenticated(true)->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'resource')->end();