-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into release/3.8.0
- Loading branch information
Showing
6 changed files
with
151 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Give\FormMigration\Steps; | ||
|
||
use Give\FormMigration\Contracts\FormMigrationStep; | ||
use Give\Framework\Blocks\BlockModel; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class DoubleTheDonation extends FormMigrationStep | ||
{ | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function canHandle(): bool | ||
{ | ||
return $this->formV2->getDoubleTheDonationStatus() === 'enabled'; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function process() | ||
{ | ||
$block = BlockModel::make([ | ||
'name' => 'givewp/dtd', | ||
'attributes' => [ | ||
'label' => $this->formV2->getDoubleTheDonationLabel(), | ||
'company' => [ | ||
'company_id' => '', | ||
'company_name' => '', | ||
'entered_text' => '', | ||
], | ||
], | ||
]); | ||
|
||
$this->fieldBlocks->insertAfter('givewp/donation-amount', $block); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/Feature/FormMigration/Steps/TestDoubleTheDonation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Give\Tests\Feature\FormMigration\Steps; | ||
|
||
use Give\FormMigration\DataTransferObjects\FormMigrationPayload; | ||
use Give\FormMigration\Steps\DoubleTheDonation; | ||
use Give\Tests\TestCase; | ||
use Give\Tests\TestTraits\RefreshDatabase; | ||
use Give\Tests\Unit\DonationForms\TestTraits\LegacyDonationFormAdapter; | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @covers \Give\FormMigration\Steps\DoubleTheDonation | ||
*/ | ||
class TestDoubleTheDonation extends TestCase | ||
{ | ||
use RefreshDatabase, LegacyDonationFormAdapter; | ||
|
||
public function testProcessShouldUpdateDoubleTheDonationBlockAttributes(): void | ||
{ | ||
$meta = [ | ||
'give_dtd_label' => 'DTD Label', | ||
]; | ||
|
||
$company = [ | ||
'company_id' => '', | ||
'company_name' => '', | ||
'entered_text' => '', | ||
]; | ||
|
||
$formV2 = $this->createSimpleDonationForm(['meta' => $meta]); | ||
$payload = FormMigrationPayload::fromFormV2($formV2); | ||
|
||
$dtd = new DoubleTheDonation($payload); | ||
$dtd->process(); | ||
|
||
$block = $payload->formV3->blocks->findByName('givewp/dtd'); | ||
|
||
$this->assertSame($meta['give_dtd_label'], $block->getAttribute('label')); | ||
$this->assertEqualsIgnoringCase($company, $block->getAttribute('company')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters