1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
|
<?php
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new JobeetTestFunctional(new sfBrowser());
$browser->loadData();
$browser->setTester('doctrine', 'sfTesterDoctrine');
$browser->info('1 - The homepage')->
get('/en/')->
with('request')->begin()->
isParameter('module', 'sfJobeetJob')->
isParameter('action', 'index')->
end()->
with('response')->begin()->
info(' 1.1 - Expired jobs are not listed')->
checkElement('.jobs td.position:contains("expired")', false)->
end()
;
$max = sfConfig::get('app_max_jobs_on_homepage');
$browser->info('1 - The homepage')->
info(sprintf(' 1.2 - Only %s jobs are listed for a category', $max))->
with('response')->
checkElement('.category_programming tr', $max)
;
$browser->info('1 - The homepage')->
get('/en/')->
info(' 1.3 - A category has a link to the category page only if too many jobs')->
with('response')->begin()->
checkElement('.category_design .more_jobs', false)->
checkElement('.category_programming .more_jobs')->
end()
;
$browser->info('1 - The homepage')->
info(' 1.4 - Jobs are sorted by date')->
with('response')->begin()->
checkElement(sprintf('.category_programming tr:first a[href*="/%d/"]', $browser->getMostRecentProgrammingJob()->getId()))->
end()
;
$browser->info('2 - The job page')->
info(' 2.1 - Each job on the homepage is clickable and give detailed information')->
click('Web Developer', array(), array('position' => 1))->
with('request')->begin()->
isParameter('module', 'sfJobeetJob')->
isParameter('action', 'show')->
isParameter('company_slug', 'sensio-labs')->
isParameter('location_slug', 'paris-france')->
isParameter('position_slug', 'web-developer')->
isParameter('id', $browser->getMostRecentProgrammingJob()->getId())->
end()->
info(' 2.2 - A non-existent job forwards the user to a 404')->
get('/en/job/foo-inc/milano-italy/0/painter')->
with('response')->isStatusCode(404)->
info(' 2.3 - An expired job page forwards the user to a 404')->
get(sprintf('/job/sensio-labs/paris-france/%d/web-developer', $browser->getExpiredJob()->getId()))->
with('response')->isStatusCode(404)
;
$browser->info('3 - Post a Job page')->
info(' 3.1 - Submit a Job')->
get('/en/job/new')->
with('request')->begin()->
isParameter('module', 'sfJobeetJob')->
isParameter('action', 'new')->
end()
;
$browser->info('3 - Post a Job page')->
info(' 3.1 - Submit a Job')->
get('/en/job/new')->
with('request')->begin()->
isParameter('module', 'sfJobeetJob')->
isParameter('action', 'new')->
end()->
click('Preview your job', array('job' => array(
'company' => 'Sensio Labs',
'url' => 'http://www.sensio.com/',
'logo' => sfConfig::get('sf_upload_dir').'/jobs/sensio-labs.gif',
'position' => 'Developer',
'location' => 'Atlanta, USA',
'description' => 'You will work with symfony to develop websites for our customers.',
'how_to_apply' => 'Send me an email',
'email' => 'for.a.job@example.com',
'is_public' => false,
)))->
with('form')->begin()->
hasErrors(false)->
end()->
with('request')->begin()->
isParameter('module', 'sfJobeetJob')->
isParameter('action', 'create')->
end()->
isRedirected()->
followRedirect()->
with('request')->begin()->
isParameter('module', 'sfJobeetJob')->
isParameter('action', 'show')->
end()->
with('doctrine')->begin()->
check('JobeetJob', array(
'location' => 'Atlanta, USA',
'is_activated' => false,
'is_public' => false,
))->
end()
;
$browser->
info(' 3.2 - Submit a Job with invalid values')->
get('/en/job/new')->
click('Preview your job', array('job' => array(
'company' => 'Sensio Labs',
'position' => 'Developer',
'location' => 'Atlanta, USA',
'email' => 'not.an.email',
)))->
with('form')->begin()->
hasErrors(3)->
isError('description', 'required')->
isError('how_to_apply', 'required')->
isError('email', 'invalid')->
end()
;
$browser->info(' 3.3 - On the preview page, you can publish the job')->
createJob(array('position' => 'FOO1'))->
click('Publish', array(), array('method' => 'put', '_with_csrf' => true))->
with('doctrine')->begin()->
check('JobeetJob', array(
'position' => 'FOO1',
'is_activated' => true,
))->
end()
;
$browser->info(' 3.4 - On the preview page, you can delete the job')->
createJob(array('position' => 'FOO2'))->
click('Delete', array(), array('method' => 'delete', '_with_csrf' => true))->
with('doctrine')->begin()->
check('JobeetJob', array(
'position' => 'FOO2',
), false)->
end()
;
$browser->info(' 3.5 - When a job is published, it cannot be edited anymore')->
createJob(array('position' => 'FOO3'), true)->
get(sprintf('/job/%s/edit', $browser->getJobByPosition('FOO3')->getToken()))->
with('response')->begin()->
isStatusCode(404)->
end()
;
$browser->info(' 3.6 - A job validity cannot be extended before the job expires soon')->
createJob(array('position' => 'FOO4'), true)->
call(sprintf('/job/%s/extend', $browser->getJobByPosition('FOO4')->getToken()), 'put', array('_with_csrf' => true))->
with('response')->begin()->
isStatusCode(404)->
end()
;
$browser->info(' 3.7 - A job validity can be extended when the job expires soon')->
createJob(array('position' => 'FOO5'), true)
;
$job = $browser->getJobByPosition('FOO5');
$job->setExpiresAt(date('Y-m-d'));
$job->save();
$browser->
call(sprintf('/en/job/%s/extend', $job->getToken()), 'put', array('_with_csrf' => true))->
with('response')->isRedirected()
;
$job->refresh();
$browser->test()->is(
date('y/m/d', strtotime($job->getExpiresAt())),
date('y/m/d', time() + 86400 * sfConfig::get('app_active_days'))
);
$browser->
info('4 - User job history')->
loadData()->
restart()->
info(' 4.1 - When the user access a job, it is added to its history')->
get('/en/')->
click('Web Developer', array(), array('position' => 1))->
get('/en/')->
with('user')->begin()->
isAttribute('job_history', array($browser->getMostRecentProgrammingJob()->getId()))->
end()->
info(' 4.2 - A job is not added twice in the history')->
click('Web Developer', array(), array('position' => 1))->
get('/en/')->
with('user')->begin()->
isAttribute('job_history', array($browser->getMostRecentProgrammingJob()->getId()))->
end()
;
$browser->setHttpHeader('X_REQUESTED_WITH', 'XMLHttpRequest');
$browser->
info('5 - Live search')->
get('/en/search?query=sens*')->
with('response')->begin()->
checkElement('table tr', 2)->
end()
;
$browser->setHttpHeader('ACCEPT_LANGUAGE', 'fr_FR,fr,en;q=0.7');
$browser->
info('6 - User culture')->
restart()->
info(' 6.1 - For the first request, symfony guesses the best culture')->
get('/')->
isRedirected()->followRedirect()->
with('user')->isCulture('fr')->
info(' 6.2 - Available cultures are en and fr')->
get('/it/')->
with('response')->isStatusCode(404)
;
$browser->setHttpHeader('ACCEPT_LANGUAGE', 'en,fr;q=0.7');
$browser->
info(' 6.3 - The culture guessing is only for the first request')->
get('/')->
isRedirected()->followRedirect()->
with('user')->isCulture('fr')
;
$browser->
info(' 7 - Job creation page')->
get('/fr/')->
with('view_cache')->isCached(true, false)->
createJob(array('category_id' => Doctrine::getTable('JobeetCategory')->findOneBySlug('programming')->getId()), true)->
get('/fr/')->
with('view_cache')->isCached(true, false)->
with('response')->checkElement('.category_programming .more_jobs', '/23/')
;
|