mirror of
https://github.com/ivuorinen/bbcodeparser.git
synced 2026-02-08 15:45:54 +00:00
Update PHPUnit, configuration and tests
This commit is contained in:
@@ -27,11 +27,10 @@
|
|||||||
"php": "^8.1"
|
"php": "^8.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"dms/phpunit-arraysubset-asserts": "0.4.0",
|
"ergebnis/composer-normalize": "^2.30",
|
||||||
"ergebnis/composer-normalize": "2.30.2",
|
"orchestra/testbench": "^8",
|
||||||
"orchestra/testbench": "8.0.5",
|
"phpunit/phpunit": "^10",
|
||||||
"phpunit/phpunit": "10.0.14",
|
"squizlabs/php_codesniffer": "^3"
|
||||||
"squizlabs/php_codesniffer": "3.7.2"
|
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
"golonka/bbcodeparser": "*"
|
"golonka/bbcodeparser": "*"
|
||||||
|
|||||||
26
phpunit.xml
26
phpunit.xml
@@ -1,17 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
<coverage>
|
||||||
bootstrap="vendor/autoload.php"
|
<include>
|
||||||
colors="true"
|
<directory suffix=".php">./src</directory>
|
||||||
>
|
</include>
|
||||||
<coverage processUncoveredFiles="true">
|
</coverage>
|
||||||
<include>
|
<testsuites>
|
||||||
<directory suffix=".php">./src</directory>
|
<testsuite name="Tests">
|
||||||
</include>
|
<directory suffix="Test.php">./tests</directory>
|
||||||
</coverage>
|
</testsuite>
|
||||||
<testsuites>
|
</testsuites>
|
||||||
<testsuite name="Tests">
|
|
||||||
<directory suffix="Test.php">./tests</directory>
|
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ArrayTraitHelper
|
|||||||
* @see \ivuorinen\BBCode\Traits\ArrayTrait::arrayOnly
|
* @see \ivuorinen\BBCode\Traits\ArrayTrait::arrayOnly
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function publicArrayOnly(array $parsers, $only)
|
public function publicArrayOnly(array $parsers, $only): array
|
||||||
{
|
{
|
||||||
return $this->arrayOnly($parsers, $only);
|
return $this->arrayOnly($parsers, $only);
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ class ArrayTraitHelper
|
|||||||
* @see \ivuorinen\BBCode\Traits\ArrayTrait::arrayExcept
|
* @see \ivuorinen\BBCode\Traits\ArrayTrait::arrayExcept
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function publicArrayExcept(array $parsers, $except)
|
public function publicArrayExcept(array $parsers, $except): array
|
||||||
{
|
{
|
||||||
return $this->arrayExcept($parsers, $except);
|
return $this->arrayExcept($parsers, $except);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ class ArrayTraitTest extends TestCase
|
|||||||
$this->class = new ArrayTraitHelper();
|
$this->class = new ArrayTraitHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testArrayOnly()
|
public function testArrayOnly(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(\method_exists($this->class, 'arrayOnly'));
|
$this->assertTrue(\method_exists($this->class, 'arrayOnly'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testArrayExcept()
|
public function testArrayExcept(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(\method_exists($this->class, 'arrayExcept'));
|
$this->assertTrue(\method_exists($this->class, 'arrayExcept'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace ivuorinen\BBCode\Tests;
|
|||||||
|
|
||||||
class BBCodeParserFacadeTest extends TestCase
|
class BBCodeParserFacadeTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testFacadeExistsAndHasBbcode()
|
public function testFacadeExistsAndHasBbcode(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$method = $this->callMethod(
|
$method = $this->callMethod(
|
||||||
@@ -13,7 +13,7 @@ class BBCodeParserFacadeTest extends TestCase
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
$this->assertEquals('bbcode', $method);
|
$this->assertEquals('bbcode', $method);
|
||||||
} catch (ReflectionException $e) {
|
} catch (\ReflectionException $e) {
|
||||||
$this->throwException($e);
|
$this->throwException($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ class BBCodeParserFacadeTest extends TestCase
|
|||||||
* @param $name
|
* @param $name
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws ReflectionException
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
public static function callMethod($obj, $name, array $args)
|
public static function callMethod($obj, $name, array $args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ use ivuorinen\BBCode\BBCodeParserServiceProvider;
|
|||||||
|
|
||||||
class BBCodeParserServiceProviderTest extends TestCase
|
class BBCodeParserServiceProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testProvides()
|
public function testProvides(): void
|
||||||
{
|
{
|
||||||
$provider = new BBCodeParserServiceProvider($this->app);
|
$provider = new BBCodeParserServiceProvider($this->app);
|
||||||
$this->assertEquals(['bbcode'], $provider->provides());
|
$this->assertEquals(['bbcode'], $provider->provides());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRegister()
|
public function testRegister(): void
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
\ivuorinen\BBCode\BBCodeParser::class,
|
\ivuorinen\BBCode\BBCodeParser::class,
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ 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"' .
|
'expected_test' => '<iframe width="560" height="315" src="//www.youtube.com/embed/%s"' .
|
||||||
' frameborder="0" allowfullscreen></iframe>',
|
' frameborder="0" allowfullscreen></iframe>',
|
||||||
'values' => ['dQw4w9WgXcQ']
|
'values' => ['dQw4w9WgXcQ']
|
||||||
),
|
),
|
||||||
'listitem' => array(
|
'listitem' => array(
|
||||||
@@ -144,7 +144,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItHasKnownParsers()
|
public function testItHasKnownParsers(): void
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->parser->parsers,
|
$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();
|
$parsers = $this->parser->getParsers();
|
||||||
|
|
||||||
foreach ($parsers as $parserName => $parser) {
|
foreach ($parsers as $parserName => $parser) {
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$this->assertArrayHasKey(
|
$this->assertTrue(
|
||||||
$key,
|
array_key_exists($key, $parser),
|
||||||
$parser,
|
|
||||||
sprintf('Parser: %s, Key: %s', $parserName, $key)
|
sprintf('Parser: %s, Key: %s', $parserName, $key)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testParserRegexpIsValid()
|
public function testParserRegexpIsValid(): void
|
||||||
{
|
{
|
||||||
$parsers = $this->parser->getParsers();
|
$parsers = $this->parser->getParsers();
|
||||||
foreach ($parsers as $parserName => $parser) {
|
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) {
|
foreach ($this->testedParsers as $name => $options) {
|
||||||
$test = $this->createTest($options, $name);
|
$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';
|
$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
|
* 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) {
|
foreach ($this->mixedCaseTests as $test) {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@@ -288,7 +287,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOnly()
|
public function testOnly(): void
|
||||||
{
|
{
|
||||||
$keys = array('bold', 'underline');
|
$keys = array('bold', 'underline');
|
||||||
|
|
||||||
@@ -299,7 +298,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
$this->assertNotEquals(array_keys($parsers), array_keys($onlyFew));
|
$this->assertNotEquals(array_keys($parsers), array_keys($onlyFew));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExcept()
|
public function testExcept(): void
|
||||||
{
|
{
|
||||||
$keys = array('bold', 'underline');
|
$keys = array('bold', 'underline');
|
||||||
|
|
||||||
@@ -310,7 +309,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
$this->assertNotEquals(array_keys($parsers), array_keys($exceptFew));
|
$this->assertNotEquals(array_keys($parsers), array_keys($exceptFew));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddingNewParser()
|
public function testAddingNewParser(): void
|
||||||
{
|
{
|
||||||
$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');
|
||||||
@@ -320,7 +319,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
$this->assertArraySubset($expected, $parsers['test']);
|
$this->assertArraySubset($expected, $parsers['test']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWeHaveAllParsersTested()
|
public function testWeHaveAllParsersTested(): void
|
||||||
{
|
{
|
||||||
$parsers = array_keys($this->parser->except($this->skipParsers)->getParsers());
|
$parsers = array_keys($this->parser->except($this->skipParsers)->getParsers());
|
||||||
$missing = array();
|
$missing = array();
|
||||||
@@ -354,7 +353,7 @@ class BBCodeParserTest extends TestCase
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function createTest($options = [], $name = '')
|
public function createTest($options = [], $name = ''): array
|
||||||
{
|
{
|
||||||
if (!isset($options['bbcode'])) {
|
if (!isset($options['bbcode'])) {
|
||||||
$options['bbcode'] = $name;
|
$options['bbcode'] = $name;
|
||||||
@@ -388,4 +387,11 @@ class BBCodeParserTest extends TestCase
|
|||||||
|
|
||||||
return $options;
|
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;
|
namespace ivuorinen\BBCode\Tests;
|
||||||
|
|
||||||
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
|
|
||||||
|
|
||||||
class TestCase extends \Orchestra\Testbench\TestCase
|
class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
{
|
{
|
||||||
use ArraySubsetAsserts;
|
protected function getPackageProviders($app): array
|
||||||
|
|
||||||
protected function getPackageProviders($app)
|
|
||||||
{
|
{
|
||||||
unset($app);
|
unset($app);
|
||||||
return ['ivuorinen\BBCode\BBCodeParserServiceProvider'];
|
return ['ivuorinen\BBCode\BBCodeParserServiceProvider'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function assertRegexpIsValid(string $pattern = ''): bool
|
||||||
* @param string $pattern
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function assertRegexpIsValid($pattern = '')
|
|
||||||
{
|
{
|
||||||
if (@preg_match($pattern, null) === false) {
|
if (@preg_match($pattern, '') === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user