diff --git a/.github/workflows/composer-diff.yml b/.github/workflows/composer-diff.yml
new file mode 100644
index 0000000..f24ca9e
--- /dev/null
+++ b/.github/workflows/composer-diff.yml
@@ -0,0 +1,29 @@
+name: Composer Diff
+on:
+ pull_request:
+ paths:
+ - 'composer.lock'
+jobs:
+ composer-diff:
+ name: Composer Diff
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0 # Required to make it possible to compare with PR base branch
+
+ - name: Generate composer diff
+ id: composer_diff # To reference the output in comment
+ uses: IonBazan/composer-diff-action@v1
+
+ - uses: marocchino/sticky-pull-request-comment@v2
+ with:
+ header: composer-diff # Creates a collapsed comment with the report
+ message: |
+
+ Composer package changes
+
+ ${{ steps.composer_diff.outputs.composer_diff }}
+
+
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
new file mode 100644
index 0000000..2b20f8e
--- /dev/null
+++ b/.github/workflows/php.yml
@@ -0,0 +1,49 @@
+name: PHP Composer
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+ runs-on: ${{ matrix.operating-system }}
+ continue-on-error: true
+
+ strategy:
+ matrix:
+ operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest']
+ php-versions: ['7.4', '8.0', '8.1']
+ phpunit-versions: ['latest']
+
+ steps:
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php-versions }}
+ extensions: mbstring, intl, fileinfo
+ ini-values: post_max_size=256M, max_execution_time=180
+ coverage: xdebug
+ tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
+
+ - 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-${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-php-${{ matrix.php-versions }}-
+ ${{ runner.os }}-php-
+
+ - name: Install dependencies
+ run: composer install --prefer-dist --no-progress
+
+ - name: Run test suite
+ run: composer test
diff --git a/.gitignore b/.gitignore
index dfd6caa..8b7ef35 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
/vendor
-composer.lock
\ No newline at end of file
+composer.lock
diff --git a/.travis.yml b/.travis.yml
index 5e4891f..6f611cc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,9 @@
language: php
php:
- - 7.0
- - 7.1
- - 7.2
+ - 7.3
+ - 7.4
+ - 8.0
+ - 8.1
- nightly
matrix:
allow_failures:
diff --git a/composer.json b/composer.json
index bf5a7d9..2159b90 100644
--- a/composer.json
+++ b/composer.json
@@ -1,12 +1,20 @@
{
"name": "ivuorinen/bbcodeparser",
"description": "Parse your BBCode easy with this library.",
- "keywords": ["bbcode", "parser", "laravel", "psr-1", "psr-2", "psr-4"],
- "homepage": "https://github.com/ivuorinen/bbcodeparser",
- "type": "library",
"license": "MIT",
- "support": {
- "issues": "https://github.com/ivuorinen/bbcodeparser/issues"
+ "type": "library",
+ "keywords": [
+ "bbcode",
+ "parser",
+ "laravel",
+ "psr-1",
+ "psr-2",
+ "psr-4"
+ ],
+ "scripts": {
+ "test": "vendor/bin/phpunit",
+ "lint": "vendor/bin/phpcs",
+ "lint-fix": "vendor/bin/phpcbf"
},
"authors": [
{
@@ -20,37 +28,50 @@
"homepage": "https://github.com/golonka/"
}
],
+ "homepage": "https://github.com/ivuorinen/bbcodeparser",
+ "support": {
+ "issues": "https://github.com/ivuorinen/bbcodeparser/issues"
+ },
"require": {
- "php": ">=7"
+ "php": ">=7.4 || ^8.0 || ^8.1"
},
"require-dev": {
- "phpunit/phpunit": "5.7.27",
- "squizlabs/php_codesniffer": "2.9.2",
- "orchestra/testbench": "3.9.4"
+ "dms/phpunit-arraysubset-asserts": "v0.3.1",
+ "ergebnis/composer-normalize": "2.23.1",
+ "orchestra/testbench": "v6.24.1",
+ "phpunit/phpunit": "9.5.13",
+ "squizlabs/php_codesniffer": "3.6.2"
},
+ "replace": {
+ "golonka/bbcodeparser": "*"
+ },
+ "minimum-stability": "stable",
"autoload": {
"psr-4": {
"ivuorinen\\BBCode\\": "src/"
}
},
"autoload-dev": {
- "psr-4": { "ivuorinen\\BBCode\\Tests\\": "tests/" },
+ "psr-4": {
+ "ivuorinen\\BBCode\\Tests\\": "tests/"
+ },
"classmap": [
"tests/"
]
},
- "minimum-stability": "stable",
- "replace": {
- "golonka/bbcodeparser": "*"
+ "config": {
+ "allow-plugins": {
+ "ergebnis/composer-normalize": true
+ }
},
"extra": {
"laravel": {
- "providers": [
- "ivuorinen\\BBCode\\BBCodeParserServiceProvider"
- ],
"aliases": {
"BBCode": "ivuorinen\\BBCode\\Facades\\BBCodeParser"
- }
+ },
+ "providers": [
+ "ivuorinen\\BBCode\\BBCodeParserServiceProvider"
+ ]
}
}
}
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..f078883
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ./src
+ ./tests
+
diff --git a/phpunit.xml b/phpunit.xml
index b08155f..b04c787 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,21 +1,13 @@
-
-
-
- ./tests
-
-
-
-
- ./src
-
-
-
\ No newline at end of file
+
+
+
+ ./src
+
+
+
+
+ ./tests
+
+
+
diff --git a/src/BBCodeParser.php b/src/BBCodeParser.php
index f2652a0..eb33383 100644
--- a/src/BBCodeParser.php
+++ b/src/BBCodeParser.php
@@ -107,7 +107,8 @@ class BBCodeParser
],
'youtube' => [
'pattern' => '/\[youtube\](.*?)\[\/youtube\]/s',
- 'replace' => '',
+ 'replace' => '',
'content' => '$1'
],
'linebreak' => [
diff --git a/tests/ArrayTraitHelper.php b/tests/ArrayTraitHelper.php
index dcc3109..7918a42 100644
--- a/tests/ArrayTraitHelper.php
+++ b/tests/ArrayTraitHelper.php
@@ -1,5 +1,7 @@
class = new ArrayTraitHelper();
}
- public function test_array_only()
+ public function testArrayOnly()
{
$this->assertTrue(\method_exists($this->class, 'arrayOnly'));
}
- public function test_array_except()
+ public function testArrayExcept()
{
$this->assertTrue(\method_exists($this->class, 'arrayExcept'));
}
diff --git a/tests/BBCodeParserFacadeTest.php b/tests/BBCodeParserFacadeTest.php
index fc620d7..f93d3a6 100644
--- a/tests/BBCodeParserFacadeTest.php
+++ b/tests/BBCodeParserFacadeTest.php
@@ -1,8 +1,10 @@
callMethod(
diff --git a/tests/BBCodeParserServiceProviderTest.php b/tests/BBCodeParserServiceProviderTest.php
index cfec3e7..456a147 100644
--- a/tests/BBCodeParserServiceProviderTest.php
+++ b/tests/BBCodeParserServiceProviderTest.php
@@ -1,5 +1,7 @@
array(
'bbcode' => 'youtube',
- 'expected_test' => '',
+ 'expected_test' => '',
'values' => ['dQw4w9WgXcQ']
),
'listitem' => array(
@@ -135,14 +138,13 @@ class BBCodeParserTest extends TestCase
['bbcode' => '[I]Result[/i]', 'expected' => 'Result'],
);
- protected function setUp()
+ protected function setUp(): void
{
- parent::setUp();
-
$this->parser = new BBCodeParser();
+ parent::setUp();
}
- public function test_it_has_known_parsers()
+ public function testItHasKnownParsers()
{
$this->assertEquals(
$this->parser->parsers,
@@ -150,7 +152,7 @@ class BBCodeParserTest extends TestCase
);
}
- public function test_parsers_have_required_keys()
+ public function testParsersHaveRequiredKeys()
{
$keys = array('pattern', 'replace', 'content');
$parsers = $this->parser->getParsers();
@@ -166,7 +168,7 @@ class BBCodeParserTest extends TestCase
}
}
- public function test_parser_regexp_is_valid()
+ public function testParserRegexpIsValid()
{
$parsers = $this->parser->getParsers();
foreach ($parsers as $parserName => $parser) {
@@ -179,7 +181,7 @@ class BBCodeParserTest extends TestCase
}
}
- public function test_parser_default()
+ public function testParserDefault()
{
foreach ($this->testedParsers as $name => $options) {
$test = $this->createTest($options, $name);
@@ -189,7 +191,7 @@ class BBCodeParserTest extends TestCase
}
}
- public function test_parser_sensitive()
+ public function testParserSensitive()
{
$testTemp = 'Test: %s / bbcode: %s / Actual: %s / Expected: %s';
@@ -203,7 +205,11 @@ class BBCodeParserTest extends TestCase
$result = $this->parser->parseCaseSensitive($bbcode);
$this->assertEquals($expected, $result, sprintf(
- $testTemp, 'lowercase, sensitive', $bbcode, $result, $expected
+ $testTemp,
+ 'lowercase, sensitive',
+ $bbcode,
+ $result,
+ $expected
));
}
@@ -217,7 +223,11 @@ class BBCodeParserTest extends TestCase
$result = $this->parser->parseCaseSensitive($bbcode);
$this->assertNotEquals($expected, $result, sprintf(
- $testTemp, 'uppercase, sensitive', $bbcode, $result, $expected
+ $testTemp,
+ 'uppercase, sensitive',
+ $bbcode,
+ $result,
+ $expected
));
}
@@ -231,12 +241,16 @@ class BBCodeParserTest extends TestCase
$result = $this->parser->parseCaseSensitive($bbcode);
$this->assertNotEquals($expected, $result, sprintf(
- $testTemp, 'mixed case, sensitive', $bbcode, $result, $expected
+ $testTemp,
+ 'mixed case, sensitive',
+ $bbcode,
+ $result,
+ $expected
));
}
}
- public function test_parser_insensitive()
+ public function testParserInsensitive()
{
/**
* Now we run with insensitive case turned on, so everything
@@ -253,7 +267,8 @@ class BBCodeParserTest extends TestCase
$bbcode = $case['bbcode'];
$expected = $case['expected'];
$this->assertEquals(
- $expected, $this->parser->parse($bbcode, true)
+ $expected,
+ $this->parser->parse($bbcode, true)
);
$this->assertEquals(
@@ -263,7 +278,7 @@ class BBCodeParserTest extends TestCase
}
}
- public function test_stripBBCodeTags()
+ public function testStripBBCodeTags()
{
foreach ($this->mixedCaseTests as $test) {
$this->assertEquals(
@@ -273,7 +288,7 @@ class BBCodeParserTest extends TestCase
}
}
- public function test_only()
+ public function testOnly()
{
$keys = array('bold', 'underline');
@@ -284,7 +299,7 @@ class BBCodeParserTest extends TestCase
$this->assertNotEquals(array_keys($parsers), array_keys($onlyFew));
}
- public function test_except()
+ public function testExcept()
{
$keys = array('bold', 'underline');
@@ -295,7 +310,7 @@ class BBCodeParserTest extends TestCase
$this->assertNotEquals(array_keys($parsers), array_keys($exceptFew));
}
- public function test_adding_a_new_parser()
+ public function testAddingNewParser()
{
$this->parser->setParser('test', 'x', 'y', 'z');
$expected = array('pattern' => 'x', 'replace' => 'y', 'content' => 'z');
@@ -305,7 +320,7 @@ class BBCodeParserTest extends TestCase
$this->assertArraySubset($expected, $parsers['test']);
}
- public function test_we_have_all_parsers_tested()
+ public function testWeHaveAllParsersTested()
{
$parsers = array_keys($this->parser->except($this->skipParsers)->getParsers());
$missing = array();
@@ -336,10 +351,10 @@ class BBCodeParserTest extends TestCase
* rules for automated test generation. Automation ftw.
*
* @param array $options
- * @param $name
+ * @param string $name
* @return array
*/
- public function createTest($options = [], $name)
+ public function createTest($options = [], $name = '')
{
if (!isset($options['bbcode'])) {
$options['bbcode'] = $name;
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 06b69fc..cf7f7e0 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -1,9 +1,16 @@