Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #115 from bocharsky-bw/symfony6-continue
Browse files Browse the repository at this point in the history
Symfony 6 continue
  • Loading branch information
weaverryan committed Jan 26, 2022
2 parents 843b3d0 + 9e2d994 commit dc113af
Show file tree
Hide file tree
Showing 26 changed files with 163 additions and 44 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/phpunit.yaml
@@ -0,0 +1,91 @@
name: PHPUnit

on:
pull_request:

jobs:
phpunit:
name: "PHPUnit - PHP ${{ matrix.php-version }}"
runs-on: ubuntu-20.04
continue-on-error: false
env:
SYMFONY_REQUIRE: ${{matrix.symfony-require}}
SYMFONY_DEPRECATIONS_HELPER: ${{matrix.symfony-deprecations-helper}}

strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
deps:
- "stable"
symfony-require:
- "5.4.*"
symfony-deprecations-helper:
- "5"
include:
- symfony-require: "4.4.*"
php-version: "7.4"
deps: "low"
symfony-deprecations-helper: ""

- symfony-require: "4.4.*"
php-version: "7.4"
deps: "stable"
symfony-deprecations-helper: "5"

- symfony-require: "6.0.*"
php-version: "8.0"
deps: "stable"
symfony-deprecations-helper: "5"

- symfony-require: "6.0.*"
php-version: "8.1"
deps: "stable"
symfony-deprecations-helper: "5"

fail-fast: true

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, pdo, pdo_sqlite, sqlite3
ini-values: date.timezone=UTC

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Install dependencies with Composer
run: composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable

- name: Cache dependencies installed with Composer
uses: actions/cache@v2
with:
path: ~/.composer/cache
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: Install stable dependencies with Composer
run: composer update --no-interaction --prefer-dist --prefer-stable
if: "${{ matrix.deps == 'stable' }}"

- name: Install dev dependencies with Composer
run: composer update --no-interaction --prefer-dist
if: "${{ matrix.deps == 'dev' }}"

- name: Install lowest possible dependencies with Composer
run: composer update --no-interaction --prefer-dist --prefer-stable --prefer-lowest
if: "${{ matrix.deps == 'low' }}"

- name: Install PHPUnit
run: composer run-script test install

- name: Run tests
run: composer run-script test -v
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,4 +1,6 @@
.phpunit.result.cache
phpunit.xml
var/
vendor/*
composer.lock
Tests/fixtures/app/cache
5 changes: 2 additions & 3 deletions DependencyInjection/Configuration.php
Expand Up @@ -12,11 +12,10 @@ class Configuration implements ConfigurationInterface
*
* @return TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('knp_markdown');
// BC layer for symfony/config < 4.2
$rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('knp_markdown');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->addDefaultsIfNotSet()
Expand Down
2 changes: 1 addition & 1 deletion Helper/MarkdownHelper.php
Expand Up @@ -50,7 +50,7 @@ public function setCharset($charset)
*
* @return string The default charset
*/
public function getCharset()
public function getCharset(): string
{
return $this->charset;
}
Expand Down
2 changes: 1 addition & 1 deletion Parser/MarkdownParser.php
Expand Up @@ -124,7 +124,7 @@ public function transformMarkdown($text)
/**
* Simplify detab
*/
public function detab($text)
public function detab($text): string
{
return str_replace("\t", str_repeat(' ', $this->tab_width), $text);
}
Expand Down
2 changes: 1 addition & 1 deletion Parser/Preset/Min.php
Expand Up @@ -15,7 +15,7 @@ public function __construct(array $features = array())
$this->features[$name] = false;
}

return parent::__construct($features);
parent::__construct($features);
}
}

3 changes: 3 additions & 0 deletions README.markdown
Expand Up @@ -2,6 +2,9 @@ Provide markdown conversion (based on [Michel Fortin work](https://github.com/mi

[![Build Status](https://secure.travis-ci.org/KnpLabs/KnpMarkdownBundle.svg)](http://travis-ci.org/KnpLabs/KnpMarkdownBundle)

![ci.yml](https://github.com/tacman/KnpMarkdownBundle/actions/workflows/ci.yml/badge.svg)
![php.yml](https://github.com/tacman/KnpMarkdownBundle/actions/workflows/php.yml/badge.svg)

## INSTALLATION

Add KnpMarkdownBundle to your project via [Composer](https://getcomposer.org/):
Expand Down
6 changes: 3 additions & 3 deletions Twig/Extension/MarkdownTwigExtension.php
Expand Up @@ -15,19 +15,19 @@ public function __construct(ParserManager $parserManager)
$this->parserManager = $parserManager;
}

public function getFilters()
public function getFilters(): array
{
return array(
new TwigFilter('markdown', array($this, 'markdown'), array('is_safe' => array('html'))),
);
}

public function markdown($text, $parser = null)
public function markdown($text, $parser = null): string
{
return $this->parserManager->transform($text, $parser);
}

public function getName()
public function getName(): string
{
return 'markdown';
}
Expand Down
26 changes: 20 additions & 6 deletions composer.json
Expand Up @@ -18,14 +18,16 @@
],

"require": {
"php": "^7.1.3|^8.0",
"symfony/framework-bundle": "~3.4|^4.0|^5.0",
"symfony/dependency-injection": "~3.4|^4.0|^5.0",
"michelf/php-markdown": "~1.4"
"php": "^7.4|^8.0",
"symfony/framework-bundle": "^4.4|^5.0|^6.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"michelf/php-markdown": "^1.9"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.4.0 || ^5.0",
"symfony/templating": "~3.4|^4.0|^5.0"
"symfony/phpunit-bridge": "^4.4.11|^5.0|^6.0",
"symfony/templating": "^4.4|^5.0|^6.0",
"phpstan/phpstan": "^1.2",
"phpstan/phpstan-symfony": "^1.0"
},
"suggest": {
"symfony/twig-bundle": "to use the Twig markdown filter",
Expand All @@ -38,6 +40,18 @@
}
},

"scripts": {
"test": [
"php ./vendor/bin/simple-phpunit"
]
},

"autoload-dev": {
"psr-4": {
"Knp\\Bundle\\MarkdownBundle\\Tests\\": "tests/"
}
},

"autoload": {
"psr-4": {
"Knp\\Bundle\\MarkdownBundle\\": ""
Expand Down
26 changes: 13 additions & 13 deletions phpunit.xml.dist
Expand Up @@ -2,30 +2,30 @@

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
failOnRisky="true"
failOnWarning="true"
failOnIncomplete="false"
>
<php>
<server name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
</php>

<coverage processUncoveredFiles="true">
<include>
<directory>.</directory>
</include>
<exclude>
<directory>tests</directory>
<directory>vendor</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Markdown Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory>.</directory>
<exclude>
<directory>tests</directory>
<directory>vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
</phpunit>
5 changes: 3 additions & 2 deletions Tests/EscapingTest.php → tests/EscapingTest.php
Expand Up @@ -2,13 +2,14 @@

namespace Knp\Bundle\MarkdownBundle\Tests;

use PHPUnit\Framework\TestCase;
use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser as Parser;

class EscapingTest extends \PHPUnit_Framework_TestCase
class EscapingTest extends TestCase
{
protected $parser;

public function setUp()
protected function setUp(): void
{
$this->parser = new Parser();
}
Expand Down
11 changes: 6 additions & 5 deletions Tests/FeatureTest.php → tests/FeatureTest.php
Expand Up @@ -3,8 +3,9 @@
namespace Knp\Bundle\MarkdownBundle\Tests;

use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser as Parser;
use PHPUnit\Framework\TestCase;

class FeatureTest extends \PHPUnit_Framework_TestCase
class FeatureTest extends TestCase
{
public function testParser()
{
Expand Down Expand Up @@ -754,10 +755,10 @@ public function testFootNote($parser)
// asserting a few things instead of comparing full final HTML
// because a few minor things have changed over versions of Michelf
// With assertContains(), tests will pass across all versions
$this->assertContains('<p>That\'s some text with a footnote.<sup id="fnref:1"><a href="#fn:1"', $actualHtml);
$this->assertContains('<div class="footnotes"', $actualHtml);
$this->assertContains('<li id="fn:1"', $actualHtml);
$this->assertContains('<p>And that\'s the footnote.&#160;<a href="#fnref:1" class="footnote-backref"', $actualHtml);
$this->assertStringContainsString('<p>That\'s some text with a footnote.<sup id="fnref:1"><a href="#fn:1"', $actualHtml);
$this->assertStringContainsString('<div class="footnotes"', $actualHtml);
$this->assertStringContainsString('<li id="fn:1"', $actualHtml);
$this->assertStringContainsString('<p>And that\'s the footnote.&#160;<a href="#fnref:1" class="footnote-backref"', $actualHtml);
}

/**
Expand Down
16 changes: 11 additions & 5 deletions Tests/IntegrationTest.php → tests/IntegrationTest.php
Expand Up @@ -4,14 +4,16 @@

use Knp\Bundle\MarkdownBundle\KnpMarkdownBundle;
use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\RouteCollectionBuilder;

class IntegrationTest extends \PHPUnit_Framework_TestCase
class IntegrationTest extends TestCase
{
public function testServicesAvailable()
{
Expand All @@ -29,24 +31,28 @@ class IntegrationKernel extends Kernel

private $cacheDir;

public function registerBundles()
public function registerBundles(): iterable
{
return [
new FrameworkBundle(),
new KnpMarkdownBundle(),
];
}

protected function configureRoutes(RouteCollectionBuilder $routes)
protected function configureRoutes(RoutingConfigurator $routes)
{
}

protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
{
$c->setParameter('kernel.secret', '1234');

$c->loadFromExtension('framework', [
'secret' => 'F00',
'router' => ['utf8' => true]
]);
}

public function getCacheDir()
public function getCacheDir(): string
{
if (null === $this->cacheDir) {
$this->cacheDir = sys_get_temp_dir().'/'.rand(100, 999);
Expand Down
Expand Up @@ -5,8 +5,9 @@
use Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper;
use Knp\Bundle\MarkdownBundle\Tests\fixtures\app\TestKernel;
use Knp\Bundle\MarkdownBundle\Parser\ParserManager;
use PHPUnit\Framework\TestCase;

class ParserManagerTest extends \PHPUnit_Framework_TestCase
class ParserManagerTest extends TestCase
{
public function testIntegration()
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion Tests/PresetTest.php → tests/PresetTest.php
Expand Up @@ -3,8 +3,9 @@
namespace Knp\Bundle\MarkdownBundle\Tests;

use Knp\Bundle\MarkdownBundle\Parser\Preset as Preset;
use PHPUnit\Framework\TestCase;

class PresetTest extends \PHPUnit_Framework_TestCase
class PresetTest extends TestCase
{
public function testMax()
{
Expand Down
Expand Up @@ -12,7 +12,7 @@

class TestKernel extends Kernel
{
public function registerBundles()
public function registerBundles(): iterable
{
return array(
new FrameworkBundle(),
Expand All @@ -31,4 +31,4 @@ public function registerContainerConfiguration(LoaderInterface $loader)
$c->setAlias('markdown.parser.parser_manager.public', new Alias('markdown.parser.parser_manager', true));
});
}
}
}
File renamed without changes.
File renamed without changes.

0 comments on commit dc113af

Please sign in to comment.