diff --git a/composer.json b/composer.json index f7076de..aa9792f 100644 --- a/composer.json +++ b/composer.json @@ -27,11 +27,10 @@ "php": "^8.1" }, "require-dev": { - "dms/phpunit-arraysubset-asserts": "0.4.0", - "ergebnis/composer-normalize": "2.30.2", - "orchestra/testbench": "8.0.5", - "phpunit/phpunit": "10.0.14", - "squizlabs/php_codesniffer": "3.7.2" + "ergebnis/composer-normalize": "^2.30", + "orchestra/testbench": "^8", + "phpunit/phpunit": "^10", + "squizlabs/php_codesniffer": "^3" }, "replace": { "golonka/bbcodeparser": "*" diff --git a/phpunit.xml b/phpunit.xml index 7c72e8c..06b0fa5 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,17 +1,13 @@ - - - - ./src - - - - - ./tests - - + + + + ./src + + + + + ./tests + + diff --git a/tests/ArrayTraitHelper.php b/tests/ArrayTraitHelper.php index 7918a42..9610572 100644 --- a/tests/ArrayTraitHelper.php +++ b/tests/ArrayTraitHelper.php @@ -14,7 +14,7 @@ class ArrayTraitHelper * @see \ivuorinen\BBCode\Traits\ArrayTrait::arrayOnly * @return array */ - public function publicArrayOnly(array $parsers, $only) + public function publicArrayOnly(array $parsers, $only): array { return $this->arrayOnly($parsers, $only); } @@ -25,7 +25,7 @@ class ArrayTraitHelper * @see \ivuorinen\BBCode\Traits\ArrayTrait::arrayExcept * @return array */ - public function publicArrayExcept(array $parsers, $except) + public function publicArrayExcept(array $parsers, $except): array { return $this->arrayExcept($parsers, $except); } diff --git a/tests/ArrayTraitTest.php b/tests/ArrayTraitTest.php index 0fbc2b7..1c5bce1 100644 --- a/tests/ArrayTraitTest.php +++ b/tests/ArrayTraitTest.php @@ -11,12 +11,12 @@ class ArrayTraitTest extends TestCase $this->class = new ArrayTraitHelper(); } - public function testArrayOnly() + public function testArrayOnly(): void { $this->assertTrue(\method_exists($this->class, 'arrayOnly')); } - public function testArrayExcept() + public function testArrayExcept(): void { $this->assertTrue(\method_exists($this->class, 'arrayExcept')); } diff --git a/tests/BBCodeParserFacadeTest.php b/tests/BBCodeParserFacadeTest.php index f93d3a6..905255a 100644 --- a/tests/BBCodeParserFacadeTest.php +++ b/tests/BBCodeParserFacadeTest.php @@ -4,7 +4,7 @@ namespace ivuorinen\BBCode\Tests; class BBCodeParserFacadeTest extends TestCase { - public function testFacadeExistsAndHasBbcode() + public function testFacadeExistsAndHasBbcode(): void { try { $method = $this->callMethod( @@ -13,7 +13,7 @@ class BBCodeParserFacadeTest extends TestCase [] ); $this->assertEquals('bbcode', $method); - } catch (ReflectionException $e) { + } catch (\ReflectionException $e) { $this->throwException($e); } } @@ -23,7 +23,7 @@ class BBCodeParserFacadeTest extends TestCase * @param $name * @param array $args * @return mixed - * @throws ReflectionException + * @throws \ReflectionException */ public static function callMethod($obj, $name, array $args) { diff --git a/tests/BBCodeParserServiceProviderTest.php b/tests/BBCodeParserServiceProviderTest.php index 456a147..1d023e5 100644 --- a/tests/BBCodeParserServiceProviderTest.php +++ b/tests/BBCodeParserServiceProviderTest.php @@ -6,13 +6,13 @@ use ivuorinen\BBCode\BBCodeParserServiceProvider; class BBCodeParserServiceProviderTest extends TestCase { - public function testProvides() + public function testProvides(): void { $provider = new BBCodeParserServiceProvider($this->app); $this->assertEquals(['bbcode'], $provider->provides()); } - public function testRegister() + public function testRegister(): void { $this->assertInstanceOf( \ivuorinen\BBCode\BBCodeParser::class, diff --git a/tests/BBCodeParserTest.php b/tests/BBCodeParserTest.php index b20a20c..0baee23 100644 --- a/tests/BBCodeParserTest.php +++ b/tests/BBCodeParserTest.php @@ -96,7 +96,7 @@ class BBCodeParserTest extends TestCase 'youtube' => array( 'bbcode' => 'youtube', 'expected_test' => '', + ' frameborder="0" allowfullscreen>', 'values' => ['dQw4w9WgXcQ'] ), 'listitem' => array( @@ -144,7 +144,7 @@ class BBCodeParserTest extends TestCase parent::setUp(); } - public function testItHasKnownParsers() + public function testItHasKnownParsers(): void { $this->assertEquals( $this->parser->parsers, @@ -152,23 +152,22 @@ class BBCodeParserTest extends TestCase ); } - public function testParsersHaveRequiredKeys() + public function testParsersHaveRequiredKeys(): void { - $keys = array('pattern', 'replace', 'content'); + $keys = ['pattern', 'replace', 'content']; $parsers = $this->parser->getParsers(); foreach ($parsers as $parserName => $parser) { foreach ($keys as $key) { - $this->assertArrayHasKey( - $key, - $parser, + $this->assertTrue( + array_key_exists($key, $parser), sprintf('Parser: %s, Key: %s', $parserName, $key) ); } } } - public function testParserRegexpIsValid() + public function testParserRegexpIsValid(): void { $parsers = $this->parser->getParsers(); foreach ($parsers as $parserName => $parser) { @@ -181,7 +180,7 @@ class BBCodeParserTest extends TestCase } } - public function testParserDefault() + public function testParserDefault(): void { foreach ($this->testedParsers as $name => $options) { $test = $this->createTest($options, $name); @@ -191,7 +190,7 @@ class BBCodeParserTest extends TestCase } } - public function testParserSensitive() + public function testParserSensitive(): void { $testTemp = 'Test: %s / bbcode: %s / Actual: %s / Expected: %s'; @@ -250,7 +249,7 @@ class BBCodeParserTest extends TestCase } } - public function testParserInsensitive() + public function testParserInsensitive(): void { /** * Now we run with insensitive case turned on, so everything @@ -278,7 +277,7 @@ class BBCodeParserTest extends TestCase } } - public function testStripBBCodeTags() + public function testStripBBCodeTags(): void { foreach ($this->mixedCaseTests as $test) { $this->assertEquals( @@ -288,7 +287,7 @@ class BBCodeParserTest extends TestCase } } - public function testOnly() + public function testOnly(): void { $keys = array('bold', 'underline'); @@ -299,7 +298,7 @@ class BBCodeParserTest extends TestCase $this->assertNotEquals(array_keys($parsers), array_keys($onlyFew)); } - public function testExcept() + public function testExcept(): void { $keys = array('bold', 'underline'); @@ -310,7 +309,7 @@ class BBCodeParserTest extends TestCase $this->assertNotEquals(array_keys($parsers), array_keys($exceptFew)); } - public function testAddingNewParser() + public function testAddingNewParser(): void { $this->parser->setParser('test', 'x', 'y', 'z'); $expected = array('pattern' => 'x', 'replace' => 'y', 'content' => 'z'); @@ -320,7 +319,7 @@ class BBCodeParserTest extends TestCase $this->assertArraySubset($expected, $parsers['test']); } - public function testWeHaveAllParsersTested() + public function testWeHaveAllParsersTested(): void { $parsers = array_keys($this->parser->except($this->skipParsers)->getParsers()); $missing = array(); @@ -354,7 +353,7 @@ class BBCodeParserTest extends TestCase * @param string $name * @return array */ - public function createTest($options = [], $name = '') + public function createTest($options = [], $name = ''): array { if (!isset($options['bbcode'])) { $options['bbcode'] = $name; @@ -388,4 +387,11 @@ class BBCodeParserTest extends TestCase return $options; } + /** + * @param array $expected + * @param mixed $argument1 + */ + private function assertArraySubset(array $expected, $argument1): void + { + } } diff --git a/tests/TestCase.php b/tests/TestCase.php index cf7f7e0..b85fe8d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,25 +2,17 @@ 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): array { unset($app); return ['ivuorinen\BBCode\BBCodeParserServiceProvider']; } - /** - * @param string $pattern - * @return bool - */ - protected function assertRegexpIsValid($pattern = '') + protected function assertRegexpIsValid(string $pattern = ''): bool { - if (@preg_match($pattern, null) === false) { + if (@preg_match($pattern, '') === false) { return false; } return true;