mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-11 12:28:23 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2637481f2 | |||
| 938456087a |
Generated
+6
-6
@@ -9408,16 +9408,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "friendsofphp/php-cs-fixer",
|
"name": "friendsofphp/php-cs-fixer",
|
||||||
"version": "v3.95.12",
|
"version": "v3.95.13",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
||||||
"reference": "b1b9055997a98dce3c2338e884626e718a25a923"
|
"reference": "ea941114a002eb5e5876f190223deec1066c482c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/b1b9055997a98dce3c2338e884626e718a25a923",
|
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/ea941114a002eb5e5876f190223deec1066c482c",
|
||||||
"reference": "b1b9055997a98dce3c2338e884626e718a25a923",
|
"reference": "ea941114a002eb5e5876f190223deec1066c482c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -9501,7 +9501,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
|
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
|
||||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.95.12"
|
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.95.13"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -9509,7 +9509,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-07-07T13:29:36+00:00"
|
"time": "2026-07-10T09:23:21+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "myclabs/deep-copy",
|
"name": "myclabs/deep-copy",
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ class DataExportService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$lastColumnIndex = 1 + \count($questions);
|
$lastColumnIndex = 1 + \count($questions);
|
||||||
foreach (range('A', Coordinate::stringFromColumnIndex($lastColumnIndex)) as $column) {
|
foreach ($this->columnLetters($lastColumnIndex) as $column) {
|
||||||
$sheet->getColumnDimension($column)->setWidth(30);
|
$sheet->getColumnDimension($column)->setWidth(30);
|
||||||
$sheet->getStyle($column.':'.$column)->getAlignment()->setWrapText(true);
|
$sheet->getStyle($column.':'.$column)->getAlignment()->setWrapText(true);
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ class DataExportService
|
|||||||
++$row;
|
++$row;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (range('A', Coordinate::stringFromColumnIndex(2 + \count($candidates))) as $column) {
|
foreach ($this->columnLetters(2 + \count($candidates)) as $column) {
|
||||||
$sheet->getColumnDimension($column)->setAutoSize(true);
|
$sheet->getColumnDimension($column)->setAutoSize(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ class DataExportService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$lastColumnIndex = $answerStartColumnIndex + max(1, 2 * $maxAnswers);
|
$lastColumnIndex = $answerStartColumnIndex + max(1, 2 * $maxAnswers);
|
||||||
foreach (range('A', Coordinate::stringFromColumnIndex($lastColumnIndex)) as $column) {
|
foreach ($this->columnLetters($lastColumnIndex) as $column) {
|
||||||
$sheet->getColumnDimension($column)->setAutoSize(true);
|
$sheet->getColumnDimension($column)->setAutoSize(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,6 +426,22 @@ class DataExportService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Column letters from 'A' up to and including the given 1-based column index.
|
||||||
|
* Unlike range('A', ...), this works past 'Z' (e.g. index 27 => 'AA').
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function columnLetters(int $lastColumnIndex): array
|
||||||
|
{
|
||||||
|
$letters = [];
|
||||||
|
for ($columnIndex = 1; $columnIndex <= $lastColumnIndex; ++$columnIndex) {
|
||||||
|
$letters[] = Coordinate::stringFromColumnIndex($columnIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $letters;
|
||||||
|
}
|
||||||
|
|
||||||
/** @throws FilesystemException */
|
/** @throws FilesystemException */
|
||||||
private function writeToTempFile(Spreadsheet $spreadsheet): string
|
private function writeToTempFile(Spreadsheet $spreadsheet): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Tvdt\Tests\Service;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Tvdt\Entity\Question;
|
||||||
|
use Tvdt\Entity\Quiz;
|
||||||
|
use Tvdt\Repository\QuizRepository;
|
||||||
|
use Tvdt\Service\DataExportService;
|
||||||
|
use Tvdt\Service\QuizSpreadsheetService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reproduces a Sentry warning (PHP-SYMFONY-3Z): with more than 25 questions, the last raw-answers
|
||||||
|
* column goes past 'Z' (e.g. 'AA'), and range('A', 'AA') is invalid because range()'s second argument
|
||||||
|
* must be a single byte.
|
||||||
|
*/
|
||||||
|
#[CoversClass(DataExportService::class)]
|
||||||
|
final class DataExportServiceRawAnswersColumnsTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testFillRawAnswersSheetHandlesMoreThanTwentyFiveQuestions(): void
|
||||||
|
{
|
||||||
|
$subject = new DataExportService(
|
||||||
|
$this->createStub(EntityManagerInterface::class),
|
||||||
|
$this->createStub(QuizSpreadsheetService::class),
|
||||||
|
$this->createStub(QuizRepository::class),
|
||||||
|
);
|
||||||
|
|
||||||
|
$quiz = new Quiz();
|
||||||
|
for ($i = 0; $i < 26; ++$i) {
|
||||||
|
$question = new Question();
|
||||||
|
$question->question = 'Question '.($i + 1);
|
||||||
|
$quiz->addQuestion($question);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sheet = new Spreadsheet()->getActiveSheet();
|
||||||
|
|
||||||
|
$method = new \ReflectionMethod(DataExportService::class, 'fillRawAnswersSheet');
|
||||||
|
$method->invoke($subject, $sheet, $quiz);
|
||||||
|
|
||||||
|
$this->assertEqualsWithDelta(30.0, $sheet->getColumnDimension('AA')->getWidth(), \PHP_FLOAT_EPSILON);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user