Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: update constantcontact form meta decorator #7580

Merged
merged 8 commits into from
Nov 20, 2024
8 changes: 4 additions & 4 deletions src/FormMigration/FormMetaDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public function isConstantContactEnabled(): bool
$isFormDisabled = give_is_setting_enabled($this->getMeta('_give_constant_contact_disable'), 'true');

$isGloballyEnabled = give_is_setting_enabled(
give_get_option('give_constant_contact_show_checkout_signup'),
give_get_option('givewp_constant_contact_show_checkout_signup'),
'on'
);

Expand All @@ -532,7 +532,7 @@ public function isConstantContactEnabled(): bool
*/
public function getConstantContactLabel(): string
{
$defaultMeta = give_get_option('give_constant_contact_label', __('Subscribe to our newsletter?'));
$defaultMeta = give_get_option('givewp_constant_contact_label', __('Subscribe to our newsletter?'));

return $this->getMeta('_give_constant_contact_custom_label', $defaultMeta);
}
Expand All @@ -544,7 +544,7 @@ public function getConstantContactDefaultChecked(): bool
{
$defaultMeta = give_is_setting_enabled(
give_get_option(
'give_constant_contact_checked_default',
'givewp_constant_contact_checked_default',
true
),
'on'
Expand All @@ -558,7 +558,7 @@ public function getConstantContactDefaultChecked(): bool
*/
public function getConstantContactSelectedLists(): array
{
$defaultMeta = give_get_option('give_constant_contact_list', []);
$defaultMeta = give_get_option('givewp_constant_contact_list', []);

return (array)$this->getMeta('_give_constant_contact', $defaultMeta);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Feature/FormMigration/Steps/TestConstantContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public function testFormMigratesUsingGlobalSettingsWhenGloballyEnabled(): void
{
// Arrange
$options = [
'give_constant_contact_show_checkout_signup' => 'on',
'give_constant_contact_label' => 'Subscribe to our newsletter?',
'give_constant_contact_checked_default' => 'on',
'give_constant_contact_list' => ['1928414891'],
'givewp_constant_contact_show_checkout_signup' => 'on',
'givewp_constant_contact_label' => 'Subscribe to our newsletter?',
'givewp_constant_contact_checked_default' => 'on',
'givewp_constant_contact_list' => ['1928414891'],
];
foreach ($options as $key => $value) {
give_update_option($key, $value);
Expand All @@ -43,8 +43,8 @@ public function testFormMigratesUsingGlobalSettingsWhenGloballyEnabled(): void
// Assert
$block = $v3Form->blocks->findByName('givewp/constantcontact');
$this->assertTrue(true, $block->getAttribute('checked' === 'on'));
$this->assertSame($options['give_constant_contact_label'], $block->getAttribute('label'));
$this->assertSame($options['give_constant_contact_list'], $block->getAttribute('selectedEmailLists'));
$this->assertSame($options['givewp_constant_contact_label'], $block->getAttribute('label'));
$this->assertSame($options['givewp_constant_contact_list'], $block->getAttribute('selectedEmailLists'));
}

/**
Expand All @@ -53,7 +53,7 @@ public function testFormMigratesUsingGlobalSettingsWhenGloballyEnabled(): void
public function testFormConfiguredToDisableConstantContactIsMigratedWithoutConstantContactBlock()
{
// Arrange
give_update_option('give_constant_contact_show_checkout_signup', 'on');
give_update_option('givewp_constant_contact_show_checkout_signup', 'on');
$meta = ['_give_constant_contact_disable' => 'true'];
$v2Form = $this->createSimpleDonationForm(['meta' => $meta]);

Expand Down
Loading