<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new dnTestFunctional(new sfBrowser()); $neededStuff = csFactory::create('StuffResource', array('transaction_type' => 'need', 'title' => csFactory::generate('Stuff Resource '), 'owner_id' => csFactory::selectRandomId('sfGuardUser'))); $neededStuff->save(); $browser->get('/')->click('I Have')->isModuleAction('resource', 'have')->click('Stuff')->isModuleAction('stuff', 'have')->info('first we will look for something that is a have-resource, a pump, and expect no results')->call('/stuff/list', 'post', $parameters = array('q' => 'pump', 'type' => 'need'))->isModuleAction('resource', 'stuffList')->info('you have a pump? yeah so do we.')->with('response')->begin()->matches('!/pump/i')->end()->call('/stuff/list', 'post', $parameters = array('q' => 'picnic', 'type' => 'need'))->isModuleAction('resource', 'stuffList')->with('response')->begin()->matches('/picnic/i')->end()->call('/stuff/list', 'post', $parameters = array('q' => $neededStuff['title'], 'type' => 'need'))->isModuleAction('resource', 'stuffList')->with('response')->begin()->matches(sprintf('/%s/i', $neededStuff['title']))->end()->get(sprintf('/have/stuff/%s', $neededStuff['id']))->isModuleAction('stuff', 'show')->with('response')->begin()->matches(sprintf('/%s/', $neededStuff['title']))->end();
<?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();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new dnTestFunctional(new sfBrowser()); $browser->get('/')->click('I Need')->isModuleAction('resource', 'need')->click('A Hand')->isModuleAction('time', 'addNeed');
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new dnTestFunctional(new sfBrowser()); $browser->get('/')->click('I Need')->isModuleAction('resource', 'need')->click('A Place')->isModuleAction('resource', 'place')->with('response')->begin()->matches('/FEMA/')->end();
<?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();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new dnTestFunctional(new sfBrowser()); $neededTime = csFactory::create('TimeResource', array('transaction_type' => 'need', 'title' => csFactory::generate('Time Resource '), 'owner_id' => csFactory::selectRandomId('sfGuardUser'))); $neededTime['resource_date'] = date('Y-m-d'); $neededTime->save(); $browser->get('/')->click('I Have')->isModuleAction('resource', 'have')->click('Time')->isModuleAction('time', 'have')->call('/time/list', 'post', $parameters = array('start' => date('Y-m-d')))->isModuleAction('resource', 'timeList')->with('response')->begin()->matches(sprintf('/%s/i', $neededTime['title']))->end()->get(sprintf('/have/time/%s', $neededTime['id']))->isModuleAction('time', 'show')->with('response')->begin()->matches(sprintf('/%s/', $neededTime['title']))->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new dnTestFunctional(new sfBrowser()); $availableStuff = csFactory::create('StuffResource', array('transaction_type' => 'have', 'title' => csFactory::generate('Stuff Resource '), 'owner_id' => csFactory::selectRandomId('sfGuardUser'))); $availableStuff->save(); // Delete all existing data $browser->get('/')->click('I Need')->isModuleAction('resource', 'need')->click('Stuff')->isModuleAction('stuff', 'need')->info('first we will look for something that is a needed resource, a picnic table, and expect no results')->call('/stuff/list', 'post', $parameters = array('q' => 'picnic', 'type' => 'have'))->isModuleAction('resource', 'stuffList')->info('you need a picnic table? yeah well so does everyone else')->with('response')->begin()->matches('!/picnic/i')->end()->call('/stuff/list', 'post', $parameters = array('q' => 'pump', 'type' => 'have'))->isModuleAction('resource', 'stuffList')->with('response')->begin()->matches('/sump/i')->end()->call('/stuff/list', 'post', $parameters = array('q' => $availableStuff['title'], 'type' => 'have'))->isModuleAction('resource', 'stuffList')->with('response')->begin()->matches(sprintf('/%s/i', $availableStuff['title']))->end()->get(sprintf('/need/stuff/%s', $availableStuff['id']))->isModuleAction('stuff', 'show')->with('response')->begin()->matches(sprintf('/%s/', $availableStuff['title']))->end(); $resource = Doctrine_Core::getTable('stuffResource')->findOneByTitle('Sump Pump'); $browser->get(sprintf('/need/stuff/%s', $resource['id']))->isModuleAction('stuff', 'show')->with('response')->begin()->matches(sprintf('/%s/', $resource['title']))->checkForm('ContactResourceOwnerForm')->end()->setField('contact[email]', '*****@*****.**')->setField('contact[name]', 'Lacy')->setField('contact[phone]', '12345')->setField('contact[notes]', 'Takin notes!')->click('#resource-contact-submit')->with('form')->begin()->hasErrors(false)->end()->with('mailer')->begin()->hasSent(true)->withMessage($resource->User->username)->end()->with('doctrine')->begin()->check('Contact', array('resource_id' => $resource['id'], 'resource_type' => $resource['type']))->end();
<?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();