Compare commits

...

74 commits

Author SHA1 Message Date
Ryan Weaver 9a8e23f69f minor #117 Abandon this bundle (bocharsky-bw)
This PR was squashed before being merged into the 1.5.x-dev branch.

Discussion
----------

Abandon this bundle

Closes #116

Commits
-------

091cff2 Abandon this bundle
2022-02-01 12:06:52 -05:00
Victor Bocharsky 091cff2698 Abandon this bundle 2022-02-01 12:06:50 -05:00
Ryan Weaver dc113af854
Merge pull request #115 from bocharsky-bw/symfony6-continue
Symfony 6 continue
2022-01-26 13:46:39 -05:00
bocharsky-bw 9e2d994506 Run PHPUnit tests only on PR 2022-01-26 11:34:45 +02:00
bocharsky-bw 80e724bb6c Remove PHP config and simplify PHPUnit one 2022-01-26 11:30:45 +02:00
bocharsky-bw 7dd53fca23 Try to remove CI as well 2022-01-26 11:23:16 +02:00
bocharsky-bw 129a09ce3f Ignore deprecations and run PHPUnit via composer run-script 2022-01-26 10:54:34 +02:00
bocharsky-bw 4f439a0d56 Remove PHP CS Fixer and PHPStan configs for now 2022-01-26 10:44:49 +02:00
bocharsky-bw 59ab364807 Add symfony-deprecations-helper everywhere 2022-01-26 00:08:07 +02:00
bocharsky-bw 68aaf27531 Do not fail on incomplete - we do have incomplete tests 2022-01-26 00:04:56 +02:00
bocharsky-bw 54c72caaf7 Remove symfony-deprecations-helper from a job 2022-01-25 23:59:52 +02:00
bocharsky-bw 2e716d1b64 Fix matrix 2022-01-25 23:55:56 +02:00
bocharsky-bw 643203872b Fix PHPUnit 2022-01-25 23:39:43 +02:00
bocharsky-bw b22717883f Tweak GitHub Action config and matrix 2022-01-25 23:29:47 +02:00
bocharsky-bw c018169d4e Bump symfony/phpunit-bridge to ^4.4.11 to fix PHPUnit error 2022-01-25 20:48:22 +02:00
bocharsky-bw 2b779a4eb3 Drop direct phpunit dep - we use simple phpunit here 2022-01-25 20:44:49 +02:00
bocharsky-bw 63c755a578 Bump PHPUnit to 9.5 2022-01-25 20:44:27 +02:00
bocharsky-bw 74ded9e121 Bump michelf/php-markdown to ^1.9 to fix deprecations 2022-01-25 20:24:07 +02:00
bocharsky-bw 664c3bf82b Bump Symfony lowest to ^4.4 2022-01-25 20:18:11 +02:00
bocharsky-bw b839e4358f Bump PHP version to 7.4 2022-01-25 20:10:45 +02:00
bocharsky-bw cdd1aeec0c Ignore PHPUnit cache file and var/ dir 2022-01-25 19:43:26 +02:00
bocharsky-bw 98710f8f2a Migrate PHPUnit configuration 2022-01-25 19:08:57 +02:00
bocharsky-bw 972faeb8cf Get rid of property types for now 2022-01-25 19:02:38 +02:00
bocharsky-bw 547f137ea8 Use single pipe for all version constrains 2022-01-25 18:44:02 +02:00
bocharsky-bw b9e547fb67 Revert removing Sundown 2022-01-25 18:32:36 +02:00
bocharsky-bw 83d78eb5c7 Bump Symfony to ^4.2 to get rid of treeBuilder->root() BC layer 2022-01-25 18:09:50 +02:00
bocharsky-bw 289f0327bb Revert PHP version back to 7.1.3|^8.0 2022-01-25 17:52:11 +02:00
Tac Tacelosky a87b16a141
Update .github/workflows/phpstan.yaml
Co-authored-by: LAHAXE Arnaud <lahaxe.arnaud@gmail.com>
2021-12-08 06:36:52 -05:00
Tac Tacelosky f782aae4f7 add phpstan 2021-11-30 07:51:46 -05:00
Tac Tacelosky 823f0d8d89 should not return a result in a constructor 2021-11-30 07:49:20 -05:00
Tac Tacelosky 7e0b145307 add phpstan 2021-11-30 07:49:00 -05:00
Tac Tacelosky 6decbb73f9 add phpunit matrix 2021-11-30 07:44:49 -05:00
Tac Tacelosky 88932cc74d use .dist config file for phpunit 2021-11-30 07:35:59 -05:00
Tac Tacelosky 9de7a9f400 update test methods to parent signatures 2021-11-30 07:32:02 -05:00
Tac Tacelosky 7afd756126 merge dev-tac 2021-11-14 20:41:44 -05:00
Tac Tacelosky 90ff78064e update phpunit 2021-11-14 20:39:23 -05:00
Tac Tacelosky 24f6c74239 bump to phpunit9 2021-11-08 07:08:55 -05:00
Tac Tacelosky 86433a9433 show workflow badges 2021-11-08 06:58:03 -05:00
Tac Tacelosky 69862cc6f6 add ci.yml 2021-11-08 06:40:29 -05:00
Tac Tacelosky 5fb3d1c269 Merge branch 'master' into tac 2021-11-08 06:39:52 -05:00
Tac Tacelosky fa322f2a92
Create php.yml 2021-11-08 06:38:06 -05:00
Tac Tacelosky fadc9120b8 remove sundown 2021-11-08 06:32:20 -05:00
Tac Tacelosky da45d3c76d update tests to use phpunit 9.5 2021-11-08 06:24:51 -05:00
Tac Tacelosky eb31781090 remove deprecations 2021-11-05 12:50:12 -04:00
Tac Tacelosky 7074f295ce up to symfony6 2021-11-05 11:24:50 -04:00
Tac Tacelosky 5baa80f676 allow symfony6 2021-11-05 09:48:22 -04:00
Ryan Weaver 843b3d0c9b
Merge pull request #107 from RobinDev/master
Add PHP 8
2021-03-03 15:01:32 -05:00
Robin 5e83a6a9ba add PHP 8 2021-01-20 18:31:15 +01:00
Ryan Weaver d575814dd3
Adding note about avoiding XSS problems
Closes #91
2020-04-15 09:55:14 -04:00
Ryan Weaver 7238cc264e
Merge pull request #102 from abdounikarim/patch-1
Update Twig filters and extension
2019-11-26 08:18:52 -05:00
Abdouni Abdelkarim 6dba9b29bc
Update Twig filters and extension
Hello,

I just updated this file to be compatible with Symfony 5.
The twig filters and extensions were deprecated.

Cheers 😉
2019-11-26 10:56:15 +01:00
abdounikarim a81befb20f update phpunit 2019-11-25 22:01:03 -05:00
abdounikarim bd574d776b remove variable 2019-11-25 22:01:03 -05:00
Ryan Weaver a63663cce6 using a newer phpunit bridge 2019-11-25 22:01:03 -05:00
abdounikarim a172d73960 update .travis.yml 2019-11-25 22:01:03 -05:00
abdounikarim dd17fd825c update composer.json 2019-11-25 22:01:03 -05:00
abdounikarim 182b7cc670 update composer.json 2019-11-25 22:01:03 -05:00
abdounikarim a960290f36 update phpunit.xml.dist file 2019-11-25 22:01:03 -05:00
abdounikarim d462ba15b9 update composer.json 2019-11-25 22:01:03 -05:00
abdounikarim 1cb9e62d4d restoring phpunit 2019-11-25 22:01:03 -05:00
abdounikarim b23e8d965b update composer.json to add symfony/phpunit-bridge 2019-11-25 22:01:03 -05:00
abdounikarim 25663d724b using new .travis.yml config as suggested by @weaverryan 2019-11-25 22:01:03 -05:00
abdounikarim 0f8ec028e9 update .travis.yml and composer.json to work with Symfony 5 2019-11-25 22:01:03 -05:00
Abdouni Abdelkarim f93e8da815 Update composer.json to work with Symfony 5.0 2019-11-25 22:01:03 -05:00
Ryan Weaver c055def2e6
Merge pull request #96 from mercuryseries/patch-1
Fix small typo
2019-01-03 13:47:10 -06:00
Ryan Weaver d2824faf99
Merge pull request #98 from antograssiot/patch-1
Avoid deprecation warning when using symfony/config >= 4.2
2019-01-03 13:46:37 -06:00
Anto c2b7faa646
Avoid deprecation warning when using symfony/config >= 4.2 2018-12-10 20:53:47 +01:00
Honoré HOUNWANOU 881585be15
Fix small typo
Fix a small typo by adding a missing $this.
2018-10-31 05:11:57 -04:00
Ryan Weaver a97046ec63
removing 2 on Symfony :) 2018-01-25 14:19:16 -06:00
Ryan Weaver 8947cfb930
Clarifying filename 2018-01-25 11:39:06 -06:00
Ryan Weaver 4e998d807c
app/console -> bin/console 2018-01-23 10:31:33 -06:00
Ryan Weaver 912796833a
Merge pull request #94 from KnpLabs/remove-templating-dependency
Making the templating component an optional dependency
2018-01-23 10:34:53 -05:00
Ryan Weaver 02d9f8b7a4 Various test fixes: new versions of Michelf, etc 2018-01-23 10:25:18 -05:00
Ryan Weaver 91a268692e Making the templating component an optional dependency
It already basically was, but we were requiring it.
2018-01-22 20:45:26 -05:00
29 changed files with 237 additions and 106 deletions

91
.github/workflows/phpunit.yaml vendored Normal file
View file

@ -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
.gitignore vendored
View file

@ -1,4 +1,6 @@
.phpunit.result.cache
phpunit.xml phpunit.xml
var/
vendor/* vendor/*
composer.lock composer.lock
Tests/fixtures/app/cache Tests/fixtures/app/cache

View file

@ -1,39 +1,39 @@
language: php language: php
sudo: false sudo: false
cache: cache:
directories: directories:
- $HOME/.composer/cache/files - $HOME/.composer/cache/files
- $HOME/symfony-bridge/.phpunit
php: env:
- 5.5 global:
- 5.6 - PHPUNIT_FLAGS="-v"
- 7.0 - SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
- 7.1
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
# Test against lowest bounds of dependencies to ensure they are right
- php: 5.6
env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
# Test against dev versions of dependencies
- php: 5.6
env: deps=dev
# test the latest release (including beta releases)
- php: 7.1 - php: 7.1
env: deps=beta - php: 7.2
- php: 7.3
env: deps=low
- php: 7.4
- php: 8.0
before_install: before_install:
- if [ "$deps" = 'beta' ]; then perl -pi -e 's/^}$/,"minimum-stability":"beta"}/' composer.json; fi; - phpenv config-rm xdebug.ini || true
- if [ "$deps" = 'dev' ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi; - composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-main
install: install:
- composer update $COMPOSER_FLAGS - |
if [[ $deps = low ]]; then
export SYMFONY_DEPRECATIONS_HELPER=weak
composer update --prefer-dist --prefer-lowest --prefer-stable
else
composer update --prefer-dist
fi
- ./vendor/bin/simple-phpunit install
script: phpunit --coverage-text script:
- composer validate --strict --no-check-lock
notifications: - ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS
email:
- travis@knplabs.com

6
CHANGELOG.md Normal file
View file

@ -0,0 +1,6 @@
1.7
===
* The MarkdownHelper Templating component integration (and corresponding
`templating.helper.markdown` services) are no longer added unless you
have the `symfony/templating` component installed.

View file

@ -12,11 +12,12 @@ class Configuration implements ConfigurationInterface
* *
* @return TreeBuilder * @return TreeBuilder
*/ */
public function getConfigTreeBuilder() public function getConfigTreeBuilder(): TreeBuilder
{ {
$treeBuilder = new TreeBuilder(); $treeBuilder = new TreeBuilder('knp_markdown');
$rootNode = $treeBuilder->getRootNode();
$treeBuilder->root('knp_markdown', 'array') $rootNode
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
->children() ->children()
->arrayNode('parser') ->arrayNode('parser')

View file

@ -10,6 +10,7 @@ use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Templating\EngineInterface;
class KnpMarkdownExtension extends Extension class KnpMarkdownExtension extends Extension
{ {
@ -29,7 +30,10 @@ class KnpMarkdownExtension extends Extension
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('parser.xml'); $loader->load('parser.xml');
$loader->load('helper.xml'); // BC to support the PHP templates in the Templating component
if (interface_exists(EngineInterface::class)) {
$loader->load('helper.xml');
}
$loader->load('twig.xml'); $loader->load('twig.xml');
if ('markdown.parser.sundown' == $config['parser']['service']) { if ('markdown.parser.sundown' == $config['parser']['service']) {

View file

@ -5,6 +5,9 @@ namespace Knp\Bundle\MarkdownBundle\Helper;
use Knp\Bundle\MarkdownBundle\Parser\ParserManager; use Knp\Bundle\MarkdownBundle\Parser\ParserManager;
use Symfony\Component\Templating\Helper\HelperInterface; use Symfony\Component\Templating\Helper\HelperInterface;
/**
* @deprecated The MarkdownHelper was deprecated in 1.7 and will be removed in 2.0.
*/
class MarkdownHelper implements HelperInterface class MarkdownHelper implements HelperInterface
{ {
private $parserManager; private $parserManager;
@ -27,6 +30,8 @@ class MarkdownHelper implements HelperInterface
*/ */
public function transform($markdownText, $parserName = null) public function transform($markdownText, $parserName = null)
{ {
trigger_error('The MarkdownHelper was deprecated in 1.7 and will be removed in KnpMarkdownBundle 2.0.', E_USER_DEPRECATED);
return $this->parserManager->transform($markdownText, $parserName); return $this->parserManager->transform($markdownText, $parserName);
} }
@ -45,7 +50,7 @@ class MarkdownHelper implements HelperInterface
* *
* @return string The default charset * @return string The default charset
*/ */
public function getCharset() public function getCharset(): string
{ {
return $this->charset; return $this->charset;
} }

View file

@ -124,7 +124,7 @@ class MarkdownParser extends MarkdownExtra implements MarkdownParserInterface
/** /**
* Simplify detab * Simplify detab
*/ */
public function detab($text) public function detab($text): string
{ {
return str_replace("\t", str_repeat(' ', $this->tab_width), $text); return str_replace("\t", str_repeat(' ', $this->tab_width), $text);
} }

View file

@ -15,7 +15,7 @@ class Min extends MarkdownParser
$this->features[$name] = false; $this->features[$name] = false;
} }
return parent::__construct($features); parent::__construct($features);
} }
} }

View file

@ -1,7 +1,14 @@
Provide markdown conversion (based on [Michel Fortin work](https://github.com/michelf/php-markdown)) to your Symfony2 projects. > **WARNING:** This bundle is **abandoned** in favor of [markdown_to_html](https://twig.symfony.com/doc/3.x/filters/markdown_to_html.html)
> Twig filter. Please, consider using it instead. Migration should be easy because it also supports
> `michelf/php-markdown` Markdown parser that is used in this project under the hood.
Provide markdown conversion (based on [Michel Fortin work](https://github.com/michelf/php-markdown)) to your Symfony projects.
[![Build Status](https://secure.travis-ci.org/KnpLabs/KnpMarkdownBundle.svg)](http://travis-ci.org/KnpLabs/KnpMarkdownBundle) [![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 ## INSTALLATION
Add KnpMarkdownBundle to your project via [Composer](https://getcomposer.org/): Add KnpMarkdownBundle to your project via [Composer](https://getcomposer.org/):
@ -40,7 +47,7 @@ public function __construct(MarkdownParserInterface $parser)
public function someMethod() public function someMethod()
{ {
$html = $parser->transformMarkdown($text); $html = $this->parser->transformMarkdown($text);
} }
``` ```
@ -52,6 +59,11 @@ In Twig, you can use the `markdown` filter:
{# Use default parser #} {# Use default parser #}
{{ my_data|markdown }} {{ my_data|markdown }}
{# If my_data is entered by a user, escape HTML tags before printing it #}
{{ my_data|escape|markdown }}
{# or strip HTML tags #}
{{ my_data|striptags|markdown }}
{# Or select specific parser #} {# Or select specific parser #}
{{ my_data|markdown('parserName') }} {{ my_data|markdown('parserName') }}
``` ```
@ -62,6 +74,8 @@ Create a service implementing `Knp\Bundle\MarkdownBundle\MarkdownParserInterface
then configure the bundle to use it: then configure the bundle to use it:
```yaml ```yaml
# Symfony 3: app/config/config.yml
# Symfony 4: config/packages/knp_markdown.yaml (you'll need to create this)
knp_markdown: knp_markdown:
parser: parser:
service: my.markdown.parser service: my.markdown.parser
@ -71,7 +85,7 @@ Alternatively if you are using the ``markdown.parser.sundown`` there are
options for enabling sundown extensions and render flags, see the options for enabling sundown extensions and render flags, see the
default Configuration with: default Configuration with:
php app/console config:dump-reference knp_markdown php bin/console config:dump-reference knp_markdown
This bundle comes with 5 parser services, 4 based on the same algorithm This bundle comes with 5 parser services, 4 based on the same algorithm
but providing different levels of compliance to the markdown specification, but providing different levels of compliance to the markdown specification,

View file

@ -3,8 +3,10 @@
namespace Knp\Bundle\MarkdownBundle\Twig\Extension; namespace Knp\Bundle\MarkdownBundle\Twig\Extension;
use Knp\Bundle\MarkdownBundle\Parser\ParserManager; use Knp\Bundle\MarkdownBundle\Parser\ParserManager;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class MarkdownTwigExtension extends \Twig_Extension class MarkdownTwigExtension extends AbstractExtension
{ {
private $parserManager; private $parserManager;
@ -13,19 +15,19 @@ class MarkdownTwigExtension extends \Twig_Extension
$this->parserManager = $parserManager; $this->parserManager = $parserManager;
} }
public function getFilters() public function getFilters(): array
{ {
return array( return array(
new \Twig_SimpleFilter('markdown', array($this, 'markdown'), array('is_safe' => array('html'))), 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); return $this->parserManager->transform($text, $parser);
} }
public function getName() public function getName(): string
{ {
return 'markdown'; return 'markdown';
} }

View file

@ -18,15 +18,18 @@
], ],
"require": { "require": {
"php": ">=5.5.9", "php": "^7.4|^8.0",
"symfony/framework-bundle": "~2.8|~3.0|^4.0", "symfony/framework-bundle": "^4.4|^5.0|^6.0",
"symfony/dependency-injection": "~2.8|~3.0|^4.0", "symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/templating": "~2.8|~3.0|^4.0", "michelf/php-markdown": "^1.9"
"michelf/php-markdown": "~1.4"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.5" "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"
}, },
"abandoned": "twig/markdown-extra",
"suggest": { "suggest": {
"symfony/twig-bundle": "to use the Twig markdown filter", "symfony/twig-bundle": "to use the Twig markdown filter",
"ext-sundown": "to use optional support for php-sundown extension instead of php implementation" "ext-sundown": "to use optional support for php-sundown extension instead of php implementation"
@ -38,6 +41,18 @@
} }
}, },
"scripts": {
"test": [
"php ./vendor/bin/simple-phpunit"
]
},
"autoload-dev": {
"psr-4": {
"Knp\\Bundle\\MarkdownBundle\\Tests\\": "tests/"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Knp\\Bundle\\MarkdownBundle\\": "" "Knp\\Bundle\\MarkdownBundle\\": ""

View file

@ -1,30 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" <!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
backupStaticAttributes="false" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true" colors="true"
convertErrorsToExceptions="true" failOnRisky="true"
convertNoticesToExceptions="true" failOnWarning="true"
convertWarningsToExceptions="true" failOnIncomplete="false"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./vendor/autoload.php"
> >
<php>
<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> <testsuites>
<testsuite name="Markdown Test Suite"> <testsuite name="Markdown Test Suite">
<directory>./Tests/</directory> <directory>tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit> </phpunit>

View file

@ -2,13 +2,14 @@
namespace Knp\Bundle\MarkdownBundle\Tests; namespace Knp\Bundle\MarkdownBundle\Tests;
use PHPUnit\Framework\TestCase;
use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser as Parser; use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser as Parser;
class EscapingTest extends \PHPUnit_Framework_TestCase class EscapingTest extends TestCase
{ {
protected $parser; protected $parser;
public function setUp() protected function setUp(): void
{ {
$this->parser = new Parser(); $this->parser = new Parser();
} }

View file

@ -3,8 +3,9 @@
namespace Knp\Bundle\MarkdownBundle\Tests; namespace Knp\Bundle\MarkdownBundle\Tests;
use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser as Parser; 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() public function testParser()
{ {
@ -749,31 +750,15 @@ That's some text with a footnote.[^1]
[^1]: And that's the footnote. [^1]: And that's the footnote.
EOF; EOF;
$html = <<<EOF
<p>That's some text with a footnote.<sup id="fnref:1"><a href="#fn:1" class="footnote-ref">1</a></sup></p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>And that's the footnote.&#160;<a href="#fnref:1" class="footnote-backref">&#8617;&#xFE0E;</a></p>
</li>
</ol>
</div>
EOF;
// newer versions of Michelf add an extra &#xFE0E; To make the tests
// pass against ALL versions, we just hack the &#xFE0E; into the
// expected string if it isn't there
$actualHtml = $parser->transform($text); $actualHtml = $parser->transform($text);
if (strpos($actualHtml, '&#xFE0E;') === false) {
$actualHtml = str_replace('&#8617;', '&#8617;&#xFE0E;', $actualHtml);
}
$this->assertEquals($html, $actualHtml); // 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->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);
} }
/** /**

View file

@ -4,14 +4,16 @@ namespace Knp\Bundle\MarkdownBundle\Tests;
use Knp\Bundle\MarkdownBundle\KnpMarkdownBundle; use Knp\Bundle\MarkdownBundle\KnpMarkdownBundle;
use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser; use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\RouteCollectionBuilder; use Symfony\Component\Routing\RouteCollectionBuilder;
class IntegrationTest extends \PHPUnit_Framework_TestCase class IntegrationTest extends TestCase
{ {
public function testServicesAvailable() public function testServicesAvailable()
{ {
@ -29,7 +31,7 @@ class IntegrationKernel extends Kernel
private $cacheDir; private $cacheDir;
public function registerBundles() public function registerBundles(): iterable
{ {
return [ return [
new FrameworkBundle(), new FrameworkBundle(),
@ -37,16 +39,20 @@ class IntegrationKernel extends Kernel
]; ];
} }
protected function configureRoutes(RouteCollectionBuilder $routes) protected function configureRoutes(RoutingConfigurator $routes)
{ {
} }
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) 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) { if (null === $this->cacheDir) {
$this->cacheDir = sys_get_temp_dir().'/'.rand(100, 999); $this->cacheDir = sys_get_temp_dir().'/'.rand(100, 999);

View file

@ -5,8 +5,9 @@ namespace Knp\Bundle\MarkdownBundle\Tests\Parser;
use Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper; use Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper;
use Knp\Bundle\MarkdownBundle\Tests\fixtures\app\TestKernel; use Knp\Bundle\MarkdownBundle\Tests\fixtures\app\TestKernel;
use Knp\Bundle\MarkdownBundle\Parser\ParserManager; use Knp\Bundle\MarkdownBundle\Parser\ParserManager;
use PHPUnit\Framework\TestCase;
class ParserManagerTest extends \PHPUnit_Framework_TestCase class ParserManagerTest extends TestCase
{ {
public function testIntegration() public function testIntegration()
{ {
@ -24,10 +25,5 @@ class ParserManagerTest extends \PHPUnit_Framework_TestCase
$actual = $parserManager->transform('*hi*', 'light'); $actual = $parserManager->transform('*hi*', 'light');
$this->assertEquals("<p><em>hi</em></p>\n", $actual, 'Specific parsers are registered'); $this->assertEquals("<p><em>hi</em></p>\n", $actual, 'Specific parsers are registered');
/** @var MarkdownHelper $markdownHelper */
$markdownHelper = $container->get('templating.helper.markdown');
$actual = $markdownHelper->transform('*yo*');
$this->assertEquals("<p><em>yo</em></p>\n", $actual, 'The templating helper also works');
} }
} }

View file

@ -3,8 +3,9 @@
namespace Knp\Bundle\MarkdownBundle\Tests; namespace Knp\Bundle\MarkdownBundle\Tests;
use Knp\Bundle\MarkdownBundle\Parser\Preset as Preset; 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() public function testMax()
{ {

View file

@ -5,13 +5,14 @@ namespace Knp\Bundle\MarkdownBundle\Tests\fixtures\app;
use Knp\Bundle\MarkdownBundle\KnpMarkdownBundle; use Knp\Bundle\MarkdownBundle\KnpMarkdownBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Kernel;
class TestKernel extends Kernel class TestKernel extends Kernel
{ {
public function registerBundles() public function registerBundles(): iterable
{ {
return array( return array(
new FrameworkBundle(), new FrameworkBundle(),
@ -27,7 +28,7 @@ class TestKernel extends Kernel
)); ));
// add a public alias so we can fetch for testing // add a public alias so we can fetch for testing
$c->setAlias('markdown.parser.parser_manager.public', 'markdown.parser.parser_manager'); $c->setAlias('markdown.parser.parser_manager.public', new Alias('markdown.parser.parser_manager', true));
}); });
} }
} }