diff --git a/tests/HooksActionTest.php b/tests/HooksActionTest.php index e71d38d..9230f28 100644 --- a/tests/HooksActionTest.php +++ b/tests/HooksActionTest.php @@ -20,9 +20,12 @@ public function testAction() { $done = false; - $this->hooks->add_action('bar', function () use (&$done) { - $done = true; - }); + $this->hooks->add_action( + 'bar', + function () use (&$done) { + $done = true; + } + ); $this->hooks->do_action('bar'); diff --git a/tests/HooksFilterTest.php b/tests/HooksFilterTest.php index 7073f93..f327635 100644 --- a/tests/HooksFilterTest.php +++ b/tests/HooksFilterTest.php @@ -18,9 +18,11 @@ class HooksFilterTest extends \PHPUnit\Framework\TestCase */ public function testFilter() { - $this->hooks->add_filter('foo', function ($content) { - return '' . $content . ''; - }); + $this->hooks->add_filter( + 'foo', function ($content) { + return '' . $content . ''; + } + ); self::assertSame('Hello world', $this->hooks->apply_filters('foo', 'Hello world')); } diff --git a/tests/HooksFooBar.php b/tests/HooksFooBar.php index 87e6e97..1cb5904 100644 --- a/tests/HooksFooBar.php +++ b/tests/HooksFooBar.php @@ -20,9 +20,9 @@ public function doSomethingFunction($attrs, $content = '') extract( \voku\helper\Hooks::getInstance()->shortcode_atts( - array( + [ 'foo', - ), + ], $attrs ), EXTR_OVERWRITE diff --git a/tests/HooksShortcodeStrictTest.php b/tests/HooksShortcodeStrictTest.php index 3558a1e..f5451a7 100644 --- a/tests/HooksShortcodeStrictTest.php +++ b/tests/HooksShortcodeStrictTest.php @@ -37,7 +37,7 @@ public function parse_youtube($attrs) extract( $hooks->shortcode_atts( - array( + [ 'autoplay', 'noControls', 'list' => null, @@ -47,7 +47,7 @@ public function parse_youtube($attrs) 'color' => 'red', 'theme' => 'dark', 'start' => 0, - ), + ], $attrs ), EXTR_OVERWRITE @@ -75,7 +75,7 @@ public function parse_youtube($attrs) public function testShortcode() { $hooks = Hooks::getInstance(); - $hooks->add_shortcode('youtube', array($this, 'parse_youtube')); + $hooks->add_shortcode('youtube', [$this, 'parse_youtube']); $default_content = '[youtube id=iCUV3iv9xOs color=white theme=light]'; $parsed_content = $hooks->do_shortcode($default_content); diff --git a/tests/HooksShortcodeTest.php b/tests/HooksShortcodeTest.php index db697d6..e60dec4 100644 --- a/tests/HooksShortcodeTest.php +++ b/tests/HooksShortcodeTest.php @@ -35,7 +35,7 @@ public function parse_youtube($attrs) extract( $hooks->shortcode_atts( - array( + [ 'autoplay', 'noControls', 'list' => null, @@ -45,7 +45,7 @@ public function parse_youtube($attrs) 'color' => 'red', 'theme' => 'dark', 'start' => 0, - ), + ], $attrs ), EXTR_OVERWRITE @@ -73,7 +73,7 @@ public function parse_youtube($attrs) public function testShortcode() { $hooks = Hooks::getInstance(); - $hooks->add_shortcode('youtube', array($this, 'parse_youtube')); + $hooks->add_shortcode('youtube', [$this, 'parse_youtube']); $default_content = '[youtube id=iCUV3iv9xOs color=white theme=light]'; $parsed_content = $hooks->do_shortcode($default_content); diff --git a/tests/HooksStrictTest.php b/tests/HooksStrictTest.php index 83ea70c..415d47b 100644 --- a/tests/HooksStrictTest.php +++ b/tests/HooksStrictTest.php @@ -50,8 +50,8 @@ public function hookTestString_2($input) */ public function testHooks() { - $this->hooks->add_filter('test_strict', array($this, 'hookTestString_1')); - $this->hooks->add_filter('test_strict', array($this, 'hookTestString_2')); + $this->hooks->add_filter('test_strict', [$this, 'hookTestString_1']); + $this->hooks->add_filter('test_strict', [$this, 'hookTestString_2']); $lall = $this->hooks->apply_filters('test_strict', ''); @@ -67,7 +67,7 @@ public function testHooksInstance() { $lall = $this->hooks->apply_filters('test_strict', ''); - self::assertSame($this->testString_1 . $this->testString_2, $lall, ); + self::assertSame($this->testString_1 . $this->testString_2, $lall); } public function testHasFunctions() @@ -163,34 +163,34 @@ public function testRunHookFunctions() self::assertSame(true, $hooks->remove_all_actions('testAction')); self::assertSame(false, $hooks->do_action('testAction')); - self::assertSame(false, $hooks->do_action_ref_array('testNotExistingAction', array())); + self::assertSame(false, $hooks->do_action_ref_array('testNotExistingAction', [])); self::assertSame('Foo', $hooks->apply_filters('testFilter', 'Foo')); - self::assertSame(false, $hooks->do_action_ref_array('testAction', array('test'))); - self::assertSame('Foo', $hooks->apply_filters_ref_array('testFilter', array('Foo'))); + self::assertSame(false, $hooks->do_action_ref_array('testAction', ['test'])); + self::assertSame('Foo', $hooks->apply_filters_ref_array('testFilter', ['Foo'])); - $mock = $this->getMockBuilder('stdClass')->setMethods( array('doSomeAction', 'applySomeFilter'))->getMock(); + $mock = $this->getMockBuilder('stdClass')->setMethods(['doSomeAction', 'applySomeFilter'])->getMock(); $mock->expects(self::exactly(4))->method('doSomeAction'); $mock->expects(self::exactly(10))->method('applySomeFilter')->willReturn('foo'); - self::assertSame(true, $hooks->add_action('testAction', array($mock, 'doSomeAction'))); - self::assertSame(true, $hooks->add_filter('testFilter', array($mock, 'applySomeFilter'))); + self::assertSame(true, $hooks->add_action('testAction', [$mock, 'doSomeAction'])); + self::assertSame(true, $hooks->add_filter('testFilter', [$mock, 'applySomeFilter'])); self::assertSame(2, $hooks->did_action('testAction')); self::assertSame(true, $hooks->do_action('testAction')); self::assertSame(3, $hooks->did_action('testAction')); self::assertSame('foo', $hooks->apply_filters('testFilter', 'Foo')); - self::assertSame(true, $hooks->add_filter('all', array($mock, 'applySomeFilter'))); + self::assertSame(true, $hooks->add_filter('all', [$mock, 'applySomeFilter'])); self::assertSame(false, $hooks->do_action('notExistingAction')); self::assertSame('Foo', $hooks->apply_filters('notExistingFilter', 'Foo')); // unmodified value - self::assertSame(true, $hooks->do_action('testAction', (object)array('foo' => 'bar'))); + self::assertSame(true, $hooks->do_action('testAction', (object)['foo' => 'bar'])); self::assertSame(true, $hooks->do_action('testAction', 'param1', 'param2', 'param3', 'param4')); - self::assertSame(true, $hooks->do_action_ref_array('testAction', array('test'))); + self::assertSame(true, $hooks->do_action_ref_array('testAction', ['test'])); self::assertSame('foo', $hooks->apply_filters('testFilter', 'Foo')); - self::assertSame('foo', $hooks->apply_filters_ref_array('testFilter', array('Foo'))); + self::assertSame('foo', $hooks->apply_filters_ref_array('testFilter', ['Foo'])); } public function testRunShortcodeFunctions() @@ -204,7 +204,7 @@ public function testRunShortcodeFunctions() self::assertSame('testAction', $hooks->do_shortcode('testAction')); $testClass = new HooksFooBar(); - self::assertSame(true, $hooks->add_shortcode('testAction', array($testClass, 'doSomethingFunction'))); + self::assertSame(true, $hooks->add_shortcode('testAction', [$testClass, 'doSomethingFunction'])); self::assertTrue($hooks->shortcode_exists('testAction')); self::assertSame('foo bar