From da45d3c76ded164e339ad9157e4eb3c9f520377a Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 06:24:51 -0500 Subject: [PATCH 1/6] update tests to use phpunit 9.5 --- composer.json | 17 ++++++++++++----- {Tests => tests}/EscapingTest.php | 6 ++++-- {Tests => tests}/FeatureTest.php | 11 ++++++----- {Tests => tests}/IntegrationTest.php | 12 +++++++++--- {Tests => tests}/Parser/ParserManagerTest.php | 3 ++- {Tests => tests}/Performance/.htaccess | 0 {Tests => tests}/Performance/Base.php | 0 {Tests => tests}/Performance/Light.php | 0 {Tests => tests}/Performance/Max.php | 0 {Tests => tests}/Performance/Medium.php | 0 {Tests => tests}/Performance/Min.php | 0 {Tests => tests}/Performance/index.php | 0 {Tests => tests}/Performance/run | 0 {Tests => tests}/PresetTest.php | 3 ++- {Tests => tests}/fixtures/app/TestKernel.php | 0 {Tests => tests}/fixtures/big_text.html | 0 {Tests => tests}/fixtures/big_text.markdown | 0 17 files changed, 35 insertions(+), 17 deletions(-) rename {Tests => tests}/EscapingTest.php (89%) rename {Tests => tests}/FeatureTest.php (97%) rename {Tests => tests}/IntegrationTest.php (78%) rename {Tests => tests}/Parser/ParserManagerTest.php (92%) rename {Tests => tests}/Performance/.htaccess (100%) rename {Tests => tests}/Performance/Base.php (100%) rename {Tests => tests}/Performance/Light.php (100%) rename {Tests => tests}/Performance/Max.php (100%) rename {Tests => tests}/Performance/Medium.php (100%) rename {Tests => tests}/Performance/Min.php (100%) rename {Tests => tests}/Performance/index.php (100%) rename {Tests => tests}/Performance/run (100%) rename {Tests => tests}/PresetTest.php (94%) rename {Tests => tests}/fixtures/app/TestKernel.php (100%) rename {Tests => tests}/fixtures/big_text.html (100%) rename {Tests => tests}/fixtures/big_text.markdown (100%) diff --git a/composer.json b/composer.json index 961801c..8c6a04e 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,15 @@ ], "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", + "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": { - "symfony/phpunit-bridge": "^4.4.0 || ^5.0", - "symfony/templating": "~3.4|^4.0|^5.0" + "symfony/phpunit-bridge": "^4.4.0 || ^5.0 || ^6.0", + "symfony/templating": "^4.0|^5.0|^6.0", + "phpunit/phpunit": "^9.5" }, "suggest": { "symfony/twig-bundle": "to use the Twig markdown filter", @@ -38,6 +39,12 @@ } }, + "autoload-dev": { + "psr-4": { + "App\\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 From fadc9120b8066b983857fefb1432ea2420036f33 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 06:32:20 -0500 Subject: [PATCH 2/6] remove sundown --- DependencyInjection/Configuration.php | 36 ++------------------------- Parser/SundownParser.php | 30 ---------------------- Resources/config/sundown.xml | 26 ------------------- composer.json | 5 ++-- 4 files changed, 4 insertions(+), 93 deletions(-) delete mode 100644 Parser/SundownParser.php delete mode 100644 Resources/config/sundown.xml 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/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 8c6a04e..fd53e00 100644 --- a/composer.json +++ b/composer.json @@ -29,8 +29,7 @@ "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": { @@ -41,7 +40,7 @@ "autoload-dev": { "psr-4": { - "App\\Tests\\": "tests/" + "Knp\\Bundle\\MarkdownBundle\\Tests\\": "tests/" } }, From fa322f2a926dddc28b113cd501b2509c944d7e6f Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 06:38:06 -0500 Subject: [PATCH 3/6] Create php.yml --- .github/workflows/php.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..65254b6 --- /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 From 69862cc6f6ef83deee52c38a265b573567505404 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 06:40:29 -0500 Subject: [PATCH 4/6] add ci.yml --- .github/workflows/ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..95a28e3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,14 @@ +name: CI + +on: [push] + +jobs: + build-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: php-actions/composer@v5 # or alternative dependency management + - uses: php-actions/phpunit@v9 + # ... then your own project steps ... + From 86433a9433f0ec8111c916cef575fe6adebb273b Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 06:58:03 -0500 Subject: [PATCH 5/6] show workflow badges --- .github/workflows/ci.yml | 15 +++++++++++---- .github/workflows/php.yml | 4 ++-- README.markdown | 3 +++ composer.json | 6 ++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95a28e3..ed5c28c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: php-actions/composer@v5 # or alternative dependency management - - uses: php-actions/phpunit@v9 - # ... then your own project steps ... + - uses: actions/checkout@v2 + - uses: php-actions/composer@v5 + + - name: PHPUnit Tests + uses: php-actions/phpunit@v2 + 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 index 65254b6..066ac59 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -32,5 +32,5 @@ jobs: # 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 + - name: Run test suite + run: composer run-script test 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/composer.json b/composer.json index fd53e00..a071716 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,12 @@ } }, + "scripts": { + "test": [ + "php ./vendor/bin/phpunit" + ] + }, + "autoload-dev": { "psr-4": { "Knp\\Bundle\\MarkdownBundle\\Tests\\": "tests/" From 24f6c742397cc5b065c69bc8a7a552273e08ad89 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 07:08:55 -0500 Subject: [PATCH 6/6] bump to phpunit9 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed5c28c..ee965d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: - uses: php-actions/composer@v5 - name: PHPUnit Tests - uses: php-actions/phpunit@v2 + uses: php-actions/phpunit@v9 env: TEST_NAME: PHPUNIT with: