diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ee965d5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +name: CI + +on: [push] + +jobs: + build-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: php-actions/composer@v5 + + - name: PHPUnit Tests + uses: php-actions/phpunit@v9 + env: + TEST_NAME: PHPUNIT + with: + bootstrap: vendor/autoload.php + configuration: phpunit.xml + args: --coverage-text diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..066ac59 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,36 @@ +name: PHP Composer + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md + + - name: Run test suite + run: composer run-script test diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 90bbdfa..3d5900a 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -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() @@ -27,37 +26,6 @@ class Configuration implements ConfigurationInterface ->scalarNode('service')->cannotBeEmpty()->defaultValue('markdown.parser.max')->end() ->end() ->end() - ->arrayNode('sundown') - ->addDefaultsIfNotSet() - ->children() - ->arrayNode('extensions') - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('fenced_code_blocks')->defaultFalse()->end() - ->booleanNode('no_intra_emphasis')->defaultFalse()->end() - ->booleanNode('tables')->defaultFalse()->end() - ->booleanNode('autolink')->defaultFalse()->end() - ->booleanNode('strikethrough')->defaultFalse()->end() - ->booleanNode('lax_html_blocks')->defaultFalse()->end() - ->booleanNode('space_after_headers')->defaultFalse()->end() - ->booleanNode('superscript')->defaultFalse()->end() - ->end() - ->end() - ->arrayNode('render_flags') - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('filter_html')->defaultFalse()->end() - ->booleanNode('no_images')->defaultFalse()->end() - ->booleanNode('no_links')->defaultFalse()->end() - ->booleanNode('no_styles')->defaultFalse()->end() - ->booleanNode('safe_links_only')->defaultFalse()->end() - ->booleanNode('with_toc_data')->defaultFalse()->end() - ->booleanNode('hard_wrap')->defaultFalse()->end() - ->booleanNode('xhtml')->defaultFalse()->end() - ->end() - ->end() - ->end() - ->end() ->end() ->end(); diff --git a/Parser/SundownParser.php b/Parser/SundownParser.php deleted file mode 100644 index 572bc7d..0000000 --- a/Parser/SundownParser.php +++ /dev/null @@ -1,30 +0,0 @@ -parser = $parser; - } - - /** - * {@inheritdoc} - */ - public function transformMarkdown($text) - { - return $this->parser->render($text); - } -} diff --git a/README.markdown b/README.markdown index 715d6ad..398d3a7 100644 --- a/README.markdown +++ b/README.markdown @@ -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/): diff --git a/Resources/config/sundown.xml b/Resources/config/sundown.xml deleted file mode 100644 index ea1f81d..0000000 --- a/Resources/config/sundown.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Knp\Bundle\MarkdownBundle\Parser\SundownParser - Sundown\Markdown - Sundown\Render\HTML - - - - - - - - - - %markdown.sundown.extensions% - - - - %markdown.sundown.render_flags% - - - diff --git a/composer.json b/composer.json index df598c7..a071716 100644 --- a/composer.json +++ b/composer.json @@ -18,20 +18,18 @@ ], "require": { - "php": "^7.1.3|^8.0", - "symfony/framework-bundle": "~3.4|^4.0|^5.0|^6.0", - "symfony/dependency-injection": "~3.4|^4.0|^5.0|^6.0", + "php": ">= 7.4", + "symfony/framework-bundle": "^4.0|^5.0|^6.0", + "symfony/dependency-injection": "^4.0|^5.0|^6.0", "michelf/php-markdown": "~1.4" }, "require-dev": { - "phpunit/phpunit": "^9.5", "symfony/phpunit-bridge": "^4.4.0 || ^5.0 || ^6.0", - "symfony/templating": "~3.4|^4.0|^5.0|^6.0", - "symfony/test-pack": "^1.0" + "symfony/templating": "^4.0|^5.0|^6.0", + "phpunit/phpunit": "^9.5" }, "suggest": { - "symfony/twig-bundle": "to use the Twig markdown filter", - "ext-sundown": "to use optional support for php-sundown extension instead of php implementation" + "symfony/twig-bundle": "to use the Twig markdown filter" }, "extra": { @@ -40,6 +38,18 @@ } }, + "scripts": { + "test": [ + "php ./vendor/bin/phpunit" + ] + }, + + "autoload-dev": { + "psr-4": { + "Knp\\Bundle\\MarkdownBundle\\Tests\\": "tests/" + } + }, + "autoload": { "psr-4": { "Knp\\Bundle\\MarkdownBundle\\": "" diff --git a/Tests/EscapingTest.php b/tests/EscapingTest.php similarity index 89% rename from Tests/EscapingTest.php rename to tests/EscapingTest.php index a2d396f..92f49b0 100644 --- a/Tests/EscapingTest.php +++ b/tests/EscapingTest.php @@ -2,13 +2,15 @@ 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() + public function setUp(): void { $this->parser = new Parser(); } diff --git a/Tests/FeatureTest.php b/tests/FeatureTest.php similarity index 97% rename from Tests/FeatureTest.php rename to tests/FeatureTest.php index 7c0d099..a2291d7 100644 --- a/Tests/FeatureTest.php +++ b/tests/FeatureTest.php @@ -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() { @@ -754,10 +755,10 @@ EOF; // 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('

That\'s some text with a footnote.assertContains('

assertContains('
  • assertContains('

    And that\'s the footnote. assertStringContainsString('

    That\'s some text with a footnote.assertStringContainsString('

  • assertStringContainsString('

    And that\'s the footnote. setParameter('kernel.secret', '1234'); + + $c->loadFromExtension('framework', [ + 'secret' => 'F00', + 'router' => ['utf8' => true] + ]); } public function getCacheDir() diff --git a/Tests/Parser/ParserManagerTest.php b/tests/Parser/ParserManagerTest.php similarity index 92% rename from Tests/Parser/ParserManagerTest.php rename to tests/Parser/ParserManagerTest.php index 9285ea8..7357c1e 100644 --- a/Tests/Parser/ParserManagerTest.php +++ b/tests/Parser/ParserManagerTest.php @@ -5,8 +5,9 @@ namespace Knp\Bundle\MarkdownBundle\Tests\Parser; 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() { diff --git a/Tests/Performance/.htaccess b/tests/Performance/.htaccess similarity index 100% rename from Tests/Performance/.htaccess rename to tests/Performance/.htaccess diff --git a/Tests/Performance/Base.php b/tests/Performance/Base.php similarity index 100% rename from Tests/Performance/Base.php rename to tests/Performance/Base.php diff --git a/Tests/Performance/Light.php b/tests/Performance/Light.php similarity index 100% rename from Tests/Performance/Light.php rename to tests/Performance/Light.php diff --git a/Tests/Performance/Max.php b/tests/Performance/Max.php similarity index 100% rename from Tests/Performance/Max.php rename to tests/Performance/Max.php diff --git a/Tests/Performance/Medium.php b/tests/Performance/Medium.php similarity index 100% rename from Tests/Performance/Medium.php rename to tests/Performance/Medium.php diff --git a/Tests/Performance/Min.php b/tests/Performance/Min.php similarity index 100% rename from Tests/Performance/Min.php rename to tests/Performance/Min.php diff --git a/Tests/Performance/index.php b/tests/Performance/index.php similarity index 100% rename from Tests/Performance/index.php rename to tests/Performance/index.php diff --git a/Tests/Performance/run b/tests/Performance/run similarity index 100% rename from Tests/Performance/run rename to tests/Performance/run diff --git a/Tests/PresetTest.php b/tests/PresetTest.php similarity index 94% rename from Tests/PresetTest.php rename to tests/PresetTest.php index cc7aaf0..224cb31 100644 --- a/Tests/PresetTest.php +++ b/tests/PresetTest.php @@ -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() { diff --git a/Tests/fixtures/app/TestKernel.php b/tests/fixtures/app/TestKernel.php similarity index 100% rename from Tests/fixtures/app/TestKernel.php rename to tests/fixtures/app/TestKernel.php diff --git a/Tests/fixtures/big_text.html b/tests/fixtures/big_text.html similarity index 100% rename from Tests/fixtures/big_text.html rename to tests/fixtures/big_text.html diff --git a/Tests/fixtures/big_text.markdown b/tests/fixtures/big_text.markdown similarity index 100% rename from Tests/fixtures/big_text.markdown rename to tests/fixtures/big_text.markdown