PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Donations / Factories / DonationFactory.php

DonationFactory.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Donations/Factories/DonationFactory.php

47 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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