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