Skip to content

Commit

Permalink
Update the tools (see #5488)
Browse files Browse the repository at this point in the history
Description
-----------

-

Commits
-------

73a4d4c Update the tools
bc822c8 Disable the rememberPossiblyImpureFunctionValues option
  • Loading branch information
leofeyer committed Nov 10, 2022
1 parent e5fda20 commit 493ced8
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 110 deletions.
18 changes: 9 additions & 9 deletions core-bundle/src/Controller/ContentElement/MarkdownController.php
Expand Up @@ -36,6 +36,15 @@
#[AsContentElement(category: 'texts')]
class MarkdownController extends AbstractContentElementController
{
public static function getSubscribedServices(): array
{
$services = parent::getSubscribedServices();

$services['contao.insert_tag.parser'] = InsertTagParser::class;

return $services;
}

protected function getResponse(Template $template, ContentModel $model, Request $request): Response
{
$this->initializeContaoFramework();
Expand Down Expand Up @@ -115,13 +124,4 @@ private function getContentFromFile(string|null $file): string

return (string) file_get_contents($path);
}

public static function getSubscribedServices(): array
{
$services = parent::getSubscribedServices();

$services['contao.insert_tag.parser'] = InsertTagParser::class;

return $services;
}
}
8 changes: 7 additions & 1 deletion core-bundle/src/Migration/CommandCompiler.php
Expand Up @@ -33,9 +33,15 @@ public function __construct(private readonly Connection $connection, private rea
public function compileCommands(bool $skipDropStatements = false): array
{
$schemaManager = $this->connection->createSchemaManager();
$fromSchema = $schemaManager->createSchema();
$toSchema = $this->schemaProvider->createSchema();

// Backwards compatibility with doctrine/dbal < 3.5
if (method_exists($schemaManager, 'introspectSchema')) {
$fromSchema = $schemaManager->introspectSchema();
} else {
$fromSchema = $schemaManager->createSchema();
}

// If tables or columns should be preserved, we copy the missing
// definitions over to the $toSchema, so that no DROP commands
// will be issued in the diff.
Expand Down
Expand Up @@ -137,6 +137,29 @@ public function testWithFileInput(): void
$fs->remove($tempTestFile);
}

public function testOutputsMarkdownAsHtml(): void
{
$response = $this->renderWithModelData(
new MarkdownController(),
[
'type' => 'markdown',
'code' => "## Headline\n * my\n * list",
]
);

$expectedOutput = <<<'HTML'
<div class="content-markdown">
<h2>Headline</h2>
<ul>
<li>my</li>
<li>list</li>
</ul>
</div>
HTML;

$this->assertSameHtml($expectedOutput, $response->getContent());
}

private function mockContainer(string $expectedMarkdown, array $frameworkAdapters = []): Container
{
$template = $this->createMock(FrontendTemplate::class);
Expand Down Expand Up @@ -176,27 +199,4 @@ private function mockContainer(string $expectedMarkdown, array $frameworkAdapter

return $container;
}

public function testOutputsMarkdownAsHtml(): void
{
$response = $this->renderWithModelData(
new MarkdownController(),
[
'type' => 'markdown',
'code' => "## Headline\n * my\n * list",
]
);

$expectedOutput = <<<'HTML'
<div class="content-markdown">
<h2>Headline</h2>
<ul>
<li>my</li>
<li>list</li>
</ul>
</div>
HTML;

$this->assertSameHtml($expectedOutput, $response->getContent());
}
}
3 changes: 2 additions & 1 deletion core-bundle/tests/Migration/CommandCompilerTest.php
Expand Up @@ -495,7 +495,8 @@ private function getInstaller(Schema $fromSchema = null, Schema $toSchema = null

$schemaManager = $this->createMock(MySQLSchemaManager::class);
$schemaManager
->method('createSchema')
// Backwards compatibility with doctrine/dbal < 3.5
->method(method_exists($schemaManager, 'introspectSchema') ? 'introspectSchema' : 'createSchema')
->willReturn($fromSchema)
;

Expand Down
5 changes: 0 additions & 5 deletions core-bundle/tests/Monolog/ContaoTableProcessorTest.php
Expand Up @@ -32,11 +32,6 @@ public function testCanBeInvoked(): void
{
$processor = $this->getContaoTableProcessor();

/** @phpstan-var Record $record */
$record = [];

$this->assertEmpty($processor($record));

$record = [
'message' => '',
'context' => ['contao' => false],
Expand Down
16 changes: 16 additions & 0 deletions phpstan.neon
Expand Up @@ -31,8 +31,24 @@ parameters:
message: '#type array<Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface> is incompatible with native type Psr\\Container\\ContainerInterface#'
path: %currentWorkingDirectory%/core-bundle/src/Fragment/FragmentHandler.php

-
# Ignore global operations in the DefaultOperationsListenerTest class
message: "#Call to method PHPUnit\\\\Framework\\\\Assert::assertArrayHasKey\\(\\) with 'operations' and array\\{sorting: .+\\}\\} will always evaluate to false\\.#"
path: %currentWorkingDirectory%/core-bundle/tests/EventListener/DataContainer/DefaultOperationsListenerTest.php

-
# Ignore global operations in the PreviewLinkListenerTest class
message: '#Call to method PHPUnit\\Framework\\Assert::assertFalse\(\) with true will always evaluate to false\.#'
path: %currentWorkingDirectory%/core-bundle/tests/EventListener/DataContainer/PreviewLinkListenerTest.php

-
# Ignore global operations in the ContaoFrameworkTest class
message: "#Call to method PHPUnit\\\\Framework\\\\Assert::assertSame\\(\\) with array\\{array\\{'test.listener.+\\}\\} and mixed will always evaluate to false\\.#"
path: %currentWorkingDirectory%/core-bundle/tests/Framework/ContaoFrameworkTest.php

# Ignore the wrong return type hint of the UrlGeneratorInterface::generate() method
- '#Method Contao\\CoreBundle\\Picker\\AbstractPickerProvider::generateUrl\(\) never returns null so it can be removed from the return type\.#'

treatPhpDocTypesAsCertain: false
checkMissingIterableValueType: false
rememberPossiblyImpureFunctionValues: false
30 changes: 18 additions & 12 deletions tools/ecs/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions tools/isolated-tests/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 493ced8

Please sign in to comment.