public function SmsDevelMessageTest::testDate in SMS Framework 8
Same name and namespace in other branches
- 2.x modules/sms_devel/tests/src/Functional/SmsDevelMessageTest.php \Drupal\Tests\sms_devel\Functional\SmsDevelMessageTest::testDate()
- 2.1.x modules/sms_devel/tests/src/Functional/SmsDevelMessageTest.php \Drupal\Tests\sms_devel\Functional\SmsDevelMessageTest::testDate()
Tests adding send date.
File
- modules/
sms_devel/ tests/ src/ Functional/ SmsDevelMessageTest.php, line 144
Class
- SmsDevelMessageTest
- Tests the message form.
Namespace
Drupal\Tests\sms_devel\FunctionalCode
public function testDate() {
$edit['number'] = $this
->randomPhoneNumbers(1)[0];
$edit['message'] = $this
->randomString();
$edit['skip_queue'] = FALSE;
$value = '2005-11-25 22:03:58';
$date = new DrupalDateTime($value, 'UTC');
// The user inputs field values in its own timezone, then it is auto
// converted on field submission to UTC.
$date_user = $date;
$date_user
->setTimezone(timezone_open(drupal_get_user_timezone()));
$edit['send_on[date]'] = $date_user
->format('Y-m-d');
$edit['send_on[time]'] = $date_user
->format('H:i:s');
$this
->drupalPostForm(Url::fromRoute('sms_devel.message'), $edit, t('Send'));
$this
->assertSession()
->statusCodeEquals(200);
$messages = SmsMessage::loadMultiple();
$message = reset($messages);
$this
->assertEquals($date
->format('U'), $message
->getSendTime(), 'Message has send time.');
}