Skip to content

Commit

Permalink
Updated test suite for PHPUnit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Feb 11, 2023
1 parent 46279a2 commit cb07f21
Show file tree
Hide file tree
Showing 200 changed files with 391 additions and 446 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.phpunit.cache
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ You can try the JavaScript version in this [BBCodes + other stuff demo](https://

The following tools are used during development.

- [phpunit/phpunit](https://phpunit.de/) 9.6.3 runs a full suite of tests before every commit.
- [phpunit/phpunit](https://phpunit.de/) 10.0.7 runs a full suite of tests before every commit.
- [code-lts/doctum](https://github.com/code-lts/doctum) 5.5.1 generates the [API docs](https://s9e.github.io/TextFormatter/api/).
- Scrutinizer is used for code tracking.
30 changes: 0 additions & 30 deletions docs/testdox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3092,25 +3092,6 @@ Template Checker (s9e\TextFormatter\Tests\Configurator\TemplateChecker)
[x] disable() disables all checks
[x] enable() re-enables all checks

Abstract Dynamic Content Check (s9e\TextFormatter\Tests\Configurator\TemplateChecks\AbstractDynamicContentCheck)
[x] Stylesheet parameters are considered safe
[x] Variables pointing to an unknown attribute are unsafe
[x] Variables pointing to an unknown attribute are ignored if ignoreUnknownAttributes() is called
[x] Variables pointing to an unknown attribute are detected if detectUnknownAttributes() is called after ignoreUnknownAttributes()
[x] Variables pointing to a safe attribute are safe
[x] Variables pointing to an unsafe attribute are unsafe
[x] Variables pointing to a safe variable are safe
[x] Variables pointing to an unsafe variable are unsafe
[x] Variables pointing to a stylesheet parameter are safe
[x] Variables pointing to a stylesheet parameter of the same name are safe
[x] Local parameters pointing to an unknown attribute are unsafe
[x] Local parameters pointing to a safe attribute are safe
[x] Attributes are not safe if the tag's filterChain is cleared
[x] Attributes are not safe if the tag's filterChain does not contain the default attribute filter
[x] Attributes can be safe with the tag's default filterChain
[x] Multiple attributes can be safe
[x] Multiple attributes can be unsafe

Disallow Attribute Sets (s9e\TextFormatter\Tests\Configurator\TemplateChecks\DisallowAttributeSets)
[x] Disallowed: <b use-attribute-sets="foo"/>
[x] Allowed: <b>...</b>
Expand Down Expand Up @@ -3379,17 +3360,6 @@ Restrict Flash Script Access (s9e\TextFormatter\Tests\Configurator\TemplateCheck
[x] 'never',true disallows <object><param name="movie" value="{@url}"/></object>
[x] 'never',true disallows <embed><xsl:apply-templates/></embed>

Abstract Normalization (s9e\TextFormatter\Tests\Configurator\AbstractNormalization)
[x] Nothing happens if the normalization doesn't override any method or set any query
[x] Nothing happens if the normalization doesn't override any method but set an element query
[x] Nothing happens if the normalization doesn't override any method but set an attribute query
[x] Calls normalizeAttribute() if an XPath query returns a DOMElement
[x] Calls normalizeElement() if an XPath query returns a DOMElement
[x] Nodes removed during normalization are not processed further
[x] Can create elements and text nodes
[x] isXsl() differentiates between XSL elements and others
[x] lowercase() works

Add Attribute Value To Elements (s9e\TextFormatter\Tests\Configurator\TemplateNormalizations\AddAttributeValueToElements)
[x] Works with data set #0
[x] Works with data set #1
Expand Down
21 changes: 10 additions & 11 deletions tests/BundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testParse()
$text = 'Hello world';
$xml = '<t>Hello world</t>';

$mock = $this->getMockBuilder('stdClass')->setMethods(['parse'])->getMock();
$mock = $this->getMockBuilder('stdClass')->addMethods(['parse'])->getMock();
$mock->expects($this->once())
->method('parse')
->with($text)
Expand All @@ -54,10 +54,9 @@ public function testParseSingleton()
$text2 = 'Sup Earth :)';
$xml2 = '<r>Sup Earth <E>:)</e></r>';

$mock = $this->getMockBuilder('stdClass')->setMethods(['parse'])->getMock();
$mock = $this->getMockBuilder('stdClass')->addMethods(['parse'])->getMock();
$mock->expects($this->exactly(2))
->method('parse')
->withConsecutive([$text1], [$text2])
->willReturnOnConsecutiveCalls($xml1, $xml2);

DummyBundle::$_parser = $mock;
Expand All @@ -72,7 +71,7 @@ public function testParseSingleton()
*/
public function testBeforeParse()
{
$mock = $this->getMockBuilder('stdClass')->setMethods(['parse'])->getMock();
$mock = $this->getMockBuilder('stdClass')->addMethods(['parse'])->getMock();
$mock->expects($this->once())
->method('parse')
->with('beforeParse')
Expand All @@ -94,7 +93,7 @@ public function testBeforeParse()
*/
public function testAfterParse()
{
$mock = $this->getMockBuilder('stdClass')->setMethods(['parse'])->getMock();
$mock = $this->getMockBuilder('stdClass')->addMethods(['parse'])->getMock();
$mock->expects($this->once())
->method('parse')
->with('')
Expand All @@ -119,7 +118,7 @@ public function testRender()
$xml = '<t>Hello world</t>';
$html = 'Hello world';

$mock = $this->getMockBuilder('stdClass')->setMethods(['render', 'setParameters'])->getMock();
$mock = $this->getMockBuilder('stdClass')->addMethods(['render', 'setParameters'])->getMock();
$mock->expects($this->once())
->method('render')
->with($xml)
Expand All @@ -139,7 +138,7 @@ public function testRenderSingleton()
$xml = '<t>Hello world</t>';
$html = 'Hello world';

$mock = $this->getMockBuilder('stdClass')->setMethods(['render', 'setParameters'])->getMock();
$mock = $this->getMockBuilder('stdClass')->addMethods(['render', 'setParameters'])->getMock();
$mock->expects($this->exactly(2))
->method('render')
->with($xml)
Expand All @@ -161,7 +160,7 @@ public function testRenderParameters()
$html = 'Hello world';
$params = ['foo' => 'bar'];

$mock = $this->getMockBuilder('stdClass')->setMethods(['render', 'setParameters'])->getMock();
$mock = $this->getMockBuilder('stdClass')->addMethods(['render', 'setParameters'])->getMock();
$mock->expects($this->once())
->method('render')
->with($xml)
Expand All @@ -181,7 +180,7 @@ public function testRenderParameters()
*/
public function testBeforeRender()
{
$mock = $this->getMockBuilder('stdClass')->setMethods(['render'])->getMock();
$mock = $this->getMockBuilder('stdClass')->addMethods(['render'])->getMock();
$mock->expects($this->once())
->method('render')
->with('<t>beforeRender</t>')
Expand All @@ -203,7 +202,7 @@ public function testBeforeRender()
*/
public function testAfterRender()
{
$mock = $this->getMockBuilder('stdClass')->setMethods(['render'])->getMock();
$mock = $this->getMockBuilder('stdClass')->addMethods(['render'])->getMock();
$mock->expects($this->once())
->method('render')
->with('')
Expand Down Expand Up @@ -297,7 +296,7 @@ public static function _reset(Test $test)
self::$calls = ['getParser' => 0, 'getRenderer' => 0];

$mock = $test->getMockBuilder('stdClass')
->setMethods(['parse', 'render', 'setParameters'])
->addMethods(['parse', 'render', 'setParameters'])
->getMock();
$mock->expects($test->never())->method('parse');
$mock->expects($test->never())->method('render');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @covers s9e\TextFormatter\Bundle
*/
abstract class AbstractTest extends Test
abstract class AbstractTestClass extends Test
{
protected static function getBundleName()
{
Expand Down Expand Up @@ -194,7 +194,7 @@ public function testRender($text, $expected, $params = [])
$this->runRenderingTest($text, $expected, $params, false);
}

public function getRenderingTests()
public static function getRenderingTests()
{
$bundleName = static::getBundleName();

Expand Down
2 changes: 1 addition & 1 deletion tests/Bundles/FatdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @covers s9e\TextFormatter\Bundles\Fatdown
* @covers s9e\TextFormatter\Bundles\Fatdown\Renderer
*/
class FatdownTest extends AbstractTest
class FatdownTest extends AbstractTestClass
{
protected function postprocessActualHtml(string $html): string
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Bundles/ForumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
* @covers s9e\TextFormatter\Bundles\Forum
* @covers s9e\TextFormatter\Bundles\Forum\Renderer
*/
class ForumTest extends AbstractTest
class ForumTest extends AbstractTestClass
{
}
2 changes: 1 addition & 1 deletion tests/Bundles/MediaPackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* @covers s9e\TextFormatter\Bundles\MediaPack
* @covers s9e\TextFormatter\Bundles\MediaPack\Renderer
*/
class MediaPackTest extends AbstractTest
class MediaPackTest extends AbstractTestClass
{
}
6 changes: 3 additions & 3 deletions tests/Configurator/BundleGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testFileHeader()
public function testCustomSerializer()
{
$mock = $this->getMockBuilder('stdClass')
->setMethods(['serialize'])
->addMethods(['serialize'])
->getMock();
$mock->expects($this->any())
->method('serialize')
Expand Down Expand Up @@ -210,7 +210,7 @@ public function testExportCallback($namespace, $original, $expected)
$this->assertSame($expected, $actual);
}

public function getExportCallbackTests()
public static function getExportCallbackTests()
{
return [
[
Expand Down Expand Up @@ -274,7 +274,7 @@ public function testExportObject($original, $expected)
$this->assertEquals($original, eval('return ' . $actual . ';'), 'Not reversible');
}

public function getExportObjectTests()
public static function getExportObjectTests()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NormalizedCollectionTest extends Test
{
protected function getMockCollection()
{
return $this->getMockBuilder('s9e\\TextFormatter\\Configurator\\Collections\\NormalizedCollection')->setMethods(func_get_args())->getMock();
return $this->getMockBuilder('s9e\\TextFormatter\\Configurator\\Collections\\NormalizedCollection')->onlyMethods(func_get_args())->getMock();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Configurator/Collections/NormalizedListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testAppend()
public function testArrayAccessAppend()
{
$mock = $this->getMockBuilder('s9e\\TextFormatter\\Configurator\\Collections\\NormalizedList')
->setMethods(['append'])
->onlyMethods(['append'])
->getMock();

$mock->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testHighlightNode($template, $expected)
$this->assertSame($expected, $e->highlightNode());
}

public function getHighlights()
public static function getHighlights()
{
return [
[
Expand Down
8 changes: 4 additions & 4 deletions tests/Configurator/Helpers/AVTHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testParse($attrValue, $expected)
$this->assertSame($expected, AVTHelper::parse($attrValue));
}

public function getParseTests()
public static function getParseTests()
{
return [
[
Expand Down Expand Up @@ -131,7 +131,7 @@ public function testSerialize($tokens, $expected)
$this->assertSame($expected, AVTHelper::serialize($tokens));
}

public function getSerializeTests()
public static function getSerializeTests()
{
return [
[
Expand Down Expand Up @@ -199,7 +199,7 @@ public function testReplace($xml, $callback, $expected)
$this->assertSame($expected, $dom->saveXML($dom->documentElement));
}

public function getReplaceTests()
public static function getReplaceTests()
{
return [
[
Expand Down Expand Up @@ -238,7 +238,7 @@ public function testToXSL($attrValue, $expected)
$this->assertSame($expected, AVTHelper::toXSL($attrValue));
}

public function getToXSLTests()
public static function getToXSLTests()
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Configurator/Helpers/ElementInspectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function test($methodName, $args, $expected)
$this->assertEquals($expected, $actual);
}

public function getElementInspectorTests()
public static function getElementInspectorTests()
{
return [
[
Expand Down
4 changes: 2 additions & 2 deletions tests/Configurator/Helpers/FilterHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testIsAllowed(string $filter, array $allowed, bool $expected)
$this->assertEquals($expected, FilterHelper::isAllowed($filter, $allowed));
}

public function getIsAllowedTests()
public static function getIsAllowedTests()
{
return [
[
Expand Down Expand Up @@ -73,7 +73,7 @@ public function testParse($filterString, $expected)
$this->assertEquals($expected, FilterHelper::parse($filterString));
}

public function getParseTests()
public static function getParseTests()
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Configurator/Helpers/FilterSyntaxMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testParse($filterString, $expected)
$this->assertEquals($expected, $parser->parse($filterString)['value']);
}

public function getParseTests()
public static function getParseTests()
{
return [
[
Expand Down
8 changes: 4 additions & 4 deletions tests/Configurator/Helpers/NodeLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testGetURLNodes($template, $query = null)
$this->runTestGetNodes('getURLNodes', [], $template, $query);
}

public function getObjectParamsByRegexpTests()
public static function getObjectParamsByRegexpTests()
{
return [
[
Expand Down Expand Up @@ -131,7 +131,7 @@ public function getObjectParamsByRegexpTests()
];
}

public function getCSSNodesTests()
public static function getCSSNodesTests()
{
return [
[
Expand Down Expand Up @@ -176,7 +176,7 @@ public function getCSSNodesTests()
];
}

public function getJSNodesTests()
public static function getJSNodesTests()
{
return [
[
Expand Down Expand Up @@ -225,7 +225,7 @@ public function getJSNodesTests()
];
}

public function getURLNodesTests()
public static function getURLNodesTests()
{
return [
[
Expand Down
4 changes: 2 additions & 2 deletions tests/Configurator/Helpers/RegexpParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ public function testGetAllowedCharacterRegexp($regexp, $results)
}
}

public function getAllowedCharacterRegexpData()
public static function getAllowedCharacterRegexpData()
{
return [
[
Expand Down Expand Up @@ -1145,7 +1145,7 @@ public function testGetCaptureNamesTests($regexp, array $expected)
$this->assertSame($expected, RegexpParser::getCaptureNames($regexp));
}

public function getGetCaptureNamesTests()
public static function getGetCaptureNamesTests()
{
return [
[
Expand Down
6 changes: 3 additions & 3 deletions tests/Configurator/Helpers/TemplateHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testGetParametersFromXSL($xsl, $expected)
);
}

public function getParametersTests()
public static function getParametersTests()
{
return [
[
Expand Down Expand Up @@ -120,7 +120,7 @@ public function testHighlightNode($query, $template, $expected)
);
}

public function getHighlights()
public static function getHighlights()
{
return [
[
Expand Down Expand Up @@ -212,7 +212,7 @@ public function testReplaceHomogeneousTemplates($templates, $expected)
$this->assertSame($expected, $templates);
}

public function getReplaceHomogeneousTemplatesTests()
public static function getReplaceHomogeneousTemplatesTests()
{
return [
[
Expand Down
Loading

0 comments on commit cb07f21

Please sign in to comment.