diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index c2cb8e3cc6..9f2b867dbe 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -30,6 +30,10 @@ jobs:
- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
+ - name: "Use PHPUnit 9.3+ on PHP 8"
+ run: composer require --no-update --dev phpunit/phpunit:^9.3
+ if: "matrix.php == '8.0'"
+
- run: composer update --no-progress ${{ matrix.composer-flags }}
- run: vendor/bin/phpunit --no-coverage
diff --git a/composer.json b/composer.json
index 3a39e2820d..16395270c5 100644
--- a/composer.json
+++ b/composer.json
@@ -32,10 +32,12 @@
"michelf/php-markdown": "~1.4",
"mikehaertl/php-shellcommand": "^1.4",
"phpstan/phpstan": "^0.12",
- "phpunit/phpunit": "^7.5",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.2",
"scrutinizer/ocular": "^1.5",
"symfony/finder": "^4.2"
},
+ "minimum-stability": "dev",
+ "prefer-stable": true,
"conflict": {
"scrutinizer/ocular": "1.7.*"
},
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index b1e50943c2..0ad04ee79f 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -10,8 +10,11 @@
processIsolation="false"
stopOnFailure="false">
(1)(2)both(/2)(/1)Test
'];
}
+ /**
+ * @group legacy
+ */
public function testHeadingPermalinksWithDeprecatedInnerContents()
{
$environment = Environment::createCommonMarkEnvironment();
diff --git a/tests/functional/Extension/InlinesOnly/InlinesOnlyFunctionalTest.php b/tests/functional/Extension/InlinesOnly/InlinesOnlyFunctionalTest.php
index 7d124b6362..1416599333 100644
--- a/tests/functional/Extension/InlinesOnly/InlinesOnlyFunctionalTest.php
+++ b/tests/functional/Extension/InlinesOnly/InlinesOnlyFunctionalTest.php
@@ -26,7 +26,7 @@ class InlinesOnlyFunctionalTest extends TestCase
*/
protected $converter;
- protected function setUp()
+ protected function setUp(): void
{
$environment = new Environment();
$environment->addExtension(new InlinesOnlyExtension());
diff --git a/tests/functional/Extension/SmartPunct/SmartPunctFunctionalTest.php b/tests/functional/Extension/SmartPunct/SmartPunctFunctionalTest.php
index 01228f0b50..f0a579f798 100644
--- a/tests/functional/Extension/SmartPunct/SmartPunctFunctionalTest.php
+++ b/tests/functional/Extension/SmartPunct/SmartPunctFunctionalTest.php
@@ -12,7 +12,7 @@
* file that was distributed with this source code.
*/
-namespace League\CommonMark\Tests\Unit\Extension\SmartPunct;
+namespace League\CommonMark\Tests\Functional\Extension\SmartPunct;
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
@@ -29,7 +29,7 @@ class SmartPunctFunctionalTest extends TestCase
*/
protected $converter;
- protected function setUp()
+ protected function setUp(): void
{
$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new SmartPunctExtension());
diff --git a/tests/functional/LocalDataTest.php b/tests/functional/LocalDataTest.php
index d84886fb31..0a45faf389 100644
--- a/tests/functional/LocalDataTest.php
+++ b/tests/functional/LocalDataTest.php
@@ -26,7 +26,7 @@ class LocalDataTest extends AbstractLocalDataTest
*/
protected $converter;
- protected function setUp()
+ protected function setUp(): void
{
$this->converter = new CommonMarkConverter();
}
diff --git a/tests/unit/Block/Element/AbstractBlockTest.php b/tests/unit/Block/Element/AbstractBlockTest.php
index 75a3cb530d..1ccc31903f 100644
--- a/tests/unit/Block/Element/AbstractBlockTest.php
+++ b/tests/unit/Block/Element/AbstractBlockTest.php
@@ -33,11 +33,10 @@ public function testSetParent()
$this->assertNull($block->parent());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testSetParentWithInvalidNode()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$block = $this->getMockForAbstractClass(AbstractBlock::class);
$inline = $this->getMockForAbstractClass(AbstractInline::class);
diff --git a/tests/unit/Block/Renderer/BlockQuoteRendererTest.php b/tests/unit/Block/Renderer/BlockQuoteRendererTest.php
index 07d66b79df..0b257190e5 100644
--- a/tests/unit/Block/Renderer/BlockQuoteRendererTest.php
+++ b/tests/unit/Block/Renderer/BlockQuoteRendererTest.php
@@ -29,7 +29,7 @@ class BlockQuoteRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new BlockQuoteRenderer();
}
@@ -58,15 +58,14 @@ public function testRenderBlockQuote()
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals('blockquote', $result->getTagName());
- $this->assertContains('::blocks::', $result->getContents(true));
+ $this->assertStringContainsString('::blocks::', $result->getContents(true));
$this->assertEquals(['id' => 'id'], $result->getAllAttributes());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(BlockElement\AbstractBlock::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Block/Renderer/DocumentRendererTest.php b/tests/unit/Block/Renderer/DocumentRendererTest.php
index f628011a75..f941b842a2 100644
--- a/tests/unit/Block/Renderer/DocumentRendererTest.php
+++ b/tests/unit/Block/Renderer/DocumentRendererTest.php
@@ -28,7 +28,7 @@ class DocumentRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new DocumentRenderer();
}
@@ -40,7 +40,7 @@ public function testRenderEmptyDocument()
$result = $this->renderer->render($block, $fakeRenderer);
- $this->assertInternalType('string', $result);
+ $this->assertIsString($result);
$this->assertEmpty($result);
}
@@ -51,15 +51,14 @@ public function testRenderDocument()
$result = $this->renderer->render($block, $fakeRenderer);
- $this->assertInternalType('string', $result);
- $this->assertContains('::blocks::', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('::blocks::', $result);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(BlockElement\AbstractBlock::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Block/Renderer/FencedCodeRendererTest.php b/tests/unit/Block/Renderer/FencedCodeRendererTest.php
index df3c8c5b0c..5436c9f8a8 100644
--- a/tests/unit/Block/Renderer/FencedCodeRendererTest.php
+++ b/tests/unit/Block/Renderer/FencedCodeRendererTest.php
@@ -31,7 +31,7 @@ class FencedCodeRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new FencedCodeRenderer();
}
@@ -59,8 +59,8 @@ public function testRenderWithLanguageSpecified()
$code = $result->getContents(false);
$this->assertTrue($code instanceof HtmlElement);
$this->assertEquals('code', $code->getTagName());
- $this->assertContains('bar language-php', $code->getAttribute('class'));
- $this->assertContains('hello world', $code->getContents(true));
+ $this->assertStringContainsString('bar language-php', $code->getAttribute('class'));
+ $this->assertStringContainsString('hello world', $code->getContents(true));
}
public function testRenderWithoutLanguageSpecified()
@@ -87,14 +87,13 @@ public function testRenderWithoutLanguageSpecified()
$this->assertTrue($code instanceof HtmlElement);
$this->assertEquals('code', $code->getTagName());
$this->assertEquals('bar', $code->getAttribute('class'));
- $this->assertContains('hello world', $code->getContents(true));
+ $this->assertStringContainsString('hello world', $code->getContents(true));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(BlockElement\AbstractBlock::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Block/Renderer/HeadingRendererTest.php b/tests/unit/Block/Renderer/HeadingRendererTest.php
index ca9707b2dc..4cf57b069e 100644
--- a/tests/unit/Block/Renderer/HeadingRendererTest.php
+++ b/tests/unit/Block/Renderer/HeadingRendererTest.php
@@ -28,7 +28,7 @@ class HeadingRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new HeadingRenderer();
}
@@ -49,7 +49,7 @@ public function testRender($level, $expectedTag)
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals($expectedTag, $result->getTagName());
- $this->assertContains('::inlines::', $result->getContents(true));
+ $this->assertStringContainsString('::inlines::', $result->getContents(true));
$this->assertEquals(['id' => 'foo'], $result->getAllAttributes());
}
@@ -65,11 +65,10 @@ public function dataForTestRender()
];
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(BlockElement\AbstractBlock::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Block/Renderer/HtmlBlockRendererTest.php b/tests/unit/Block/Renderer/HtmlBlockRendererTest.php
index 4df6790640..2656652e8b 100644
--- a/tests/unit/Block/Renderer/HtmlBlockRendererTest.php
+++ b/tests/unit/Block/Renderer/HtmlBlockRendererTest.php
@@ -29,7 +29,7 @@ class HtmlBlockRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new HtmlBlockRenderer();
$this->renderer->setConfiguration(new Configuration());
@@ -37,7 +37,7 @@ protected function setUp()
public function testRender()
{
- /** @var HtmlBlock|\PHPUnit_Framework_MockObject_MockObject $block */
+ /** @var HtmlBlock|\PHPUnit\Framework\MockObject\MockObject $block */
$block = $this->getMockBuilder(\League\CommonMark\Block\Element\HtmlBlock::class)
->setConstructorArgs([HtmlBlock::TYPE_6_BLOCK_ELEMENT])
->getMock();
@@ -49,8 +49,8 @@ public function testRender()
$result = $this->renderer->render($block, $fakeRenderer);
- $this->assertInternalType('string', $result);
- $this->assertContains('', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('', $result);
}
public function testRenderAllowHtml()
@@ -59,7 +59,7 @@ public function testRenderAllowHtml()
'html_input' => Environment::HTML_INPUT_ALLOW,
]));
- /** @var HtmlBlock|\PHPUnit_Framework_MockObject_MockObject $block */
+ /** @var HtmlBlock|\PHPUnit\Framework\MockObject\MockObject $block */
$block = $this->getMockBuilder(\League\CommonMark\Block\Element\HtmlBlock::class)
->setConstructorArgs([HtmlBlock::TYPE_6_BLOCK_ELEMENT])
->getMock();
@@ -71,8 +71,8 @@ public function testRenderAllowHtml()
$result = $this->renderer->render($block, $fakeRenderer);
- $this->assertInternalType('string', $result);
- $this->assertContains('', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('', $result);
}
public function testRenderEscapeHtml()
@@ -81,7 +81,7 @@ public function testRenderEscapeHtml()
'html_input' => Environment::HTML_INPUT_ESCAPE,
]));
- /** @var HtmlBlock|\PHPUnit_Framework_MockObject_MockObject $block */
+ /** @var HtmlBlock|\PHPUnit\Framework\MockObject\MockObject $block */
$block = $this->getMockBuilder(\League\CommonMark\Block\Element\HtmlBlock::class)
->setConstructorArgs([HtmlBlock::TYPE_6_BLOCK_ELEMENT])
->getMock();
@@ -93,8 +93,8 @@ public function testRenderEscapeHtml()
$result = $this->renderer->render($block, $fakeRenderer);
- $this->assertInternalType('string', $result);
- $this->assertContains('<button class="test">Test</button>', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('<button class="test">Test</button>', $result);
}
public function testRenderStripHtml()
@@ -103,7 +103,7 @@ public function testRenderStripHtml()
'html_input' => Environment::HTML_INPUT_STRIP,
]));
- /** @var HtmlBlock|\PHPUnit_Framework_MockObject_MockObject $block */
+ /** @var HtmlBlock|\PHPUnit\Framework\MockObject\MockObject $block */
$block = $this->getMockBuilder(\League\CommonMark\Block\Element\HtmlBlock::class)
->setConstructorArgs([HtmlBlock::TYPE_6_BLOCK_ELEMENT])
->getMock();
@@ -115,15 +115,14 @@ public function testRenderStripHtml()
$result = $this->renderer->render($block, $fakeRenderer);
- $this->assertInternalType('string', $result);
+ $this->assertIsString($result);
$this->assertEquals('', $result);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(BlockElement\AbstractBlock::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Block/Renderer/IndentedCodeRendererTest.php b/tests/unit/Block/Renderer/IndentedCodeRendererTest.php
index fae86b766e..627e5f9e99 100644
--- a/tests/unit/Block/Renderer/IndentedCodeRendererTest.php
+++ b/tests/unit/Block/Renderer/IndentedCodeRendererTest.php
@@ -31,7 +31,7 @@ class IndentedCodeRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new IndentedCodeRenderer();
}
@@ -60,14 +60,13 @@ public function testRender()
$this->assertEquals('code', $code->getTagName());
$this->assertNull($code->getAttribute('class'));
$this->assertEquals(['id' => 'foo'], $code->getAllAttributes());
- $this->assertContains('hello world', $code->getContents(true));
+ $this->assertStringContainsString('hello world', $code->getContents(true));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(BlockElement\AbstractBlock::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Block/Renderer/ListBlockRendererTest.php b/tests/unit/Block/Renderer/ListBlockRendererTest.php
index 2b6ef3218b..bd5a6db442 100644
--- a/tests/unit/Block/Renderer/ListBlockRendererTest.php
+++ b/tests/unit/Block/Renderer/ListBlockRendererTest.php
@@ -29,7 +29,7 @@ class ListBlockRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new ListBlockRenderer();
}
@@ -50,7 +50,7 @@ public function testRenderOrderedList($listStart = null, $expectedAttributeValue
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals('ol', $result->getTagName());
$this->assertSame($expectedAttributeValue, $result->getAttribute('start'));
- $this->assertContains('::blocks::', $result->getContents(true));
+ $this->assertStringContainsString('::blocks::', $result->getContents(true));
$this->assertEquals('foo', $result->getAttribute('id'));
}
@@ -74,15 +74,14 @@ public function testRenderUnorderedList()
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals('ul', $result->getTagName());
- $this->assertContains('::blocks::', $result->getContents(true));
+ $this->assertStringContainsString('::blocks::', $result->getContents(true));
$this->assertEquals(['id' => 'foo'], $result->getAllAttributes());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(BlockElement\AbstractBlock::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Block/Renderer/ListItemRendererTest.php b/tests/unit/Block/Renderer/ListItemRendererTest.php
index 7ca67aa436..287ca021c0 100644
--- a/tests/unit/Block/Renderer/ListItemRendererTest.php
+++ b/tests/unit/Block/Renderer/ListItemRendererTest.php
@@ -29,7 +29,7 @@ class ListItemRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new ListItemRenderer();
}
@@ -47,11 +47,10 @@ public function testRenderUnorderedList()
$this->assertEquals('Test
', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('Test
', $result);
}
public function testRenderAllowHtml()
@@ -57,8 +57,8 @@ public function testRenderAllowHtml()
$result = $this->renderer->render($inline, $fakeRenderer);
- $this->assertInternalType('string', $result);
- $this->assertContains('Test
', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('Test
', $result);
}
public function testRenderEscapeHtml()
@@ -72,8 +72,8 @@ public function testRenderEscapeHtml()
$result = $this->renderer->render($inline, $fakeRenderer);
- $this->assertInternalType('string', $result);
- $this->assertContains('<h1 class="test">Test</h1>', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('<h1 class="test">Test</h1>', $result);
}
public function testRenderStripHtml()
@@ -87,15 +87,14 @@ public function testRenderStripHtml()
$result = $this->renderer->render($inline, $fakeRenderer);
- $this->assertInternalType('string', $result);
+ $this->assertIsString($result);
$this->assertEquals('', $result);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(InlineElement\AbstractInline::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Inline/Renderer/ImageRendererTest.php b/tests/unit/Inline/Renderer/ImageRendererTest.php
index 8939907207..0bca9dc53d 100644
--- a/tests/unit/Inline/Renderer/ImageRendererTest.php
+++ b/tests/unit/Inline/Renderer/ImageRendererTest.php
@@ -29,7 +29,7 @@ class ImageRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new ImageRenderer();
$this->renderer->setConfiguration(new Configuration());
@@ -45,11 +45,11 @@ public function testRenderWithTitle()
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals('img', $result->getTagName());
- $this->assertContains('http://example.com/foo.jpg', $result->getAttribute('src'));
- $this->assertContains('foo.jpg', $result->getAttribute('src'));
- $this->assertContains('::inlines::', $result->getAttribute('alt'));
- $this->assertContains('::title::', $result->getAttribute('title'));
- $this->assertContains('::id::', $result->getAttribute('id'));
+ $this->assertStringContainsString('http://example.com/foo.jpg', $result->getAttribute('src'));
+ $this->assertStringContainsString('foo.jpg', $result->getAttribute('src'));
+ $this->assertStringContainsString('::inlines::', $result->getAttribute('alt'));
+ $this->assertStringContainsString('::title::', $result->getAttribute('title'));
+ $this->assertStringContainsString('::id::', $result->getAttribute('id'));
}
public function testRenderWithoutTitle()
@@ -61,9 +61,9 @@ public function testRenderWithoutTitle()
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals('img', $result->getTagName());
- $this->assertContains('http://example.com/foo.jpg', $result->getAttribute('src'));
- $this->assertContains('foo.jpg', $result->getAttribute('src'));
- $this->assertContains('::inlines::', $result->getAttribute('alt'));
+ $this->assertStringContainsString('http://example.com/foo.jpg', $result->getAttribute('src'));
+ $this->assertStringContainsString('foo.jpg', $result->getAttribute('src'));
+ $this->assertStringContainsString('::inlines::', $result->getAttribute('alt'));
$this->assertNull($result->getAttribute('title'));
}
@@ -79,7 +79,7 @@ public function testRenderAllowUnsafeLink()
$result = $this->renderer->render($inline, $fakeRenderer);
$this->assertTrue($result instanceof HtmlElement);
- $this->assertContains('javascript:void(0)', $result->getAttribute('src'));
+ $this->assertStringContainsString('javascript:void(0)', $result->getAttribute('src'));
}
public function testRenderDisallowUnsafeLink()
@@ -97,11 +97,10 @@ public function testRenderDisallowUnsafeLink()
$this->assertEquals('', $result->getAttribute('src'));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(InlineElement\AbstractInline::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Inline/Renderer/LinkRendererTest.php b/tests/unit/Inline/Renderer/LinkRendererTest.php
index 3e36e7fa24..1eaf29ac5c 100644
--- a/tests/unit/Inline/Renderer/LinkRendererTest.php
+++ b/tests/unit/Inline/Renderer/LinkRendererTest.php
@@ -29,7 +29,7 @@ class LinkRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new LinkRenderer();
$this->renderer->setConfiguration(new Configuration());
@@ -45,10 +45,10 @@ public function testRenderWithTitle()
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals('a', $result->getTagName());
- $this->assertContains('http://example.com/foo.html', $result->getAttribute('href'));
- $this->assertContains('::title::', $result->getAttribute('title'));
- $this->assertContains('::inlines::', $result->getContents(true));
- $this->assertContains('::id::', $result->getAttribute('id'));
+ $this->assertStringContainsString('http://example.com/foo.html', $result->getAttribute('href'));
+ $this->assertStringContainsString('::title::', $result->getAttribute('title'));
+ $this->assertStringContainsString('::inlines::', $result->getContents(true));
+ $this->assertStringContainsString('::id::', $result->getAttribute('id'));
}
public function testRenderWithoutTitle()
@@ -60,9 +60,9 @@ public function testRenderWithoutTitle()
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals('a', $result->getTagName());
- $this->assertContains('http://example.com/foo.html', $result->getAttribute('href'));
+ $this->assertStringContainsString('http://example.com/foo.html', $result->getAttribute('href'));
$this->assertNull($result->getAttribute('title'));
- $this->assertContains('::inlines::', $result->getContents(true));
+ $this->assertStringContainsString('::inlines::', $result->getContents(true));
}
public function testRenderAllowUnsafeLink()
@@ -77,7 +77,7 @@ public function testRenderAllowUnsafeLink()
$result = $this->renderer->render($inline, $fakeRenderer);
$this->assertTrue($result instanceof HtmlElement);
- $this->assertContains('javascript:void(0)', $result->getAttribute('href'));
+ $this->assertStringContainsString('javascript:void(0)', $result->getAttribute('href'));
}
public function testRenderDisallowUnsafeLink()
@@ -95,11 +95,10 @@ public function testRenderDisallowUnsafeLink()
$this->assertEquals('', $result->getAttribute('href'));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(InlineElement\AbstractInline::class);
$fakeRenderer = new FakeHtmlRenderer();
@@ -116,8 +115,8 @@ public function testRenderWithExternalTarget()
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals('a', $result->getTagName());
- $this->assertContains('http://example.com/foo.html', $result->getAttribute('href'));
- $this->assertContains('noopener', $result->getAttribute('rel'));
- $this->assertContains('noreferrer', $result->getAttribute('rel'));
+ $this->assertStringContainsString('http://example.com/foo.html', $result->getAttribute('href'));
+ $this->assertStringContainsString('noopener', $result->getAttribute('rel'));
+ $this->assertStringContainsString('noreferrer', $result->getAttribute('rel'));
}
}
diff --git a/tests/unit/Inline/Renderer/NewlineRendererTest.php b/tests/unit/Inline/Renderer/NewlineRendererTest.php
index df38466b16..571800ceb9 100644
--- a/tests/unit/Inline/Renderer/NewlineRendererTest.php
+++ b/tests/unit/Inline/Renderer/NewlineRendererTest.php
@@ -27,7 +27,7 @@ class NewlineRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new NewlineRenderer();
}
@@ -39,8 +39,8 @@ public function testRenderHardbreak()
$result = $this->renderer->render($inline, $fakeRenderer);
- $this->assertInternalType('string', $result);
- $this->assertContains('
', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('
', $result);
}
public function testRenderSoftbreak()
@@ -51,15 +51,14 @@ public function testRenderSoftbreak()
$result = $this->renderer->render($inline, $fakeRenderer);
- $this->assertInternalType('string', $result);
- $this->assertContains('::softbreakChar::', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('::softbreakChar::', $result);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(InlineElement\AbstractInline::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Inline/Renderer/StrongRendererTest.php b/tests/unit/Inline/Renderer/StrongRendererTest.php
index 55b9ae4fbd..2cc3cb5b65 100644
--- a/tests/unit/Inline/Renderer/StrongRendererTest.php
+++ b/tests/unit/Inline/Renderer/StrongRendererTest.php
@@ -28,7 +28,7 @@ class StrongRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new StrongRenderer();
}
@@ -43,15 +43,14 @@ public function testRender()
$this->assertTrue($result instanceof HtmlElement);
$this->assertEquals('strong', $result->getTagName());
- $this->assertContains('::inlines::', $result->getContents(true));
+ $this->assertStringContainsString('::inlines::', $result->getContents(true));
$this->assertEquals(['id' => 'foo'], $result->getAllAttributes());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(InlineElement\AbstractInline::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/Inline/Renderer/TextRendererTest.php b/tests/unit/Inline/Renderer/TextRendererTest.php
index b0b9ba6129..1e6e072961 100644
--- a/tests/unit/Inline/Renderer/TextRendererTest.php
+++ b/tests/unit/Inline/Renderer/TextRendererTest.php
@@ -27,7 +27,7 @@ class TextRendererTest extends TestCase
*/
protected $renderer;
- protected function setUp()
+ protected function setUp(): void
{
$this->renderer = new TextRenderer();
}
@@ -39,15 +39,14 @@ public function testRender()
$result = $this->renderer->render($inline, $fakeRenderer);
- $this->assertInternalType('string', $result);
- $this->assertContains('foo bar', $result);
+ $this->assertIsString($result);
+ $this->assertStringContainsString('foo bar', $result);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithInvalidType()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$inline = $this->getMockForAbstractClass(InlineElement\AbstractInline::class);
$fakeRenderer = new FakeHtmlRenderer();
diff --git a/tests/unit/UnmatchedBlockCloserTest.php b/tests/unit/UnmatchedBlockCloserTest.php
index 209fcb3113..0088a46a8b 100644
--- a/tests/unit/UnmatchedBlockCloserTest.php
+++ b/tests/unit/UnmatchedBlockCloserTest.php
@@ -36,11 +36,10 @@ public function testResetTip()
$this->assertTrue($closer->areAllClosed());
}
- /**
- * @expectedException \RuntimeException
- */
public function testResetTipWithNullTip()
{
+ $this->expectException(\RuntimeException::class);
+
$context = $this->getMockForAbstractClass(ContextInterface::class);
$context->method('getTip')->willReturn(null);
diff --git a/tests/unit/Util/ArrayCollectionTest.php b/tests/unit/Util/ArrayCollectionTest.php
index 02a75e2180..84f744f9db 100644
--- a/tests/unit/Util/ArrayCollectionTest.php
+++ b/tests/unit/Util/ArrayCollectionTest.php
@@ -52,6 +52,9 @@ public function testGetIterator()
$this->assertEquals($array, $iterator->getArrayCopy());
}
+ /**
+ * @group legacy
+ */
public function testAdd()
{
$collection = new ArrayCollection();
@@ -64,6 +67,9 @@ public function testAdd()
$this->assertEquals(['foo', 'bar'], $collection->toArray());
}
+ /**
+ * @group legacy
+ */
public function testSet()
{
$collection = new ArrayCollection(['foo']);
@@ -76,6 +82,9 @@ public function testSet()
$this->assertEquals(['foo', 'foo' => 2], $collection->toArray());
}
+ /**
+ * @group legacy
+ */
public function testGet()
{
$collection = new ArrayCollection(['foo' => 1, 'bar']);
@@ -85,6 +94,9 @@ public function testGet()
$this->assertNull($collection->get('bar'));
}
+ /**
+ * @group legacy
+ */
public function testRemove()
{
$collection = new ArrayCollection(['foo' => 1, 'bar', 'baz']);
@@ -106,6 +118,9 @@ public function testRemove()
$this->assertEquals([], $collection->toArray());
}
+ /**
+ * @group legacy
+ */
public function testRemoveNulls()
{
$collection = new ArrayCollection(['foo' => null]);
@@ -119,6 +134,9 @@ public function testRemoveNulls()
$this->assertEquals([], $collection->toArray());
}
+ /**
+ * @group legacy
+ */
public function testIsEmpty()
{
$collection = new ArrayCollection();
@@ -135,6 +153,9 @@ public function testIsEmpty()
$this->assertFalse($collection->isEmpty());
}
+ /**
+ * @group legacy
+ */
public function testContains()
{
$object = new \stdClass();
@@ -155,6 +176,9 @@ public function testContains()
$this->assertFalse($collection->contains('FOO'));
}
+ /**
+ * @group legacy
+ */
public function testIndexOf()
{
$object = new \stdClass();
@@ -175,6 +199,9 @@ public function testIndexOf()
$this->assertTrue(false === $collection->indexOf('FOO'));
}
+ /**
+ * @group legacy
+ */
public function testContainsKey()
{
$collection = new ArrayCollection(['foo' => 1, 'bar']);
@@ -197,10 +224,10 @@ public function testCount()
$collection = new ArrayCollection(['foo']);
$this->assertEquals(1, $collection->count());
- $collection->add('bar');
+ $collection[] = 'bar';
$this->assertEquals(2, $collection->count());
- $collection->remove(0);
+ unset($collection[0]);
$this->assertEquals(1, $collection->count());
}
@@ -320,6 +347,9 @@ public function testToArray()
$this->assertEquals([2 => 1, 'foo'], $collection->toArray());
}
+ /**
+ * @group legacy
+ */
public function testReplaceWith()
{
$collection = new ArrayCollection(['foo' => 1, 'bar']);
@@ -330,6 +360,9 @@ public function testReplaceWith()
$this->assertEquals(['baz', 42], $replaced->toArray());
}
+ /**
+ * @group legacy
+ */
public function testRemoveGaps()
{
$collection = new ArrayCollection(['', true, false, null, [], 0, '0', 1]);
diff --git a/tests/unit/Util/Html5EntitiesTest.php b/tests/unit/Util/Html5EntitiesTest.php
index f88b7ea2e1..335dfa6d98 100644
--- a/tests/unit/Util/Html5EntitiesTest.php
+++ b/tests/unit/Util/Html5EntitiesTest.php
@@ -5,6 +5,9 @@
use League\CommonMark\Util\Html5Entities;
use PHPUnit\Framework\TestCase;
+/**
+ * @group legacy
+ */
class Html5EntitiesTest extends TestCase
{
public function testEntityToChar()
diff --git a/tests/unit/Util/RegexHelperTest.php b/tests/unit/Util/RegexHelperTest.php
index 3c4c0af398..9597042914 100644
--- a/tests/unit/Util/RegexHelperTest.php
+++ b/tests/unit/Util/RegexHelperTest.php
@@ -23,246 +23,246 @@ class RegexHelperTest extends TestCase
public function testEscapable()
{
$regex = '/^' . RegexHelper::PARTIAL_ESCAPABLE . '$/';
- $this->assertRegExp($regex, '&');
- $this->assertRegExp($regex, '/');
- $this->assertRegExp($regex, '\\');
- $this->assertRegExp($regex, '(');
- $this->assertRegExp($regex, ')');
+ $this->assertRegexMatches($regex, '&');
+ $this->assertRegexMatches($regex, '/');
+ $this->assertRegexMatches($regex, '\\');
+ $this->assertRegexMatches($regex, '(');
+ $this->assertRegexMatches($regex, ')');
}
public function testEscapedChar()
{
$regex = '/^' . RegexHelper::PARTIAL_ESCAPED_CHAR . '$/';
- $this->assertRegExp($regex, '\\&');
- $this->assertRegExp($regex, '\\/');
- $this->assertRegExp($regex, '\\\\');
- $this->assertRegExp($regex, '\)');
- $this->assertRegExp($regex, '\(');
+ $this->assertRegexMatches($regex, '\\&');
+ $this->assertRegexMatches($regex, '\\/');
+ $this->assertRegexMatches($regex, '\\\\');
+ $this->assertRegexMatches($regex, '\)');
+ $this->assertRegexMatches($regex, '\(');
}
public function testInDoubleQuotes()
{
$regex = '/^' . RegexHelper::PARTIAL_IN_DOUBLE_QUOTES . '$/';
- $this->assertRegExp($regex, '"\\&"');
- $this->assertRegExp($regex, '"\\/"');
- $this->assertRegExp($regex, '"\\\\"');
+ $this->assertRegexMatches($regex, '"\\&"');
+ $this->assertRegexMatches($regex, '"\\/"');
+ $this->assertRegexMatches($regex, '"\\\\"');
}
public function testInSingleQuotes()
{
$regex = '/^' . RegexHelper::PARTIAL_IN_SINGLE_QUOTES . '$/';
- $this->assertRegExp($regex, '\'\\&\'');
- $this->assertRegExp($regex, '\'\\/\'');
- $this->assertRegExp($regex, '\'\\\\\'');
+ $this->assertRegexMatches($regex, '\'\\&\'');
+ $this->assertRegexMatches($regex, '\'\\/\'');
+ $this->assertRegexMatches($regex, '\'\\\\\'');
}
public function testInParens()
{
$regex = '/^' . RegexHelper::PARTIAL_IN_PARENS . '$/';
- $this->assertRegExp($regex, '(\\&)');
- $this->assertRegExp($regex, '(\\/)');
- $this->assertRegExp($regex, '(\\\\)');
+ $this->assertRegexMatches($regex, '(\\&)');
+ $this->assertRegexMatches($regex, '(\\/)');
+ $this->assertRegexMatches($regex, '(\\\\)');
}
public function testRegChar()
{
$regex = '/^' . RegexHelper::PARTIAL_REG_CHAR . '$/';
- $this->assertRegExp($regex, 'a');
- $this->assertRegExp($regex, 'A');
- $this->assertRegExp($regex, '!');
- $this->assertNotRegExp($regex, ' ');
+ $this->assertRegexMatches($regex, 'a');
+ $this->assertRegexMatches($regex, 'A');
+ $this->assertRegexMatches($regex, '!');
+ $this->assertRegexDoesNotMatch($regex, ' ');
}
public function testInParensNoSp()
{
$regex = '/^' . RegexHelper::PARTIAL_IN_PARENS_NOSP . '$/';
- $this->assertRegExp($regex, '(a)');
- $this->assertRegExp($regex, '(A)');
- $this->assertRegExp($regex, '(!)');
- $this->assertNotRegExp($regex, '(a )');
+ $this->assertRegexMatches($regex, '(a)');
+ $this->assertRegexMatches($regex, '(A)');
+ $this->assertRegexMatches($regex, '(!)');
+ $this->assertRegexDoesNotMatch($regex, '(a )');
}
public function testTagname()
{
$regex = '/^' . RegexHelper::PARTIAL_TAGNAME . '$/';
- $this->assertRegExp($regex, 'a');
- $this->assertRegExp($regex, 'img');
- $this->assertRegExp($regex, 'h1');
- $this->assertNotRegExp($regex, '11');
+ $this->assertRegexMatches($regex, 'a');
+ $this->assertRegexMatches($regex, 'img');
+ $this->assertRegexMatches($regex, 'h1');
+ $this->assertRegexDoesNotMatch($regex, '11');
}
public function testBlockTagName()
{
$regex = '/^' . RegexHelper::PARTIAL_BLOCKTAGNAME . '$/';
- $this->assertRegExp($regex, 'p');
- $this->assertRegExp($regex, 'div');
- $this->assertRegExp($regex, 'h1');
- $this->assertNotRegExp($regex, 'a');
- $this->assertNotRegExp($regex, 'h7');
+ $this->assertRegexMatches($regex, 'p');
+ $this->assertRegexMatches($regex, 'div');
+ $this->assertRegexMatches($regex, 'h1');
+ $this->assertRegexDoesNotMatch($regex, 'a');
+ $this->assertRegexDoesNotMatch($regex, 'h7');
}
public function testAttributeName()
{
$regex = '/^' . RegexHelper::PARTIAL_ATTRIBUTENAME . '$/';
- $this->assertRegExp($regex, 'href');
- $this->assertRegExp($regex, 'class');
- $this->assertRegExp($regex, 'data-src');
- $this->assertNotRegExp($regex, '-key');
+ $this->assertRegexMatches($regex, 'href');
+ $this->assertRegexMatches($regex, 'class');
+ $this->assertRegexMatches($regex, 'data-src');
+ $this->assertRegexDoesNotMatch($regex, '-key');
}
public function testUnquotedValue()
{
$regex = '/^' . RegexHelper::PARTIAL_UNQUOTEDVALUE . '$/';
- $this->assertRegExp($regex, 'foo');
- $this->assertRegExp($regex, 'bar');
- $this->assertNotRegExp($regex, '"baz"');
+ $this->assertRegexMatches($regex, 'foo');
+ $this->assertRegexMatches($regex, 'bar');
+ $this->assertRegexDoesNotMatch($regex, '"baz"');
}
public function testSingleQuotedValue()
{
$regex = '/^' . RegexHelper::PARTIAL_SINGLEQUOTEDVALUE . '$/';
- $this->assertRegExp($regex, '\'foo\'');
- $this->assertRegExp($regex, '\'bar\'');
- $this->assertNotRegExp($regex, '"baz"');
+ $this->assertRegexMatches($regex, '\'foo\'');
+ $this->assertRegexMatches($regex, '\'bar\'');
+ $this->assertRegexDoesNotMatch($regex, '"baz"');
}
public function testDoubleQuotedValue()
{
$regex = '/^' . RegexHelper::PARTIAL_DOUBLEQUOTEDVALUE . '$/';
- $this->assertRegExp($regex, '"foo"');
- $this->assertRegExp($regex, '"bar"');
- $this->assertNotRegExp($regex, '\'baz\'');
+ $this->assertRegexMatches($regex, '"foo"');
+ $this->assertRegexMatches($regex, '"bar"');
+ $this->assertRegexDoesNotMatch($regex, '\'baz\'');
}
public function testAttributeValue()
{
$regex = '/^' . RegexHelper::PARTIAL_ATTRIBUTEVALUE . '$/';
- $this->assertRegExp($regex, 'foo');
- $this->assertRegExp($regex, '\'bar\'');
- $this->assertRegExp($regex, '"baz"');
+ $this->assertRegexMatches($regex, 'foo');
+ $this->assertRegexMatches($regex, '\'bar\'');
+ $this->assertRegexMatches($regex, '"baz"');
}
public function testAttributeValueSpec()
{
$regex = '/^' . RegexHelper::PARTIAL_ATTRIBUTEVALUESPEC . '$/';
- $this->assertRegExp($regex, '=foo');
- $this->assertRegExp($regex, '= foo');
- $this->assertRegExp($regex, ' =foo');
- $this->assertRegExp($regex, ' = foo');
- $this->assertRegExp($regex, '=\'bar\'');
- $this->assertRegExp($regex, '= \'bar\'');
- $this->assertRegExp($regex, ' =\'bar\'');
- $this->assertRegExp($regex, ' = \'bar\'');
- $this->assertRegExp($regex, '="baz"');
- $this->assertRegExp($regex, '= "baz"');
- $this->assertRegExp($regex, ' ="baz"');
- $this->assertRegExp($regex, ' = "baz"');
+ $this->assertRegexMatches($regex, '=foo');
+ $this->assertRegexMatches($regex, '= foo');
+ $this->assertRegexMatches($regex, ' =foo');
+ $this->assertRegexMatches($regex, ' = foo');
+ $this->assertRegexMatches($regex, '=\'bar\'');
+ $this->assertRegexMatches($regex, '= \'bar\'');
+ $this->assertRegexMatches($regex, ' =\'bar\'');
+ $this->assertRegexMatches($regex, ' = \'bar\'');
+ $this->assertRegexMatches($regex, '="baz"');
+ $this->assertRegexMatches($regex, '= "baz"');
+ $this->assertRegexMatches($regex, ' ="baz"');
+ $this->assertRegexMatches($regex, ' = "baz"');
}
public function testAttribute()
{
$regex = '/^' . RegexHelper::PARTIAL_ATTRIBUTE . '$/';
- $this->assertRegExp($regex, ' disabled');
- $this->assertRegExp($regex, ' disabled="disabled"');
- $this->assertRegExp($regex, ' href="http://www.google.com"');
- $this->assertNotRegExp($regex, 'disabled', 'There must be at least one space at the start');
+ $this->assertRegexMatches($regex, ' disabled');
+ $this->assertRegexMatches($regex, ' disabled="disabled"');
+ $this->assertRegexMatches($regex, ' href="http://www.google.com"');
+ $this->assertRegexDoesNotMatch($regex, 'disabled', 'There must be at least one space at the start');
}
public function testOpenTag()
{
$regex = '/^' . RegexHelper::PARTIAL_OPENTAG . '$/';
- $this->assertRegExp($regex, '
');
- $this->assertRegExp($regex, '');
- $this->assertRegExp($regex, '');
- $this->assertNotRegExp($regex, '