Skip to content

Commit

Permalink
afup#1437 fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Oct 28, 2024
1 parent 41eb937 commit 7d42cd1
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 24 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ jobs:
unit:
name: "Unit tests"
runs-on: ubuntu-22.04

continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
fail-fast: true
matrix:
php:
- "7.4"
# - "8.2"
php: [ "7.4" ]
experimental: [ false ]
include:
- php: "8.2"
experimental: true

steps:
- uses: actions/checkout@v4
Expand Down
13 changes: 5 additions & 8 deletions sources/Afup/Association/Cotisations.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,13 @@ function estDejaReglee($cmd)

function notifierRegelementEnLigneAuTresorier($cmd, $total, $autorisation, $transaction, UserRepository $userRepository)
{
/**
* @var Configuration $configuration
*/
$configuration = $GLOBALS['AFUP_CONF'];

$account = $this->getAccountFromCmd($cmd);

if (AFUP_PERSONNES_MORALES == $account['type']) {
$invoiceNumber = substr($cmd, 1);
$cotisation = $this->getByInvoice($invoiceNumber);
$personnes = new Personnes_Morales($this->_bdd);
$infos = $personnes->obtenir($account['id'], 'nom, prenom, email');
$infos = $personnes->obtenir($cotisation['id_personne'], 'nom, prenom, email');
} else {
$user = $userRepository->get($account['id']);
Assertion::notNull($user);
Expand Down Expand Up @@ -281,7 +278,7 @@ function validerReglementEnLigne($cmd, $total, $autorisation, $transaction)
$date_debut = mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4));

$cotisation = $this->obtenirDerniere($type_personne, $id_personne);
$date_fin_precedente = $cotisation['date_fin'];
$date_fin_precedente = $cotisation === false ? 0 : $cotisation['date_fin'];

if ($date_fin_precedente > 0) {
$date_debut = strtotime('+1day', $date_fin_precedente);
Expand Down Expand Up @@ -569,7 +566,7 @@ public function envoyerFacture($id_cotisation, Mailer $mailer, UserRepository $u
*
* @param int $id_personne Identifiant de la personne
* @access public
* @return array
* @return array|false
*/
function obtenirDerniere($type_personne, $id_personne)
{
Expand Down
2 changes: 1 addition & 1 deletion sources/Afup/Association/Personnes_Morales.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function obtenirMembresMaximum($id, $default = 3)
* @param int $id Identifiant de la personne
* @param string $champs Champs à renvoyer
* @access public
* @return array
* @return array|false
*/
function obtenir($id, $champs = '*')
{
Expand Down
9 changes: 7 additions & 2 deletions sources/AppBundle/Association/Model/CompanyMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,15 +557,20 @@ public function getTwitterHandle()
}

/**
* Duplicate of AppBundle\Event\Model\Speaker::getCleanedTwitterHandle()
* @return bool|string
*/
public function getCleanedTwitterHandle()
{
$twitter = $this->getTwitterHandle();
if (!$twitter) {
return null;
}

$twitter = trim($twitter, '@');
$twitter = preg_replace('!^https?://twitter.com/!', '', $twitter);

if (0 === strlen(trim($twitter))) {
if (!$twitter) {
return null;
}

Expand Down Expand Up @@ -660,7 +665,7 @@ public function getLastSubscription()
public function setLastSubscription($sub)
{
if ($sub !== null) {
$this->lastSubscription = \DateTimeImmutable::createFromFormat('U', $sub);
$this->lastSubscription = \DateTimeImmutable::createFromFormat('U', (string) $sub);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sources/AppBundle/Association/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ public function getLastSubscription()
public function setLastSubscription($sub)
{
if ($sub !== null) {
$this->lastSubscription = \DateTimeImmutable::createFromFormat('U', (string)$sub);
$this->lastSubscription = \DateTimeImmutable::createFromFormat('U', (string) $sub);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __invoke(Request $request): Response
private static function humanFilesize($bytes): string
{
$sz = 'BKMGTP';
$factor = floor((strlen($bytes) - 1) / 3);
$factor = floor((strlen((string) $bytes) - 1) / 3);

return sprintf("%.2f", $bytes / (1024 ** $factor)) . $sz[(int) $factor];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __invoke(Request $request)
private function testFeeds(array $feeds)
{
// on n'affiche rien du tout
ini_set('display_errors', 0);
ini_set('display_errors', '0');
set_time_limit(240);
$results = [];
foreach ($feeds as $f) {
Expand Down
8 changes: 4 additions & 4 deletions sources/AppBundle/Controller/MemberShipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ public function membershipFeeAction()
$message = sprintf(
'Votre dernière cotisation -- %s %s -- est valable jusqu\'au %s. <br />
Si vous renouvelez votre cotisation maintenant, celle-ci sera valable jusqu\'au %s.',
number_format($cotisation['montant'], 2, ',', ' '),
number_format((float) $cotisation['montant'], 2, ',', ' '),
EURO,
date("d/m/Y", $cotisation['date_fin']),
date("d/m/Y", (int) $cotisation['date_fin']),
$endSubscription->format('d/m/Y')
);
}
Expand Down Expand Up @@ -508,7 +508,7 @@ public function membershipFeeDownloadAction(Request $request)
$patternPrefix = $user->getLastName();
}

$pattern = str_replace(' ', '', $patternPrefix) . '_' . $numeroFacture . '_' . date('dmY', $cotisation['date_debut']) . '.pdf';
$pattern = str_replace(' ', '', $patternPrefix) . '_' . $numeroFacture . '_' . date('dmY', (int) $cotisation['date_debut']) . '.pdf';

$response = new BinaryFileResponse($tempfile, 200, [], false);
$response->deleteFileAfterSend(true);
Expand Down Expand Up @@ -554,7 +554,7 @@ public function generalMeetingAction(Request $request)
$generalMeetingPlanned = $generalMeetingRepository->hasGeneralMeetingPlanned();

$cotisation = $userService->getLastSubscription($user);
$needsMembersheepFeePayment = $latestDate->getTimestamp() > strtotime("+14 day", $cotisation['date_fin']);
$needsMembersheepFeePayment = $latestDate->getTimestamp() > strtotime("+14 day", (int) $cotisation['date_fin']);

if ($needsMembersheepFeePayment) {
return $this->render('admin/association/membership/generalmeeting_membersheepfee.html.twig', [
Expand Down
2 changes: 1 addition & 1 deletion sources/AppBundle/TechLetter/Model/TechLetterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TechLetterFactory
{
public static function createTechLetterFromJson($json)
{
$array = json_decode($json, true);
$array = json_decode((string) $json, true);

$articles = $projects = [];
if (isset($array['projects'])) {
Expand Down

0 comments on commit 7d42cd1

Please sign in to comment.