Add a test to confirm the token substitutes
...correctly
This commit is contained in:
parent
58740872fa
commit
ceb74f618b
2 changed files with 46 additions and 1 deletions
|
@ -0,0 +1,45 @@
|
||||||
|
<?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',
|
||||||
|
]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
<php>
|
<php>
|
||||||
<ini name="error_reporting" value="32767"/>
|
<ini name="error_reporting" value="32767"/>
|
||||||
<ini name="memory_limit" value="-1"/>
|
<ini name="memory_limit" value="-1"/>
|
||||||
<env name="SIMPLETEST_BASE_URL" value=""/>
|
<env name="SIMPLETEST_BASE_URL" value="http://localhost:8888"/>
|
||||||
<env name="SIMPLETEST_DB" value="sqlite://localhost//dev/shm/testing.sqlite"/>
|
<env name="SIMPLETEST_DB" value="sqlite://localhost//dev/shm/testing.sqlite"/>
|
||||||
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
|
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
|
||||||
<env name="MINK_DRIVER_CLASS" value=""/>
|
<env name="MINK_DRIVER_CLASS" value=""/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue