oliverdavies.uk/modules/opd_daily_emails/tests/src/Functional/DailyEmailTokenTest.php

48 lines
960 B
PHP
Raw Normal View History

<?php
namespace Drupal\Tests\opd_daily_emails\Functional;
use Drupal\Tests\BrowserTestBase;
2025-06-12 02:10:09 +01:00
use Drupal\Tests\RandomGeneratorTrait;
2025-05-13 23:42:39 +01:00
use Drupal\Tests\opd_daily_emails\Traits\DailyEmailTestTrait;
use Drupal\Tests\token\Functional\TokenTestTrait;
class DailyEmailTokenTest extends BrowserTestBase {
2025-05-13 23:42:39 +01:00
use DailyEmailTestTrait;
2025-06-12 02:10:09 +01:00
use RandomGeneratorTrait;
use TokenTestTrait;
public $defaultTheme = 'stark';
2025-05-29 18:12:17 +01:00
protected static $modules = [
'node',
'opd_daily_emails',
];
2025-06-12 02:10:09 +01:00
public function test_the_token_returns_the_number_of_published_daily_emails(): void {
2025-06-12 02:10:09 +01:00
$this->createDailyEmailNode(
isPublished: TRUE,
2025-06-15 17:22:37 +01:00
title: 'a',
2025-06-12 02:10:09 +01:00
);
$this->createDailyEmailNode(
isPublished: FALSE,
2025-06-15 17:22:37 +01:00
title: 'b',
2025-06-12 02:10:09 +01:00
);
$this->createDailyEmailNode(
isPublished: TRUE,
2025-06-15 17:22:37 +01:00
title: 'c',
2025-06-12 02:10:09 +01:00
);
$this->assertToken(
data: [],
expected: 2,
token: 'email-count',
type: 'opd-daily-emails',
);
}
}