Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions db/seeds/SponsorTickets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

declare(strict_types=1);

use Phinx\Seed\AbstractSeed;

class SponsorTickets extends AbstractSeed
{
public const string TOKEN_GREEN = 'token-sponsor-tickets-vert-test';
public const string TOKEN_ORANGE = 'token-sponsor-tickets-orange-test';
public const string TOKEN_RED = 'token-sponsor-tickets-rouge-test';

public function run(): void
{
$now = new DateTime('now');

// Seed idempotent : suppression de la donnee de test si elle existe deja
$this->execute(sprintf(
"DELETE FROM afup_forum_sponsors_tickets WHERE token IN ('%s', '%s', '%s')",
self::TOKEN_GREEN,
self::TOKEN_ORANGE,
self::TOKEN_RED,
));

$data = [
[
'id' => 101,
'company' => 'Sponsor Zéro Utilisé',
'token' => self::TOKEN_GREEN,
'contact_email' => 'vert@sponsor-test.com',
'max_invitations' => 4,
'used_invitations' => 0,
'id_forum' => Event::ID_FORUM,
'created_on' => $now->format('Y-m-d H:i:s'),
'edited_on' => $now->format('Y-m-d H:i:s'),
'creator_id' => Users::ID_USER_ADMIN,
'qr_codes_scanner_available' => 0,
],
[
'id' => 102,
'company' => 'Sponsor Deux Tiers Utilisé',
'token' => self::TOKEN_ORANGE,
'contact_email' => 'deuxtiers@sponsor-test.com',
'max_invitations' => 3,
'used_invitations' => 2,
'id_forum' => Event::ID_FORUM,
'created_on' => $now->format('Y-m-d H:i:s'),
'edited_on' => $now->format('Y-m-d H:i:s'),
'creator_id' => Users::ID_USER_ADMIN,
'qr_codes_scanner_available' => 0,
],
[
'id' => 103,
'company' => 'Sponsor Complet',
'token' => self::TOKEN_RED,
'contact_email' => 'complet@sponsor-test.com',
'max_invitations' => 1,
'used_invitations' => 1,
'id_forum' => Event::ID_FORUM,
'created_on' => $now->format('Y-m-d H:i:s'),
'edited_on' => $now->format('Y-m-d H:i:s'),
'creator_id' => Users::ID_USER_ADMIN,
'qr_codes_scanner_available' => 0,
],
];

$this->table('afup_forum_sponsors_tickets')->insert($data)->saveData();
}
}
32 changes: 32 additions & 0 deletions templates/admin/event/sponsor_ticket.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<th>Token</th>
<th class="right aligned">Invitations totales</th>
<th class="right aligned">Invitations utilisées</th>
<th class="right aligned">Tokens restants</th>
<th class="right aligned">Peut scanner QR Codes</th>
<th colspan="3"></th>
</tr>
Expand All @@ -62,6 +63,22 @@
<td>{{ token.token }}</td>
<td class="right aligned">{{ token.maxInvitations }}</td>
<td class="right aligned">{{ token.usedInvitations }}</td>
<td class="right aligned">
{% set pending = token.pendingInvitations %}
{% if token.maxInvitations > 0 %}
{% set remainingRate = pending / token.maxInvitations %}
{% else %}
{% set remainingRate = 0 %}
{% endif %}
{% if remainingRate > 0.5 %}
{% set color = 'red' %}
{% elseif remainingRate == 0 %}
{% set color = 'green' %}
{% else %}
{% set color = 'orange' %}
{% endif %}
<span class="ui {{ color }} label">{{ (remainingRate * 100)|round }}%</span>
</td>
<td class="right aligned">{% if token.qrCodesScannerAvailable %}OUI{% else %}-{% endif %}</td>
<td class="right aligned">
<form class="sponsor--token-admin-view" method="post" action="{{ url('sponsor_ticket_home', {eventSlug: event.path}) }}">
Expand Down Expand Up @@ -112,6 +129,21 @@
<th colspan="2"><strong>Total</strong></th>
<th class="right aligned">{{ totalInvitations }}</th>
<th class="right aligned">{{ totalUsedInvitations }}</th>
<th class="right aligned">
{% if totalInvitations > 0 %}
{% set remainingRate = (totalInvitations - totalUsedInvitations) / totalInvitations %}
{% else %}
{% set remainingRate = 0 %}
{% endif %}
{% if remainingRate > 0.5 %}
{% set color = 'red' %}
{% elseif remainingRate == 0 %}
{% set color = 'green' %}
{% else %}
{% set color = 'orange' %}
{% endif %}
<span class="ui {{ color }} label">{{ (remainingRate * 100)|round }}%</span>
</th>
<th colspan="4"></th>
</tr>
</tfoot>
Expand Down
18 changes: 18 additions & 0 deletions tests/behat/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ public function pressButtonOfTooltip(string $tooltip): void
$button->press();
}

#[When('/^I press "(?P<button>(?:[^"]|\\")*)" in the row of "(?P<row>(?:[^"]|\\")*)"$/')]
public function pressButtonInRow(string $button, string $row): void
{
$input = $this->minkContext->getSession()->getPage()->find(
'xpath',
sprintf('//tr[contains(., "%s")]//input[@value="%s"]', $row, $button),
);

if (null === $input) {
throw new ExpectationException(
sprintf('Button "%s" in row "%s" not found', $button, $row),
$this->minkContext->getSession()->getDriver(),
);
}

$input->press();
}

#[Then('/^the rows of table "(?P<selector>[^"]+)" should be in the following order:$/')]
public function assertTableRowsInOrder(string $selector, PyStringNode $expectedRows): void
{
Expand Down
11 changes: 9 additions & 2 deletions tests/behat/features/Admin/Events/TokensSponsors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ Feature: Administration - Évènements - Tokens Sponsors
# Listing des tokens
Then I should see "Invitations totales"
And I should see tooltip "Supprimer"
When I press "Voir les invitations"
# Les 3 cas de taux d'utilisation des tokens (100% restant, 33% restant, 0% restant)
And I should see a red label "100%"
And I should see a orange label "33%"
And I should see a green label "0%"
When I press "Voir les invitations" in the row of "Ma société"
# Listing des invitations vides
Then I should see "Billetterie sponsor: forum - Ma société"
And I should see "VOS PLACES GRATUITES"
Expand All @@ -46,13 +50,16 @@ Feature: Administration - Évènements - Tokens Sponsors
Then I should see "Places disponibles: 1 / 2 "
# Envoi de l'email de rappel
When I am on "/admin/event/sponsor"
Then I should see a orange label "50%"
Then I follow "Envoyer le mail de rappel"
And I should see "1 mails de relance ont été envoyés"
And I should see "3 mails de relance ont été envoyés"
And I should only receive the following emails:
| to | subject |
| <testToken1@mail.com> | Toutes les informations concernant votre sponsoring du forum |
| <personneinvitee@masociete.com> | [forum] Merci ! |
| <personneinvitee@masociete.com> | [forum] Merci ! |
| <vert@sponsor-test.com> | Sponsor: enregistrez-vous pour le forum |
| <deuxtiers@sponsor-test.com> | Sponsor: enregistrez-vous pour le forum |
| <testToken1@mail.com> | Sponsor: enregistrez-vous pour le forum |

@reloadDbWithTestData
Expand Down
Loading