Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the tools #5488

Merged
merged 2 commits into from Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions core-bundle/contao/library/Contao/Input.php
Expand Up @@ -480,6 +480,8 @@ public static function setUnusedRouteParameters(array $routeParameters): void
*
* @see FrontendTemplate::compile()
*
* @phpstan-impure
*
* @return list<string>
*/
public static function getUnusedRouteParameters(): array
Expand Down
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
20 changes: 20 additions & 0 deletions phpstan.neon
Expand Up @@ -31,6 +31,26 @@ 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 undetected changes in the cache adpater after persisting data
message: '#Call to method PHPUnit\\Framework\\Assert::assertNotEmpty\(\) with array\{\} will always evaluate to false\.#'
path: %currentWorkingDirectory%/core-bundle/tests/Twig/Loader/ContaoFilesystemLoaderTest.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\.#'

Expand Down
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.