You are here

public function HijriNodeDisplayTest::testFullDisplay in Hijri 1.0.x

Same name and namespace in other branches
  1. 3.0.x tests/src/Functional/HijriNodeDisplayTest.php \Drupal\Tests\hijri\Functional\HijriNodeDisplayTest::testFullDisplay()

File

tests/Functional/HijriNodeDisplayTest.php, line 48

Class

HijriNodeDisplayTest

Namespace

Drupal\Tests\hijri\Functional

Code

public function testFullDisplay() {
  $this
    ->drupalLogin($this
    ->createUser([
    'administer hijri',
  ]));
  $this
    ->drupalGet('admin/config/regional/date-time/hijri');
  $this->assert
    ->statusCodeEquals(200);
  $edit = [
    'hijri_correction_value' => 0,
    'hijri_types[]' => [
      'article',
    ],
    'hijri_display' => "full",
  ];
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->drupalGet('admin/config/regional/date-time/hijri');
  $this->account = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($this->account);
  $this->node = $this
    ->drupalCreateNode([
    'type' => 'article',
    'promote' => 1,
    'uid' => $this->account
      ->id(),
  ]);
  $this
    ->drupalGet('node/' . $this->node
    ->id());
  $this->assert
    ->pageTextContainsOnce(t('Submitted by @username on @hijri on @gregorian', [
    '@username' => $this->account
      ->getAccountName(),
    '@hijri' => $this->hijri_formatter
      ->format($this->node
      ->getCreatedTime(), 'custom', 'l j F Y'),
    '@gregorian' => \Drupal::service('date.formatter')
      ->format($this->node
      ->getCreatedTime(), 'custom', 'F j, Y'),
  ]));
}