mirror of
https://github.com/ivuorinen/bbcodeparser.git
synced 2026-01-26 03:13:57 +00:00
Update PHPUnit, configuration and tests
This commit is contained in:
@@ -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": "*"
|
||||
|
||||
26
phpunit.xml
26
phpunit.xml
@@ -1,17 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">./src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Tests">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">./src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Tests">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -96,7 +96,7 @@ class BBCodeParserTest extends TestCase
|
||||
'youtube' => array(
|
||||
'bbcode' => 'youtube',
|
||||
'expected_test' => '<iframe width="560" height="315" src="//www.youtube.com/embed/%s"' .
|
||||
' frameborder="0" allowfullscreen></iframe>',
|
||||
' frameborder="0" allowfullscreen></iframe>',
|
||||
'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<int,mixed> $expected
|
||||
* @param mixed $argument1
|
||||
*/
|
||||
private function assertArraySubset(array $expected, $argument1): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user