Add PHP unit tests and page tests.
Run "composer install", then "composer test".
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace Xxx\Tests\Unit;
|
||||
|
||||
use Xxx\Tests\Support\TestCase;
|
||||
|
||||
// html_entity_decode_full() and convert_entity() in lib/convert_entities.inc.php
|
||||
class EntitiesTest extends TestCase {
|
||||
public function testNamedEntitiesAreDecoded(): void {
|
||||
$this->assertSame("Wait\u{2026} \u{2014} \u{201C}yes\u{201D}", html_entity_decode_full('Wait… — “yes”'));
|
||||
}
|
||||
|
||||
public function testNumericEntitiesAreDecoded(): void {
|
||||
$this->assertSame("\u{2013} A", html_entity_decode_full('– A'));
|
||||
}
|
||||
|
||||
public function testTheXmlEntitiesAreDecoded(): void {
|
||||
$this->assertSame('<a> & "b"', html_entity_decode_full('<a> & "b"'));
|
||||
}
|
||||
|
||||
public function testSingleQuotesStayEncodedByDefault(): void {
|
||||
$this->assertSame(''', html_entity_decode_full('''));
|
||||
$this->assertSame("'", html_entity_decode_full(''', ENT_QUOTES));
|
||||
}
|
||||
|
||||
public function testUnknownEntitiesAreDropped(): void {
|
||||
$this->assertSame('ab', html_entity_decode_full('a&bogus;b'));
|
||||
}
|
||||
|
||||
public function testEntityNamesAreCaseSensitive(): void {
|
||||
$this->assertSame("\u{00E8}\u{00C8}", html_entity_decode_full('èÈ'));
|
||||
}
|
||||
|
||||
public function testConvertEntity(): void {
|
||||
$this->assertSame('…', convert_entity(array('…', 'hellip')));
|
||||
$this->assertSame('', convert_entity(array('&bogus;', 'bogus')));
|
||||
$this->assertSame('&bogus;', convert_entity(array('&bogus;', 'bogus'), FALSE));
|
||||
}
|
||||
|
||||
public function testTextWithoutEntitiesIsUnchanged(): void {
|
||||
$this->assertSame('Plain & simple? No: plain.', html_entity_decode_full('Plain & simple? No: plain.'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user