mirror of
https://github.com/ivuorinen/bbcodeparser.git
synced 2026-01-26 11:23:58 +00:00
29
.github/workflows/composer-diff.yml
vendored
Normal file
29
.github/workflows/composer-diff.yml
vendored
Normal file
@@ -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: |
|
||||||
|
<details>
|
||||||
|
<summary>Composer package changes</summary>
|
||||||
|
|
||||||
|
${{ steps.composer_diff.outputs.composer_diff }}
|
||||||
|
|
||||||
|
</details>
|
||||||
49
.github/workflows/php.yml
vendored
Normal file
49
.github/workflows/php.yml
vendored
Normal file
@@ -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
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
/vendor
|
/vendor
|
||||||
composer.lock
|
composer.lock
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
language: php
|
language: php
|
||||||
php:
|
php:
|
||||||
- 7.0
|
- 7.3
|
||||||
- 7.1
|
- 7.4
|
||||||
- 7.2
|
- 8.0
|
||||||
|
- 8.1
|
||||||
- nightly
|
- nightly
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "ivuorinen/bbcodeparser",
|
"name": "ivuorinen/bbcodeparser",
|
||||||
"description": "Parse your BBCode easy with this library.",
|
"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",
|
"license": "MIT",
|
||||||
"support": {
|
"type": "library",
|
||||||
"issues": "https://github.com/ivuorinen/bbcodeparser/issues"
|
"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": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -20,37 +28,50 @@
|
|||||||
"homepage": "https://github.com/golonka/"
|
"homepage": "https://github.com/golonka/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"homepage": "https://github.com/ivuorinen/bbcodeparser",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/ivuorinen/bbcodeparser/issues"
|
||||||
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7"
|
"php": ">=7.4 || ^8.0 || ^8.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "5.7.27",
|
"dms/phpunit-arraysubset-asserts": "v0.3.1",
|
||||||
"squizlabs/php_codesniffer": "2.9.2",
|
"ergebnis/composer-normalize": "2.23.1",
|
||||||
"orchestra/testbench": "3.9.4"
|
"orchestra/testbench": "v6.24.1",
|
||||||
|
"phpunit/phpunit": "9.5.13",
|
||||||
|
"squizlabs/php_codesniffer": "3.6.2"
|
||||||
},
|
},
|
||||||
|
"replace": {
|
||||||
|
"golonka/bbcodeparser": "*"
|
||||||
|
},
|
||||||
|
"minimum-stability": "stable",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"ivuorinen\\BBCode\\": "src/"
|
"ivuorinen\\BBCode\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": { "ivuorinen\\BBCode\\Tests\\": "tests/" },
|
"psr-4": {
|
||||||
|
"ivuorinen\\BBCode\\Tests\\": "tests/"
|
||||||
|
},
|
||||||
"classmap": [
|
"classmap": [
|
||||||
"tests/"
|
"tests/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"minimum-stability": "stable",
|
"config": {
|
||||||
"replace": {
|
"allow-plugins": {
|
||||||
"golonka/bbcodeparser": "*"
|
"ergebnis/composer-normalize": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"laravel": {
|
"laravel": {
|
||||||
"providers": [
|
|
||||||
"ivuorinen\\BBCode\\BBCodeParserServiceProvider"
|
|
||||||
],
|
|
||||||
"aliases": {
|
"aliases": {
|
||||||
"BBCode": "ivuorinen\\BBCode\\Facades\\BBCodeParser"
|
"BBCode": "ivuorinen\\BBCode\\Facades\\BBCodeParser"
|
||||||
}
|
},
|
||||||
|
"providers": [
|
||||||
|
"ivuorinen\\BBCode\\BBCodeParserServiceProvider"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
phpcs.xml
Normal file
16
phpcs.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="Basic Project Coding Standards">
|
||||||
|
<rule ref="PSR2" />
|
||||||
|
|
||||||
|
<rule ref="Generic.CodeAnalysis.EmptyStatement" />
|
||||||
|
<rule ref="Generic.Classes.DuplicateClassName"/>
|
||||||
|
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
|
||||||
|
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
|
||||||
|
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
|
||||||
|
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
|
||||||
|
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
|
||||||
|
<rule ref="Squiz.PHP.NonExecutableCode"/>
|
||||||
|
|
||||||
|
<file>./src</file>
|
||||||
|
<file>./tests</file>
|
||||||
|
</ruleset>
|
||||||
32
phpunit.xml
32
phpunit.xml
@@ -1,21 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit backupGlobals="false"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||||
backupStaticAttributes="false"
|
<coverage processUncoveredFiles="true">
|
||||||
bootstrap="vendor/autoload.php"
|
<include>
|
||||||
colors="true"
|
<directory suffix=".php">./src</directory>
|
||||||
convertErrorsToExceptions="true"
|
</include>
|
||||||
convertNoticesToExceptions="true"
|
</coverage>
|
||||||
convertWarningsToExceptions="true"
|
<testsuites>
|
||||||
processIsolation="false"
|
<testsuite name="Tests">
|
||||||
stopOnFailure="false">
|
<directory suffix="Test.php">./tests</directory>
|
||||||
<testsuites>
|
</testsuite>
|
||||||
<testsuite name="Tests">
|
</testsuites>
|
||||||
<directory suffix="Test.php">./tests</directory>
|
</phpunit>
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
<filter>
|
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
|
||||||
<directory suffix=".php">./src</directory>
|
|
||||||
</whitelist>
|
|
||||||
</filter>
|
|
||||||
</phpunit>
|
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ class BBCodeParser
|
|||||||
],
|
],
|
||||||
'youtube' => [
|
'youtube' => [
|
||||||
'pattern' => '/\[youtube\](.*?)\[\/youtube\]/s',
|
'pattern' => '/\[youtube\](.*?)\[\/youtube\]/s',
|
||||||
'replace' => '<iframe width="560" height="315" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>',
|
'replace' => '<iframe width="560" height="315" src="//www.youtube.com/embed/$1"' .
|
||||||
|
' frameborder="0" allowfullscreen></iframe>',
|
||||||
'content' => '$1'
|
'content' => '$1'
|
||||||
],
|
],
|
||||||
'linebreak' => [
|
'linebreak' => [
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace ivuorinen\BBCode\Tests;
|
||||||
|
|
||||||
use ivuorinen\BBCode\Traits\ArrayTrait;
|
use ivuorinen\BBCode\Traits\ArrayTrait;
|
||||||
|
|
||||||
class ArrayTraitHelper
|
class ArrayTraitHelper
|
||||||
|
|||||||
@@ -2,24 +2,21 @@
|
|||||||
|
|
||||||
namespace ivuorinen\BBCode\Tests;
|
namespace ivuorinen\BBCode\Tests;
|
||||||
|
|
||||||
use ArrayTraitHelper;
|
|
||||||
use TestCase;
|
|
||||||
|
|
||||||
class ArrayTraitTest extends TestCase
|
class ArrayTraitTest extends TestCase
|
||||||
{
|
{
|
||||||
private $class;
|
private $class;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->class = new ArrayTraitHelper();
|
$this->class = new ArrayTraitHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_array_only()
|
public function testArrayOnly()
|
||||||
{
|
{
|
||||||
$this->assertTrue(\method_exists($this->class, 'arrayOnly'));
|
$this->assertTrue(\method_exists($this->class, 'arrayOnly'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_array_except()
|
public function testArrayExcept()
|
||||||
{
|
{
|
||||||
$this->assertTrue(\method_exists($this->class, 'arrayExcept'));
|
$this->assertTrue(\method_exists($this->class, 'arrayExcept'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace ivuorinen\BBCode\Tests;
|
||||||
|
|
||||||
class BBCodeParserFacadeTest extends TestCase
|
class BBCodeParserFacadeTest extends TestCase
|
||||||
{
|
{
|
||||||
public function test_facade_exists_and_has_bbcode()
|
public function testFacadeExistsAndHasBbcode()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$method = $this->callMethod(
|
$method = $this->callMethod(
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace ivuorinen\BBCode\Tests;
|
||||||
|
|
||||||
use ivuorinen\BBCode\BBCodeParserServiceProvider;
|
use ivuorinen\BBCode\BBCodeParserServiceProvider;
|
||||||
|
|
||||||
class BBCodeParserServiceProviderTest extends TestCase
|
class BBCodeParserServiceProviderTest extends TestCase
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace ivuorinen\BBCode\Tests;
|
||||||
|
|
||||||
use ivuorinen\BBCode\BBCodeParser;
|
use ivuorinen\BBCode\BBCodeParser;
|
||||||
|
|
||||||
class BBCodeParserTest extends TestCase
|
class BBCodeParserTest extends TestCase
|
||||||
@@ -93,7 +95,8 @@ class BBCodeParserTest extends TestCase
|
|||||||
),
|
),
|
||||||
'youtube' => array(
|
'youtube' => array(
|
||||||
'bbcode' => 'youtube',
|
'bbcode' => 'youtube',
|
||||||
'expected_test' => '<iframe width="560" height="315" src="//www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>',
|
'expected_test' => '<iframe width="560" height="315" src="//www.youtube.com/embed/%s"' .
|
||||||
|
' frameborder="0" allowfullscreen></iframe>',
|
||||||
'values' => ['dQw4w9WgXcQ']
|
'values' => ['dQw4w9WgXcQ']
|
||||||
),
|
),
|
||||||
'listitem' => array(
|
'listitem' => array(
|
||||||
@@ -135,14 +138,13 @@ class BBCodeParserTest extends TestCase
|
|||||||
['bbcode' => '[I]Result[/i]', 'expected' => '<em>Result</em>'],
|
['bbcode' => '[I]Result[/i]', 'expected' => '<em>Result</em>'],
|
||||||
);
|
);
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->parser = new BBCodeParser();
|
$this->parser = new BBCodeParser();
|
||||||
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_it_has_known_parsers()
|
public function testItHasKnownParsers()
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->parser->parsers,
|
$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');
|
$keys = array('pattern', 'replace', 'content');
|
||||||
$parsers = $this->parser->getParsers();
|
$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();
|
$parsers = $this->parser->getParsers();
|
||||||
foreach ($parsers as $parserName => $parser) {
|
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) {
|
foreach ($this->testedParsers as $name => $options) {
|
||||||
$test = $this->createTest($options, $name);
|
$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';
|
$testTemp = 'Test: %s / bbcode: %s / Actual: %s / Expected: %s';
|
||||||
|
|
||||||
@@ -203,7 +205,11 @@ class BBCodeParserTest extends TestCase
|
|||||||
|
|
||||||
$result = $this->parser->parseCaseSensitive($bbcode);
|
$result = $this->parser->parseCaseSensitive($bbcode);
|
||||||
$this->assertEquals($expected, $result, sprintf(
|
$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);
|
$result = $this->parser->parseCaseSensitive($bbcode);
|
||||||
$this->assertNotEquals($expected, $result, sprintf(
|
$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);
|
$result = $this->parser->parseCaseSensitive($bbcode);
|
||||||
$this->assertNotEquals($expected, $result, sprintf(
|
$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
|
* Now we run with insensitive case turned on, so everything
|
||||||
@@ -253,7 +267,8 @@ class BBCodeParserTest extends TestCase
|
|||||||
$bbcode = $case['bbcode'];
|
$bbcode = $case['bbcode'];
|
||||||
$expected = $case['expected'];
|
$expected = $case['expected'];
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected, $this->parser->parse($bbcode, true)
|
$expected,
|
||||||
|
$this->parser->parse($bbcode, true)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@@ -263,7 +278,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_stripBBCodeTags()
|
public function testStripBBCodeTags()
|
||||||
{
|
{
|
||||||
foreach ($this->mixedCaseTests as $test) {
|
foreach ($this->mixedCaseTests as $test) {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@@ -273,7 +288,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_only()
|
public function testOnly()
|
||||||
{
|
{
|
||||||
$keys = array('bold', 'underline');
|
$keys = array('bold', 'underline');
|
||||||
|
|
||||||
@@ -284,7 +299,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
$this->assertNotEquals(array_keys($parsers), array_keys($onlyFew));
|
$this->assertNotEquals(array_keys($parsers), array_keys($onlyFew));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_except()
|
public function testExcept()
|
||||||
{
|
{
|
||||||
$keys = array('bold', 'underline');
|
$keys = array('bold', 'underline');
|
||||||
|
|
||||||
@@ -295,7 +310,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
$this->assertNotEquals(array_keys($parsers), array_keys($exceptFew));
|
$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');
|
$this->parser->setParser('test', 'x', 'y', 'z');
|
||||||
$expected = array('pattern' => 'x', 'replace' => 'y', 'content' => 'z');
|
$expected = array('pattern' => 'x', 'replace' => 'y', 'content' => 'z');
|
||||||
@@ -305,7 +320,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
$this->assertArraySubset($expected, $parsers['test']);
|
$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());
|
$parsers = array_keys($this->parser->except($this->skipParsers)->getParsers());
|
||||||
$missing = array();
|
$missing = array();
|
||||||
@@ -336,10 +351,10 @@ class BBCodeParserTest extends TestCase
|
|||||||
* rules for automated test generation. Automation ftw.
|
* rules for automated test generation. Automation ftw.
|
||||||
*
|
*
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @param $name
|
* @param string $name
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function createTest($options = [], $name)
|
public function createTest($options = [], $name = '')
|
||||||
{
|
{
|
||||||
if (!isset($options['bbcode'])) {
|
if (!isset($options['bbcode'])) {
|
||||||
$options['bbcode'] = $name;
|
$options['bbcode'] = $name;
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TestCase extends Orchestra\Testbench\TestCase
|
namespace ivuorinen\BBCode\Tests;
|
||||||
|
|
||||||
|
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
|
||||||
|
|
||||||
|
class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
{
|
{
|
||||||
|
use ArraySubsetAsserts;
|
||||||
|
|
||||||
protected function getPackageProviders($app)
|
protected function getPackageProviders($app)
|
||||||
{
|
{
|
||||||
|
unset($app);
|
||||||
return ['ivuorinen\BBCode\BBCodeParserServiceProvider'];
|
return ['ivuorinen\BBCode\BBCodeParserServiceProvider'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user