feat: upgrade to symfony 7.4
This commit is contained in:
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Migrations;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Version20260820000000 rewrites the wording of mails that go out to every teamer, and it
|
||||
* runs exactly once with nobody watching, so the patterns it does that with are pinned
|
||||
* here. The migration is not autoloaded (only src/ and tests/ are), hence the require.
|
||||
*/
|
||||
class EmphasisRewriteTest extends TestCase
|
||||
{
|
||||
private string $single;
|
||||
private string $double;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
require_once __DIR__.'/../../migrations/Version20260820000000.php';
|
||||
|
||||
$reflection = new \ReflectionClass(\DoctrineMigrations\Version20260820000000::class);
|
||||
|
||||
$this->single = $reflection->getConstant('SINGLE_EMPHASIS');
|
||||
$this->double = $reflection->getConstant('DOUBLE_EMPHASIS');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider upCases
|
||||
*/
|
||||
public function testTheUpwardRewrite(string $before, string $after): void
|
||||
{
|
||||
$this->assertSame($after, preg_replace($this->single, '**$1**', $before));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable<string, array{string, string}>
|
||||
*/
|
||||
public static function upCases(): iterable
|
||||
{
|
||||
yield 'one word' => ['Das ist *wichtig*', 'Das ist **wichtig**'];
|
||||
yield 'several words' => ['*Dein Einsatz wurde angenommen!*', '**Dein Einsatz wurde angenommen!**'];
|
||||
yield 'around a placeholder' => ['*{destination}*', '**{destination}**'];
|
||||
yield 'already bold' => ['Das ist **wichtig**', 'Das ist **wichtig**'];
|
||||
yield 'escaped asterisk' => ['Ein Sternchen: \*', 'Ein Sternchen: \*'];
|
||||
// Whitespace next to a marker means it is not emphasis - CommonMark's own rule, and
|
||||
// the reason arithmetic and stray asterisks come through untouched.
|
||||
yield 'multiplication' => ['5 * 3 = 15', '5 * 3 = 15'];
|
||||
yield 'spaced asterisks' => ['a * b * c', 'a * b * c'];
|
||||
yield 'bullet at line start' => ["* Ausweis\n* Bankverbindung", "* Ausweis\n* Bankverbindung"];
|
||||
yield 'not across lines' => ["*offen\ngeblieben*", "*offen\ngeblieben*"];
|
||||
}
|
||||
|
||||
public function testTheRewriteIsReversible(): void
|
||||
{
|
||||
$before = 'Das ist *wichtig* und *{destination}* auch';
|
||||
|
||||
$up = preg_replace($this->single, '**$1**', $before);
|
||||
|
||||
$this->assertSame($before, preg_replace($this->double, '*$1*', $up));
|
||||
}
|
||||
|
||||
/**
|
||||
* The delivered defaults were rewritten by hand in the same commit, so nothing should
|
||||
* be left in them for the migration to find. Read through the parser rather than off
|
||||
* the raw file: the header comment documents *kursiv* on purpose.
|
||||
*/
|
||||
public function testTheDeliveredDefaultsAreAlreadyMigrated(): void
|
||||
{
|
||||
$texts = Yaml::parseFile(__DIR__.'/../../config/email_texts.yaml')['texts'];
|
||||
|
||||
foreach ($texts as $key => $text) {
|
||||
$body = (string) ($text['body'] ?? '');
|
||||
|
||||
$this->assertSame(
|
||||
$body,
|
||||
preg_replace($this->single, '**$1**', $body),
|
||||
sprintf('Default wording of "%s" still carries single-asterisk emphasis', $key)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,7 @@ class TeamerMailingDraftHandlerTest extends TestCase
|
||||
$request = new Request();
|
||||
$request->setSession(new Session(new MockArraySessionStorage()));
|
||||
|
||||
$requestStack = new RequestStack();
|
||||
$requestStack->push($request);
|
||||
$requestStack = new RequestStack([$request]);
|
||||
|
||||
$this->handler = new TeamerMailingDraftHandler($requestStack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user