Skip to content

Commit 144f13a

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2 parents a602266 + c0897b7 commit 144f13a

6 files changed

Lines changed: 27 additions & 34 deletions

File tree

psalm-baseline.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9593,9 +9593,11 @@
95939593
<code><![CDATA[$context]]></code>
95949594
<code><![CDATA[$context]]></code>
95959595
<code><![CDATA[$filesFound]]></code>
9596-
<code><![CDATA[$filesFound]]></code>
95979596
<code><![CDATA[$filesInfos]]></code>
95989597
</MixedAssignment>
9598+
<PossiblyUndefinedArrayOffset>
9599+
<code><![CDATA[$filesFound[0]['exception']]]></code>
9600+
</PossiblyUndefinedArrayOffset>
95999601
</file>
96009602
<file src="tests/unit/Config/ConfigFileTest.php">
96019603
<MixedArrayAccess>

resources/js/src/table/gis_visualization.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,14 @@ class OlVisualization extends GisVisualization {
432432
return undefined;
433433
}
434434

435-
$('head').append('<link rel="stylesheet" type="text/css" href="js/vendor/openlayers/theme/ol.css">');
435+
const olCss = 'js/vendor/openlayers/theme/ol.css';
436+
if (! document.querySelector('link[rel="stylesheet"][href="' + olCss + '"]')) {
437+
const link = document.createElement('link');
438+
link.rel = 'stylesheet';
439+
link.type = 'text/css';
440+
link.href = olCss;
441+
document.head.appendChild(link);
442+
}
436443

437444
const vectorSource = new window.ol.source.Vector({
438445
features: getFeaturesFromOpenLayersData(this.data),

src/Command/TwigLintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static function (int $level, string $message, string $file, int $line) use (&$pr
139139
}
140140

141141
/** @return array{template: string, file: string, exception?:Error}[] */
142-
protected function getFilesInfo(string $templatesPath): array
142+
public function getFilesInfo(string $templatesPath): array
143143
{
144144
$filesInfo = [];
145145
$filesFound = $this->findFiles($templatesPath);

tests/unit/Command/TwigLintCommandTest.php

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use PHPUnit\Framework\Attributes\CoversClass;
1111
use Symfony\Component\Console\Command\Command;
1212
use Twig\Error\SyntaxError;
13-
use Twig\Source;
1413

1514
use function class_exists;
1615
use function sort;
@@ -86,36 +85,19 @@ public function testGetFilesInfo(): void
8685

8786
public function testGetFilesInfoInvalidFile(): void
8887
{
89-
$command = $this->getMockBuilder(TwigLintCommand::class)
90-
->onlyMethods(['getTemplateContents', 'findFiles'])
91-
->getMock();
92-
93-
$command->expects(self::exactly(1))
94-
->method('findFiles')
95-
->willReturn(
96-
['foo.twig', 'foo-invalid.twig'],
97-
);
98-
99-
$command->expects(self::exactly(2))->method('getTemplateContents')->willReturnMap([
100-
['foo.twig', '{{ file }}'],
101-
['foo-invalid.twig', '{{ file }'],
102-
]);
103-
104-
$filesFound = $this->callFunction($command, TwigLintCommand::class, 'getFilesInfo', [
105-
__DIR__ . '/../_data/file_listing',
106-
]);
107-
108-
self::assertEquals([
109-
['template' => '{{ file }}', 'file' => 'foo.twig'],
110-
[
111-
'template' => '{{ file }',
112-
'file' => 'foo-invalid.twig',
113-
'exception' => new SyntaxError('Unexpected "}".', 1, new Source(
114-
'{{ file }',
115-
'foo-invalid.twig',
116-
)),
117-
],
118-
], $filesFound);
88+
$twigLintCommand = new TwigLintCommand();
89+
$path = __DIR__ . '/../_data/templates/lint_command';
90+
$filesFound = $twigLintCommand->getFilesInfo($path);
91+
92+
self::assertCount(2, $filesFound);
93+
self::assertSame('{{ file }' . "\n", $filesFound[0]['template']);
94+
self::assertSame($path . '/foo-invalid.twig', $filesFound[0]['file']);
95+
self::assertArrayHasKey('exception', $filesFound[0]);
96+
$exception = $filesFound[0]['exception'];
97+
self::assertInstanceOf(SyntaxError::class, $exception);
98+
self::assertSame('Unexpected "}" in "' . $path . '/foo-invalid.twig" at line 1.', $exception->getMessage());
99+
self::assertSame('{{ file }}' . "\n", $filesFound[1]['template']);
100+
self::assertSame($path . '/foo-valid.twig', $filesFound[1]['file']);
119101
}
120102

121103
public function testGetContext(): void
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ file }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ file }}

0 commit comments

Comments
 (0)