Skip to content

Commit

Permalink
checkCardsSizes is no longer relevant
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed May 3, 2024
1 parent 0062739 commit 011af46
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 117 deletions.
12 changes: 0 additions & 12 deletions galette/lib/Galette/Controllers/GaletteController.php
Expand Up @@ -258,7 +258,6 @@ public function storePreferences(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$error_detected = [];
$warning_detected = [];

// Validation
if (isset($post['valid']) && $post['valid'] == '1') {
Expand All @@ -271,7 +270,6 @@ public function storePreferences(Request $request, Response $response): Response
_T("Preferences has been saved.")
);
}
$warning_detected = array_merge($warning_detected, $this->preferences->checkCardsSizes());

// picture upload
if (!Galette::isDemo() && isset($_FILES['logo'])) {
Expand Down Expand Up @@ -350,16 +348,6 @@ public function storePreferences(Request $request, Response $response): Response
);
}
}

if (count($warning_detected) > 0) {
//report warnings
foreach ($warning_detected as $warning) {
$this->flash->addMessage(
'warning_detected',
$warning
);
}
}
}
if (isset($post['tab']) && $post['tab'] != 'general') {
$tab = '?tab=' . $post['tab'];
Expand Down
35 changes: 0 additions & 35 deletions galette/lib/Galette/Core/Preferences.php
Expand Up @@ -1179,41 +1179,6 @@ public function getRegistrationDate(): ?string
return null;
}

/**
* Check member cards sizes
* Always a A4/portrait
*
* @return array<string>
*/
public function checkCardsSizes(): array
{
$warning_detected = [];
//check page width
$max = 210;
//margins
$size = $this->pref_card_marges_h * 2;
//cards
$size += PdfMembersCards::getWidth() * PdfMembersCards::getCols();
//spacing
$size += $this->pref_card_hspace * (PdfMembersCards::getCols() - 1);
if ($size > $max) {
$warning_detected[] = _T('Current cards configuration may exceed page width!');
}

$max = 297;
//margins
$size = $this->pref_card_marges_v * 2;
//cards
$size += PdfMembersCards::getHeight() * PdfMembersCards::getRows();
//spacing
$size += $this->pref_card_vspace * (PdfMembersCards::getRows() - 1);
if ($size > $max) {
$warning_detected[] = _T('Current cards configuration may exceed page height!');
}

return $warning_detected;
}

/**
* Get errors
*
Expand Down
70 changes: 0 additions & 70 deletions tests/Galette/Core/tests/units/Preferences.php
Expand Up @@ -287,76 +287,6 @@ public function testPublicPagesVisibility(): void
$this->assertFalse($visible);
}

/**
* Data provider for cards sizes tests
*
* @return array
*/
public static function sizesProvider(): array
{
return [
[//defaults
15, //vertical margin
20, //horizontal margin
5, //vertical spacing
10, //horizontal spacing
0 //expected number of warnings
], [ //OK
0, //vertical margin
20, //horizontal margin
11, //vertical spacing
10, //horizontal spacing
0 //expected number of warnings
], [ //vertical overflow
0, //vertical margin
20, //horizontal margin
12, //vertical spacing
10, //horizontal spacing
1 //expected number of warnings
], [//horizontal overflow
15, //vertical margin
20, //horizontal margin
5, //vertical spacing
61, //horizontal spacing
1 //expected number of warnings
], [//vertical and horizontal overflow
0, //vertical margin
20, //horizontal margin
12, //vertical spacing
61, //horizontal spacing
2 //expected number of warnings
], [//vertical overflow
17, //vertical margin
20, //horizontal margin
5, //vertical spacing
10, //horizontal spacing
1 //expected number of warnings
]
];
}

/**
* Test checkCardsSizes
*
* @dataProvider sizesProvider
*
* @param integer $vm Vertical margin
* @param integer $hm Horizontal margin
* @param integer $vs Vertical spacing
* @param integer $hs Horizontal spacing
* @param integer $count Number of expected errors
*
* @return void
*/
public function testCheckCardsSizes(int $vm, int $hm, int $vs, int $hs, int $count): void
{
$this->preferences->pref_card_marges_v = $vm;
$this->preferences->pref_card_marges_h = $hm;
$this->preferences->pref_card_vspace = $vs;
$this->preferences->pref_card_hspace = $hs;
$this->assertCount($count, $this->preferences->checkCardsSizes());
}

/**
* Data provider for colors
*
Expand Down

0 comments on commit 011af46

Please sign in to comment.