46 lines
1 KiB
PHP
46 lines
1 KiB
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace Drupal\Tests\opd_daily_emails\Functional;
|
||
|
|
||
|
use weitzman\DrupalTestTraits\ExistingSiteBase;
|
||
|
|
||
|
final class CallToActionTest extends ExistingSiteBase {
|
||
|
|
||
|
public function test_saving_an_email_node_without_a_cta_will_populate_one(): void {
|
||
|
$cta = $this->createNode([
|
||
|
'type' => 'daily_email_cta',
|
||
|
]);
|
||
|
|
||
|
$email = $this->createNode([
|
||
|
'field_daily_email_cta' => NULL,
|
||
|
'type' => 'daily_email',
|
||
|
]);
|
||
|
|
||
|
$this->assertNotEmpty($email->get('field_daily_email_cta')->getValue());
|
||
|
|
||
|
// TODO: assert the returned text.
|
||
|
}
|
||
|
|
||
|
public function test_saving_an_email_node_with_a_cta_will_keep_the_same_cta(): void {
|
||
|
$cta = $this->createNode([
|
||
|
'type' => 'daily_email_cta',
|
||
|
]);
|
||
|
|
||
|
$email = $this->createNode([
|
||
|
'field_daily_email_cta' => $cta,
|
||
|
'type' => 'daily_email',
|
||
|
]);
|
||
|
|
||
|
$email->set('title', 'Updated');
|
||
|
$email->save();
|
||
|
|
||
|
$this->assertSame(
|
||
|
actual: $email->get('field_daily_email_cta')->getValue()[0]['target_id'],
|
||
|
expected: $cta->id(),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|