49 lines
1.1 KiB
PHP
49 lines
1.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();
|
|
|
|
$value = $email->get('field_daily_email_cta')->getValue();
|
|
assert(is_array($value));
|
|
assert(isset($value[0]['target_id']));
|
|
|
|
$this->assertSame(
|
|
actual: $value[0]['target_id'],
|
|
expected: $cta->id(),
|
|
);
|
|
}
|
|
|
|
}
|