46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Drupal\Tests\opd_daily_emails\Functional;
|
||
|
|
||
|
use Drupal\Tests\BrowserTestBase;
|
||
|
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||
|
use Drupal\Tests\token\Functional\TokenTestTrait;
|
||
|
use Drupal\node\NodeInterface;
|
||
|
use Symfony\Component\HttpFoundation\Response;
|
||
|
|
||
|
class DailyEmailTokenTest extends BrowserTestBase {
|
||
|
|
||
|
use NodeCreationTrait;
|
||
|
use TokenTestTrait;
|
||
|
|
||
|
public $defaultTheme = 'stark';
|
||
|
|
||
|
public static $modules = [
|
||
|
'node',
|
||
|
'opd_daily_emails',
|
||
|
];
|
||
|
|
||
|
public function test_the_token_returns_the_number_of_sent_daily_emails(): void {
|
||
|
$this->createDailyEmailNode(['status' => NodeInterface::PUBLISHED]);
|
||
|
$this->createDailyEmailNode(['status' => NodeInterface::NOT_PUBLISHED]);
|
||
|
$this->createDailyEmailNode(['status' => NodeInterface::PUBLISHED]);
|
||
|
|
||
|
$this->assertToken(
|
||
|
data: [],
|
||
|
expected: 2,
|
||
|
token: 'email-count',
|
||
|
type: 'opd-daily-emails',
|
||
|
);
|
||
|
}
|
||
|
|
||
|
private function createDailyEmailNode(array $options): NodeInterface {
|
||
|
return $this->createNode(array_merge(
|
||
|
$options,
|
||
|
[
|
||
|
'type' => 'daily_email',
|
||
|
]
|
||
|
));
|
||
|
}
|
||
|
|
||
|
}
|