diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml
new file mode 100644
index 0000000..0e3f6d4
--- /dev/null
+++ b/.github/workflows/php-cs-fixer.yml
@@ -0,0 +1,24 @@
+name: Check & fix styling
+
+on: [push]
+
+jobs:
+ php-cs-fixer:
+ runs-on: ubuntu-latest
+ if: "!contains(github.event.head_commit.message, 'cs-skip')"
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ with:
+ ref: ${{ github.head_ref }}
+
+ - name: Run PHP CS Fixer
+ uses: docker://oskarstark/php-cs-fixer-ga
+ with:
+ args: --config=.php-cs-fixer.php --allow-risky=yes
+
+ - name: Commit changes
+ uses: stefanzweifel/git-auto-commit-action@v4
+ with:
+ commit_message: Fix styling [cs-skip]
\ No newline at end of file
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..d003d36
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,54 @@
+name: Test
+
+on:
+ push:
+ branches:
+ - "master"
+ pull_request:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: true
+ matrix:
+ php: [7.4, 8.0, 8.1]
+
+ name: PHP:${{ matrix.php }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ - name: Setup PHP, with composer
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ tools: composer:v2
+ coverage: xdebug
+
+ - name: Get composer cache directory
+ id: composer-cache
+ run: echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+ - name: Cache composer dependencies
+ uses: actions/cache@v2
+ with:
+ path: ${{ steps.composer-cache.outputs.dir }}
+ key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
+ restore-keys: dependencies-php-${{ matrix.php }}-composer-
+
+ - name: Install Composer dependencies
+ run: |
+ composer install --prefer-dist --no-interaction --no-suggest
+
+ - name: Run Unit tests
+ run: |
+ vendor/bin/phpunit --coverage-clover=tests/logs/clover.xml
+
+ - name: Upload coverage results to Coveralls
+ env:
+ COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ composer global require php-coveralls/php-coveralls "^2.0"
+ coveralls --coverage_clover=tests/logs/clover.xml -v
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 2c1fc0c..a6a6ac4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
/vendor
composer.phar
composer.lock
-.DS_Store
\ No newline at end of file
+.DS_Store
+.php-cs-fixer.cache
\ No newline at end of file
diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php
new file mode 100644
index 0000000..5c61835
--- /dev/null
+++ b/.php-cs-fixer.php
@@ -0,0 +1,160 @@
+ true,
+ 'array_syntax' => ['syntax' => 'short'],
+ 'binary_operator_spaces' => [
+ 'default' => 'single_space',
+ 'operators' => ['=>' => null],
+ ],
+ 'blank_line_after_namespace' => true,
+ 'blank_line_after_opening_tag' => true,
+ 'blank_line_before_statement' => [
+ 'statements' => ['return'],
+ ],
+ 'braces' => true,
+ 'cast_spaces' => true,
+ 'class_attributes_separation' => [
+ 'elements' => [
+ 'const' => 'one',
+ 'method' => 'one',
+ 'property' => 'one',
+ 'trait_import' => 'none',
+ ],
+ ],
+ 'class_definition' => [
+ 'multi_line_extends_each_single_line' => true,
+ 'single_item_single_line' => true,
+ 'single_line' => true,
+ ],
+ 'concat_space' => [
+ 'spacing' => 'none',
+ ],
+ 'constant_case' => ['case' => 'lower'],
+ 'declare_equal_normalize' => true,
+ 'elseif' => true,
+ 'encoding' => true,
+ 'full_opening_tag' => true,
+ 'fully_qualified_strict_types' => true, // added by Shift
+ 'function_declaration' => true,
+ 'function_typehint_space' => true,
+ 'general_phpdoc_tag_rename' => true,
+ 'heredoc_to_nowdoc' => true,
+ 'include' => true,
+ 'increment_style' => ['style' => 'post'],
+ 'indentation_type' => true,
+ 'linebreak_after_opening_tag' => true,
+ 'line_ending' => true,
+ 'lowercase_cast' => true,
+ 'lowercase_keywords' => true,
+ 'lowercase_static_reference' => true, // added from Symfony
+ 'magic_method_casing' => true, // added from Symfony
+ 'magic_constant_casing' => true,
+ 'method_argument_space' => [
+ 'on_multiline' => 'ignore',
+ ],
+ 'multiline_whitespace_before_semicolons' => [
+ 'strategy' => 'no_multi_line',
+ ],
+ 'native_function_casing' => true,
+ 'no_alias_functions' => true,
+ 'no_extra_blank_lines' => [
+ 'tokens' => [
+ 'extra',
+ 'throw',
+ 'use',
+ ],
+ ],
+ 'no_blank_lines_after_class_opening' => true,
+ 'no_blank_lines_after_phpdoc' => true,
+ 'no_closing_tag' => true,
+ 'no_empty_phpdoc' => true,
+ 'no_empty_statement' => true,
+ 'no_leading_import_slash' => true,
+ 'no_leading_namespace_whitespace' => true,
+ 'no_mixed_echo_print' => [
+ 'use' => 'echo',
+ ],
+ 'no_multiline_whitespace_around_double_arrow' => true,
+ 'no_short_bool_cast' => true,
+ 'no_singleline_whitespace_before_semicolons' => true,
+ 'no_spaces_after_function_name' => true,
+ 'no_spaces_around_offset' => [
+ 'positions' => ['inside', 'outside'],
+ ],
+ 'no_spaces_inside_parenthesis' => true,
+ 'no_trailing_comma_in_list_call' => true,
+ 'no_trailing_comma_in_singleline_array' => true,
+ 'no_trailing_whitespace' => true,
+ 'no_trailing_whitespace_in_comment' => true,
+ 'no_unneeded_control_parentheses' => [
+ 'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
+ ],
+ 'no_unreachable_default_argument_value' => true,
+ 'no_useless_return' => true,
+ 'no_whitespace_before_comma_in_array' => true,
+ 'no_whitespace_in_blank_line' => true,
+ 'normalize_index_brace' => true,
+ 'not_operator_with_successor_space' => true,
+ 'object_operator_without_whitespace' => true,
+ 'ordered_imports' => ['sort_algorithm' => 'alpha'],
+ 'psr_autoloading' => true,
+ 'phpdoc_indent' => true,
+ 'phpdoc_inline_tag_normalizer' => true,
+ 'phpdoc_no_access' => true,
+ 'phpdoc_no_package' => true,
+ 'phpdoc_no_useless_inheritdoc' => true,
+ 'phpdoc_scalar' => true,
+ 'phpdoc_single_line_var_spacing' => true,
+ 'phpdoc_summary' => false,
+ 'phpdoc_to_comment' => false, // override to preserve user preference
+ 'phpdoc_tag_type' => true,
+ 'phpdoc_trim' => true,
+ 'phpdoc_types' => true,
+ 'phpdoc_var_without_name' => true,
+ 'self_accessor' => true,
+ 'short_scalar_cast' => true,
+ 'simplified_null_return' => false, // disabled as "risky"
+ 'single_blank_line_at_eof' => true,
+ 'single_blank_line_before_namespace' => true,
+ 'single_class_element_per_statement' => [
+ 'elements' => ['const', 'property'],
+ ],
+ 'single_import_per_statement' => true,
+ 'single_line_after_imports' => true,
+ 'single_line_comment_style' => [
+ 'comment_types' => ['hash'],
+ ],
+ 'single_quote' => true,
+ 'space_after_semicolon' => true,
+ 'standardize_not_equals' => true,
+ 'switch_case_semicolon_to_colon' => true,
+ 'switch_case_space' => true,
+ 'ternary_operator_spaces' => true,
+ 'trailing_comma_in_multiline' => ['elements' => ['arrays']],
+ 'trim_array_spaces' => true,
+ 'unary_operator_spaces' => true,
+ 'visibility_required' => [
+ 'elements' => ['method', 'property'],
+ ],
+ 'whitespace_after_comma_in_array' => true,
+];
+
+$finder = Finder::create()
+ ->in([
+ __DIR__.'/src',
+ __DIR__.'/tests',
+ ])
+ ->name('*.php')
+ ->notName('*.blade.php')
+ ->ignoreDotFiles(true)
+ ->ignoreVCS(true);
+
+return (new Config)
+ ->setFinder($finder)
+ ->setRules($rules)
+ ->setRiskyAllowed(true)
+ ->setUsingCache(true);
diff --git a/.phpunit.result.cache b/.phpunit.result.cache
new file mode 100644
index 0000000..b9debb5
--- /dev/null
+++ b/.phpunit.result.cache
@@ -0,0 +1 @@
+{"version":1,"defects":{"ParseTest::we_can_get_the_attributes_from_all_tags":4},"times":{"ParseTest::no_tags_added":0.006,"ParseTest::we_can_add_a_single_shortcode":0.001,"ParseTest::we_can_add_multiple_shorcodes":0,"ParseTest::tags_with_closing_slash":0,"ParseTest::tags_without_closing_slash":0,"ParseTest::tags_with_closing_slash_and_attributes":0,"ParseTest::tags_without_closing_slash_and_attributes":0,"ParseTest::tags_with_opening_and_closing_tags":0,"ParseTest::attributes_enclosed_in_double_quotes":0,"ParseTest::attributes_enclosed_in_single_quotes":0,"ParseTest::attributes_multiple_attributes":0,"ParseTest::we_can_strip_all_tags":0,"ParseTest::we_can_strip_specified_tag":0,"ParseTest::we_can_get_attributes_for_specified_shortcode":0,"ParseTest::we_can_strip_tags_when_no_tags_specified":0,"ParseTest::we_can_get_the_attributes_from_the_specified_tag":0,"ParseTest::we_can_get_the_attributes_from_all_tags":0.001,"ParseTest::test_we_can_remove_single_shortcode_tag":0,"ParseTest::test_we_can_remove_all_shortcode_tags":0,"ParseTest::shortcode_tags_can_be_escaped":0,"ParseTest::content_with_no_shortcodes":0,"ParseTest::shortcode_with_hyphens":0,"ParseTest::attribute_with_double_quotes":0,"ParseTest::attribute_with_single_quotes":0,"ParseTest::single_positional_attribute":0,"ParseTest::attribute_with_url":0,"ParseTest::mixed_attribute_types":0,"ParseTest::magic_properties_are_gettable":0,"ParseTest::exception_is_thrown_when_accessing_uknown_magic_property":0}}
\ No newline at end of file
diff --git a/.styleci.yml b/.styleci.yml
deleted file mode 100644
index e46be86..0000000
--- a/.styleci.yml
+++ /dev/null
@@ -1,65 +0,0 @@
-preset: none
-enabled:
- - array_element_white_space_after_comma
- - blankline_after_open_tag
- - braces
- - concat_without_spaces
- - double_arrow_multiline_whitespaces
- - duplicate_semicolon
- - elseif
- - empty_return
- - encoding
- - eof_ending
- - function_call_space
- - function_declaration
- - include
- - indentation
- - join_function
- - line_after_namespace
- - linefeed
- - list_commas
- - logical_not_operators_with_successor_space
- - short_array_syntax
- - lowercase_constants
- - lowercase_keywords
- - method_argument_space
- - multiline_array_trailing_comma
- - multiline_spaces_before_semicolon
- - multiple_use
- - namespace_no_leading_whitespace
- - no_blank_lines_after_class_opening
- - no_empty_lines_after_phpdocs
- - no_extra_consecutive_blank_lines
- - object_operator
- - operators_spaces
- - length_ordered_imports
- - parenthesis
- - phpdoc_indent
- - phpdoc_inline_tag
- - phpdoc_no_access
- - phpdoc_no_package
- - phpdoc_scalar
- - phpdoc_short_description
- - phpdoc_to_comment
- - phpdoc_trim
- - phpdoc_type_to_var
- - phpdoc_var_without_name
- - remove_leading_slash_use
- - return
- - self_accessor
- - short_echo_tag
- - short_tag
- - single_array_no_trailing_comma
- - single_blank_line_before_namespace
- - single_line_after_imports
- - single_quote
- - spaces_before_semicolon
- - spaces_cast
- - standardize_not_equal
- - ternary_spaces
- - trailing_spaces
- - trim_array_spaces
- - unalign_equals
- - unary_operators_spaces
- - visibility
- - whitespacy_lines
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 003f1dd..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-language: php
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-matrix:
- include:
- - php: 5.6
- - php: 7.0
- - php: 7.1
- - php: 7.2
- - php: 7.3
- - php: 7.4
- - php: nightly
- allow_failures:
- - php: nightly
- fast_finish: true
-
-before_install:
- - travis_retry composer self-update
-
-install:
- - composer install --no-interaction --prefer-dist --no-suggest
-
-script:
- - ./vendor/bin/phpunit --coverage-clover ./tests/logs/clover.xml
-
-after_script:
- - php vendor/bin/coveralls -v
diff --git a/composer.json b/composer.json
index f2aa7e0..ea0e4be 100644
--- a/composer.json
+++ b/composer.json
@@ -9,8 +9,7 @@
}
],
"require-dev": {
- "phpunit/phpunit": "^4.8|^5.5|^6.5",
- "satooshi/php-coveralls": "1.*"
+ "phpunit/phpunit": "^4.8|^5.5|^6.5|^9.4"
},
"autoload": {
"psr-4": {
diff --git a/src/Shortcode.php b/src/Shortcode.php
index e52b48f..de5a2e8 100644
--- a/src/Shortcode.php
+++ b/src/Shortcode.php
@@ -2,8 +2,6 @@
namespace Jaybizzle\Shortcodes;
-use Jaybizzle\Shortcodes\ShortcodeContract;
-
abstract class Shortcode implements ShortcodeContract
{
/**
diff --git a/src/Shortcodes.php b/src/Shortcodes.php
index 8d63792..81e6c4f 100644
--- a/src/Shortcodes.php
+++ b/src/Shortcodes.php
@@ -48,7 +48,8 @@ public function removeAll()
/**
* Search content for shortcodes and filter shortcodes through their hooks.
*
- * @param string $content
+ * @param string $content
+ *
* @return string
*/
public function parse($content)
@@ -79,6 +80,7 @@ protected function getShortcodeRegex()
* Build the shortcode regex for the specified tags.
*
* @param string $tags
+ *
* @return string
*/
protected function buildShortcodeRegex($tags)
@@ -89,7 +91,8 @@ protected function buildShortcodeRegex($tags)
/**
* Regular Expression callable for doShortcode() for calling shortcode hook.
*
- * @param array $matches
+ * @param array $matches
+ *
* @return string
*/
protected function doShortcodeTag($matches)
@@ -112,7 +115,8 @@ protected function doShortcodeTag($matches)
/**
* Retrieve all attributes from the shortcode tag.
*
- * @param string $text
+ * @param string $text
+ *
* @return array
*/
protected function shortcodeParseAtts($text)
@@ -145,7 +149,8 @@ protected function shortcodeParseAtts($text)
/**
* Remove all shortcode tags from the given content.
*
- * @param string $content
+ * @param string $content
+ *
* @return string
*/
public function stripShortcodes($content)
@@ -162,7 +167,8 @@ public function stripShortcodes($content)
/**
* Remove specified shortcode tag from the given content.
*
- * @param string $content
+ * @param string $content
+ *
* @return string
*/
public function stripShortcode($shortcode, $content)
@@ -170,7 +176,7 @@ public function stripShortcode($shortcode, $content)
if (empty($content)) {
return $content;
}
-
+
$pattern = $this->buildShortcodeRegex(preg_quote($shortcode));
return preg_replace('/'.$pattern.'/s', ' ', $content);
@@ -190,6 +196,7 @@ public function getShortcodes($content)
*
* @param string $shortcode
* @param string $content
+ *
* @return array
*/
public function getShortcode($shortcode, $content)
diff --git a/tests/ParseTest.php b/tests/ParseTest.php
index f357aed..7797009 100644
--- a/tests/ParseTest.php
+++ b/tests/ParseTest.php
@@ -1,177 +1,204 @@
shortcodes = new Shortcodes;
- }
-
/** @test */
public function no_tags_added()
{
+ $shortcodes = new Shortcodes();
+
$this->assertEquals(
'This is some [foo /] content',
- $this->shortcodes->parse('This is some [foo /] content')
+ $shortcodes->parse('This is some [foo /] content')
);
}
/** @test */
public function we_can_add_a_single_shortcode()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
- $this->assertCount(1, $this->shortcodes->shortcodeTags);
+ $this->assertCount(1, $shortcodes->shortcodeTags);
}
/** @test */
public function we_can_add_multiple_shorcodes()
{
- $this->shortcodes->add([
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add([
FooShortcode::class,
BarShortcode::class,
]);
- $this->assertCount(2, $this->shortcodes->shortcodeTags);
+ $this->assertCount(2, $shortcodes->shortcodeTags);
}
/** @test */
public function tags_with_closing_slash()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo /] content')
+ $shortcodes->parse('This is some [foo /] content')
);
}
/** @test */
public function tags_without_closing_slash()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo] content')
+ $shortcodes->parse('This is some [foo] content')
);
}
/** @test */
public function tags_with_closing_slash_and_attributes()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo bar=baz /] content')
+ $shortcodes->parse('This is some [foo bar=baz /] content')
);
}
/** @test */
public function tags_without_closing_slash_and_attributes()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo bar=baz] content')
+ $shortcodes->parse('This is some [foo bar=baz] content')
);
}
/** @test */
public function tags_with_opening_and_closing_tags()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some bar baz content',
- $this->shortcodes->parse('This is some [foo]bar baz[/foo] content')
+ $shortcodes->parse('This is some [foo]bar baz[/foo] content')
);
}
/** @test */
public function attributes_enclosed_in_double_quotes()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo bar="baz"] content')
+ $shortcodes->parse('This is some [foo bar="baz"] content')
);
}
/** @test */
public function attributes_enclosed_in_single_quotes()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo bar=\'baz\'] content')
+ $shortcodes->parse('This is some [foo bar=\'baz\'] content')
);
}
/** @test */
public function attributes_multiple_attributes()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo bar=baz qux=foo] content')
+ $shortcodes->parse('This is some [foo bar=baz qux=foo] content')
);
}
/** @test */
public function we_can_strip_all_tags()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->stripShortcodes('This is some [foo bar=baz qux=foo] content')
+ $shortcodes->stripShortcodes('This is some [foo bar=baz qux=foo] content')
);
}
/** @test */
public function we_can_strip_specified_tag()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some [bar bar=baz qux=foo] content',
- $this->shortcodes->stripShortcode('foo', 'This is some [foo bar=baz qux=foo] [bar bar=baz qux=foo] content')
+ $shortcodes->stripShortcode('foo', 'This is some [foo bar=baz qux=foo] [bar bar=baz qux=foo] content')
);
}
/** @test */
public function we_can_get_attributes_for_specified_shortcode()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
[],
- $this->shortcodes->getShortcode('foo', 'This is some [bar bar=baz qux=foo] content')
+ $shortcodes->getShortcode('foo', 'This is some [bar bar=baz qux=foo] content')
);
}
/** @test */
public function we_can_strip_tags_when_no_tags_specified()
{
+ $shortcodes = new Shortcodes();
+
$this->assertEquals(
'This is some [foo bar=baz qux=foo] content',
- $this->shortcodes->stripShortcodes('This is some [foo bar=baz qux=foo] content')
+ $shortcodes->stripShortcodes('This is some [foo bar=baz qux=foo] content')
);
}
/** @test */
public function we_can_get_the_attributes_from_the_specified_tag()
{
+ $shortcodes = new Shortcodes();
+
$expected = [[
'bar' => 'baz',
'qux' => 'foo',
@@ -179,15 +206,17 @@ public function we_can_get_the_attributes_from_the_specified_tag()
$this->assertEquals(
$expected,
- $this->shortcodes->getShortcode('foo', 'This is some [foo bar=baz qux=foo] [bar bar=baz qux=foo] content')
+ $shortcodes->getShortcode('foo', 'This is some [foo bar=baz qux=foo] [bar bar=baz qux=foo] content')
);
}
/** @test */
public function we_can_get_the_attributes_from_all_tags()
{
- $this->shortcodes->add(FooShortcode::class);
- $this->shortcodes->add(BarShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
+ $shortcodes->add(BarShortcode::class);
$expected = [
'foo' => [[
@@ -205,131 +234,155 @@ public function we_can_get_the_attributes_from_all_tags()
$this->assertEquals(
$expected,
- $this->shortcodes->getShortcodes('This is some [foo bar=baz qux=foo] [foo bar=baz qux=foo] [bar bar=baz qux=foo] content')
+ $shortcodes->getShortcodes('This is some [foo bar=baz qux=foo] [foo bar=baz qux=foo] [bar bar=baz qux=foo] content')
);
}
/** @test */
public function test_we_can_remove_single_shortcode_tag()
{
- $this->shortcodes->add(FooShortcode::class);
- $this->shortcodes->add(BarShortcode::class);
+ $shortcodes = new Shortcodes();
- $this->shortcodes->remove('foo');
+ $shortcodes->add(FooShortcode::class);
+ $shortcodes->add(BarShortcode::class);
- $this->assertCount(1, $this->shortcodes->shortcodeTags);
+ $shortcodes->remove('foo');
+
+ $this->assertCount(1, $shortcodes->shortcodeTags);
}
/** @test */
public function test_we_can_remove_all_shortcode_tags()
{
- $this->shortcodes->add(FooShortcode::class);
- $this->shortcodes->add(BarShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
+ $shortcodes->add(BarShortcode::class);
- $this->shortcodes->removeAll('foo');
+ $shortcodes->removeAll('foo');
- $this->assertCount(0, $this->shortcodes->shortcodeTags);
+ $this->assertCount(0, $shortcodes->shortcodeTags);
}
/** @test */
public function shortcode_tags_can_be_escaped()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some [foo bar=baz] content',
- $this->shortcodes->parse('This is some [[foo bar=baz]] content')
+ $shortcodes->parse('This is some [[foo bar=baz]] content')
);
}
/** @test */
public function content_with_no_shortcodes()
{
+ $shortcodes = new Shortcodes();
+
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some content')
+ $shortcodes->parse('This is some content')
);
}
/** @test */
public function shortcode_with_hyphens()
{
- $this->shortcodes->add(BazShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(BazShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo-bar] content')
+ $shortcodes->parse('This is some [foo-bar] content')
);
}
/** @test */
public function attribute_with_double_quotes()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo bar="baz"] content')
+ $shortcodes->parse('This is some [foo bar="baz"] content')
);
}
/** @test */
public function attribute_with_single_quotes()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo bar=\'baz\'] content')
+ $shortcodes->parse('This is some [foo bar=\'baz\'] content')
);
}
/** @test */
public function single_positional_attribute()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo 123] content')
+ $shortcodes->parse('This is some [foo 123] content')
);
}
/** @test */
public function attribute_with_url()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo url=http://www.foo.com/bar] content')
+ $shortcodes->parse('This is some [foo url=http://www.foo.com/bar] content')
);
}
/** @test */
public function mixed_attribute_types()
{
- $this->shortcodes->add(FooShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(FooShortcode::class);
$this->assertEquals(
'This is some content',
- $this->shortcodes->parse('This is some [foo 123 http://foo.com/ 0 "foo" bar] content')
+ $shortcodes->parse('This is some [foo 123 http://foo.com/ 0 "foo" bar] content')
);
}
/** @test */
public function magic_properties_are_gettable()
{
- $this->shortcodes->add(QuxShortcode::class);
+ $shortcodes = new Shortcodes();
- $this->shortcodes->parse('This is some [qux foo=bar]');
+ $shortcodes->add(QuxShortcode::class);
+
+ $shortcodes->parse('This is some [qux foo=bar]');
$this->addToAssertionCount(1);
}
/** @test */
public function exception_is_thrown_when_accessing_uknown_magic_property()
{
- $this->shortcodes->add(BazQuxShortcode::class);
+ $shortcodes = new Shortcodes();
+
+ $shortcodes->add(BazQuxShortcode::class);
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$this->expectException(\Exception::class);
@@ -337,7 +390,7 @@ public function exception_is_thrown_when_accessing_uknown_magic_property()
$this->setExpectedException(\Exception::class);
}
- $this->shortcodes->parse('This is some [qux foo=bar]');
+ $shortcodes->parse('This is some [qux foo=bar]');
}
}