|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use Phinx\Seed\AbstractSeed; |
| 6 | + |
| 7 | +class SponsorTickets extends AbstractSeed |
| 8 | +{ |
| 9 | + public const string TOKEN_GREEN = 'token-sponsor-tickets-vert-test'; |
| 10 | + public const string TOKEN_ORANGE = 'token-sponsor-tickets-orange-test'; |
| 11 | + public const string TOKEN_RED = 'token-sponsor-tickets-rouge-test'; |
| 12 | + |
| 13 | + public function run(): void |
| 14 | + { |
| 15 | + $now = new DateTime('now'); |
| 16 | + |
| 17 | + // Seed idempotent : suppression de la donnee de test si elle existe deja |
| 18 | + $this->execute(sprintf( |
| 19 | + "DELETE FROM afup_forum_sponsors_tickets WHERE token IN ('%s', '%s', '%s')", |
| 20 | + self::TOKEN_GREEN, |
| 21 | + self::TOKEN_ORANGE, |
| 22 | + self::TOKEN_RED, |
| 23 | + )); |
| 24 | + |
| 25 | + $data = [ |
| 26 | + [ |
| 27 | + 'id' => 101, |
| 28 | + 'company' => 'Sponsor Zéro Utilisé', |
| 29 | + 'token' => self::TOKEN_GREEN, |
| 30 | + 'contact_email' => 'vert@sponsor-test.com', |
| 31 | + 'max_invitations' => 4, |
| 32 | + 'used_invitations' => 0, |
| 33 | + 'id_forum' => Event::ID_FORUM, |
| 34 | + 'created_on' => $now->format('Y-m-d H:i:s'), |
| 35 | + 'edited_on' => $now->format('Y-m-d H:i:s'), |
| 36 | + 'creator_id' => Users::ID_USER_ADMIN, |
| 37 | + 'qr_codes_scanner_available' => 0, |
| 38 | + ], |
| 39 | + [ |
| 40 | + 'id' => 102, |
| 41 | + 'company' => 'Sponsor Deux Tiers Utilisé', |
| 42 | + 'token' => self::TOKEN_ORANGE, |
| 43 | + 'contact_email' => 'deuxtiers@sponsor-test.com', |
| 44 | + 'max_invitations' => 3, |
| 45 | + 'used_invitations' => 2, |
| 46 | + 'id_forum' => Event::ID_FORUM, |
| 47 | + 'created_on' => $now->format('Y-m-d H:i:s'), |
| 48 | + 'edited_on' => $now->format('Y-m-d H:i:s'), |
| 49 | + 'creator_id' => Users::ID_USER_ADMIN, |
| 50 | + 'qr_codes_scanner_available' => 0, |
| 51 | + ], |
| 52 | + [ |
| 53 | + 'id' => 103, |
| 54 | + 'company' => 'Sponsor Complet', |
| 55 | + 'token' => self::TOKEN_RED, |
| 56 | + 'contact_email' => 'complet@sponsor-test.com', |
| 57 | + 'max_invitations' => 1, |
| 58 | + 'used_invitations' => 1, |
| 59 | + 'id_forum' => Event::ID_FORUM, |
| 60 | + 'created_on' => $now->format('Y-m-d H:i:s'), |
| 61 | + 'edited_on' => $now->format('Y-m-d H:i:s'), |
| 62 | + 'creator_id' => Users::ID_USER_ADMIN, |
| 63 | + 'qr_codes_scanner_available' => 0, |
| 64 | + ], |
| 65 | + ]; |
| 66 | + |
| 67 | + $this->table('afup_forum_sponsors_tickets')->insert($data)->saveData(); |
| 68 | + } |
| 69 | +} |
0 commit comments