You are here

public function SmsDevelTestSendFormTestCase::testDevelSendReceiveForm in SMS Framework 7

Tests if messages sent using the test send form are stored properly.

File

modules/sms_devel/tests/sms_devel.test, line 33
Tests for the SMS Devel module.

Class

SmsDevelTestSendFormTestCase
Provides tests for the SMS Devel Test Send Form.

Code

public function testDevelSendReceiveForm() {

  // Create privileged user.
  $user = $this
    ->drupalCreateUser(array(
    'administer smsframework',
  ));
  $this
    ->drupalLogin($user);

  // Set up test default gateway.
  variable_set('sms_default_gateway', 'test');
  $test_message1 = array(
    'number' => '1234567890',
    'message' => 'Testing Send Message Button',
  );
  $this
    ->drupalPost('admin/smsframework/devel', $test_message1, t('Send Message'));
  $this
    ->assertResponse(200);
  $this
    ->assertText('Form submitted ok for number ' . $test_message1['number'] . ' and message: ' . $test_message1['message'], 'Successfully sent message using form.');

  // Check from gateway that the sms got sent. Use array_intersect_assoc() to
  // remove other array elements not needed.
  $result = array_intersect_assoc(sms_test_gateway_result(), $test_message1);
  $this
    ->assertEqual($result, $test_message1, 'Message was sent correctly using sms_devel.');
  $test_message2 = array(
    'number' => '0987654321',
    'message' => 'Testing Receive Message Button',
  );
  $this
    ->drupalPost('admin/smsframework/devel', $test_message2, t('Receive Message'));
  $this
    ->assertResponse(200);
  $this
    ->assertText('Message received from number ' . $test_message2['number'] . ' and message: ' . $test_message2['message'], 'Successfully received message using form.');

  // Use sms_test_gateway_get_incoming to get the incoming sms.
  $result = array_intersect_assoc(sms_test_gateway_get_incoming('process'), $test_message2);
  $this
    ->assertEqual($result, $test_message2, 'Message was received correctly using sms_devel.');
}