-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add receipt api for fields (#7149)
Co-authored-by: Jon Waldstein <[email protected]>
- Loading branch information
1 parent
aa733cc
commit 050a76c
Showing
4 changed files
with
223 additions
and
10 deletions.
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
56 changes: 56 additions & 0 deletions
56
tests/Unit/Framework/FieldsAPI/Concerns/ShowInReceiptTest.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,56 @@ | ||
<?php | ||
|
||
namespace Unit\Framework\FieldsAPI\Concerns; | ||
|
||
use Give\Framework\FieldsAPI\Concerns\ShowInReceipt; | ||
use Give\Tests\TestCase; | ||
|
||
|
||
/** | ||
* @covers ShowInReceipt | ||
*/ | ||
class ShowInReceiptTest extends TestCase | ||
{ | ||
/** | ||
* @unreleased | ||
*/ | ||
public function testSettingTheReceiptLabel(): void | ||
{ | ||
/** @var ShowInReceipt $mock */ | ||
$mock = $this->getMockForTrait(ShowInReceipt::class); | ||
|
||
$mock->receiptLabel('test'); | ||
$this->assertTrue($mock->hasReceiptLabel()); | ||
$this->assertSame('test', $mock->getReceiptLabel()); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function testSettingTheReceiptValue(): void | ||
{ | ||
/** @var ShowInReceipt $mock */ | ||
$mock = $this->getMockForTrait(ShowInReceipt::class); | ||
|
||
$value = function ($field, $donation) { | ||
return 'test'; | ||
}; | ||
|
||
$mock->receiptValue($value); | ||
$this->assertTrue($mock->hasReceiptValue()); | ||
self::assertIsCallable($mock->getReceiptValue()); | ||
$this->assertSame($value, $mock->getReceiptValue()); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function testShouldShowInReceipt(): void | ||
{ | ||
/** @var ShowInReceipt $mock */ | ||
$mock = $this->getMockForTrait(ShowInReceipt::class); | ||
|
||
$mock->showInReceipt(); | ||
$this->assertTrue($mock->shouldShowInReceipt()); | ||
} | ||
} |
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