| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
include dirname(__FILE__) . '/../bootstrap/functional.php'; |
|---|
| 4 |
|
|---|
| 5 |
$browser = new loggedTest(new sfBrowser()); |
|---|
| 6 |
|
|---|
| 7 |
$browser->setTester('propel', 'sfTesterPropel'); |
|---|
| 8 |
|
|---|
| 9 |
$browser-> |
|---|
| 10 |
|
|---|
| 11 |
doLogin()-> |
|---|
| 12 |
|
|---|
| 13 |
info('index (list)')-> |
|---|
| 14 |
get('/messages/')-> |
|---|
| 15 |
with('request')->begin()-> |
|---|
| 16 |
isParameter('module', 'sfSocialMessage')-> |
|---|
| 17 |
isParameter('action', 'list')-> |
|---|
| 18 |
end()-> |
|---|
| 19 |
with('response')->begin()-> |
|---|
| 20 |
isStatusCode(200)-> |
|---|
| 21 |
checkElement('body h2', '/Messages received/')-> |
|---|
| 22 |
checkElement('ul#list li', 5)-> |
|---|
| 23 |
|
|---|
| 24 |
end(); |
|---|
| 25 |
|
|---|
| 26 |
$browser->test()->is($browser->getResponseDom()->getElementsByTagName('li')->item(3)->getAttribute('class'), ' unread', 'message is unread'); |
|---|
| 27 |
|
|---|
| 28 |
$browser-> |
|---|
| 29 |
|
|---|
| 30 |
info('click on a message')-> |
|---|
| 31 |
click('hello pal')-> |
|---|
| 32 |
with('request')->begin()-> |
|---|
| 33 |
isParameter('module', 'sfSocialMessage')-> |
|---|
| 34 |
isParameter('action', 'read')-> |
|---|
| 35 |
end()-> |
|---|
| 36 |
with('response')->begin()-> |
|---|
| 37 |
checkElement('body h2', '/hello pal/')-> |
|---|
| 38 |
end()-> |
|---|
| 39 |
|
|---|
| 40 |
info('reply to message')-> |
|---|
| 41 |
click('Reply')-> |
|---|
| 42 |
with('response')->begin()-> |
|---|
| 43 |
checkElement('input[name="sf_social_message[subject]"][value="Re: hello pal"]', true)-> |
|---|
| 44 |
checkElement('select#sf_social_message_to > option[value="3"][selected="selected"]', true)-> |
|---|
| 45 |
end()-> |
|---|
| 46 |
|
|---|
| 47 |
click('cancel') |
|---|
| 48 |
; |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
$browser->test()->is($browser->getResponseDom()->getElementsByTagName('li')->item(2)->getAttribute('class'), 'a read', 'message is now read'); |
|---|
| 52 |
|
|---|
| 53 |
$browser-> |
|---|
| 54 |
|
|---|
| 55 |
info('compose a new message')-> |
|---|
| 56 |
click('Compose a new message')-> |
|---|
| 57 |
with('request')->begin()-> |
|---|
| 58 |
isParameter('module', 'sfSocialMessage')-> |
|---|
| 59 |
isParameter('action', 'compose')-> |
|---|
| 60 |
end()-> |
|---|
| 61 |
with('response')->begin()-> |
|---|
| 62 |
checkElement('body h2', '/Compose a new message/')-> |
|---|
| 63 |
end()-> |
|---|
| 64 |
click('send', array('sf_social_message' => array( |
|---|
| 65 |
'subject' => '', |
|---|
| 66 |
'text' => '', |
|---|
| 67 |
'to' => array(), |
|---|
| 68 |
)))-> |
|---|
| 69 |
with('form')->begin()->hasErrors(3)-> |
|---|
| 70 |
isError('subject', 'required')-> |
|---|
| 71 |
isError('text', 'required')-> |
|---|
| 72 |
isError('to', 'required')-> |
|---|
| 73 |
end()-> |
|---|
| 74 |
click('send', array('sf_social_message' => array( |
|---|
| 75 |
'subject' => 'a message from functional test', |
|---|
| 76 |
'text' => 'TDD rulez! I found a lot of bugs doing these nice tests.', |
|---|
| 77 |
'to' => array(1, 2), |
|---|
| 78 |
)))-> |
|---|
| 79 |
with('form')->begin()->hasErrors(false)-> |
|---|
| 80 |
end()-> |
|---|
| 81 |
|
|---|
| 82 |
info('sent messages')-> |
|---|
| 83 |
get('/messages/sent')-> |
|---|
| 84 |
with('request')->begin()-> |
|---|
| 85 |
isParameter('module', 'sfSocialMessage')-> |
|---|
| 86 |
isParameter('action', 'sentlist')-> |
|---|
| 87 |
end()-> |
|---|
| 88 |
|
|---|
| 89 |
with('propel')->begin()-> |
|---|
| 90 |
check('sfSocialMessage', array( |
|---|
| 91 |
'user_from' => 8, |
|---|
| 92 |
'subject' => 'a message from functional test', |
|---|
| 93 |
'text' => 'TDD rulez! I found a lot of bugs doing these nice tests.', |
|---|
| 94 |
))-> |
|---|
| 95 |
end()-> |
|---|
| 96 |
with('propel')->begin()-> |
|---|
| 97 |
check('sfSocialMessageRcpt', array( |
|---|
| 98 |
'msg_id' => 7, |
|---|
| 99 |
'user_to' => 1, |
|---|
| 100 |
'read' => 0, |
|---|
| 101 |
))-> |
|---|
| 102 |
end()-> |
|---|
| 103 |
with('propel')->begin()-> |
|---|
| 104 |
check('sfSocialMessageRcpt', array( |
|---|
| 105 |
'msg_id' => 7, |
|---|
| 106 |
'user_to' => 2, |
|---|
| 107 |
'read' => 0, |
|---|
| 108 |
))-> |
|---|
| 109 |
|
|---|
| 110 |
end() |
|---|
| 111 |
; |
|---|