| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Donations\Factories; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
use Give\Campaigns\Models\Campaign; |
| 7 |
use Give\Donations\ValueObjects\DonationMode; |
| 8 |
use Give\Donations\ValueObjects\DonationStatus; |
| 9 |
use Give\Donations\ValueObjects\DonationType; |
| 10 |
use Give\Donors\Models\Donor; |
| 11 |
use Give\Framework\Models\Factories\ModelFactory; |
| 12 |
use Give\Framework\Support\ValueObjects\Money; |
| 13 |
use Give\PaymentGateways\Gateways\TestGateway\TestGateway; |
| 14 |
|
| 15 |
class DonationFactory extends ModelFactory |
| 16 |
{ |
| 17 |
|
| 18 |
/** |
| 19 |
* @since 4.0.0 added campaignId |
| 20 |
* @since 2.22.0 add optional support for anonymous and company properties |
| 21 |
* @since 2.20.0 update default donorId to create factory |
| 22 |
* @since 2.19.6 |
| 23 |
* |
| 24 |
* @throws Exception |
| 25 |
*/ |
| 26 |
public function definition(): array |
| 27 |
{ |
| 28 |
return [ |
| 29 |
'status' => DonationStatus::PENDING(), |
| 30 |
'gatewayId' => TestGateway::id(), |
| 31 |
'mode' => DonationMode::TEST(), |
| 32 |
'type' => DonationType::SINGLE(), |
| 33 |
'amount' => new Money($this->faker->numberBetween(50, 50000), 'USD'), |
| 34 |
'donorId' => Donor::factory()->create()->id, |
| 35 |
'firstName' => $this->faker->firstName, |
| 36 |
'lastName' => $this->faker->lastName, |
| 37 |
'email' => $this->faker->email, |
| 38 |
'campaignId' => 1, |
| 39 |
'formId' => 1, |
| 40 |
'formTitle' => 'Form Title', |
| 41 |
'anonymous' => $this->faker->optional(0.5, false)->boolean(true), |
| 42 |
'company' => $this->faker->optional()->company, |
| 43 |
'comment' => $this->faker->optional()->text, |
| 44 |
]; |
| 45 |
} |
| 46 |
} |
| 47 |
|