* @author Igor V Belousov * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * ------------------------------------------------------------------ */ namespace TOC; class MarkupFixerTest extends \PHPUnit_Framework_TestCase { public function testInstantiateSucceeds() { $obj = new MarkupFixer(); $this->assertInstanceOf('\TOC\MarkupFixer', $obj); } // --------------------------------------------------------------- public function testFixAddsIdsOnlyToElementsWithoutThem() { $obj = new MarkupFixer(); $html = "

No ID

Existing ID

Ignored

"; $this->assertEquals( '

No ID

Existing ID

Ignored

', $obj->fix($html, 1, 2) ); } // --------------------------------------------------------------- public function testFixAddsIdsW3C() { $obj = new MarkupFixer(); $html = "

1 Number and ID

: 123

"; $this->assertEquals( '

1 Number and ID

: 123

', $obj->fix($html, 1, 2) ); } // --------------------------------------------------------------- public function testFixDoesNotDuplicateIdsWhenFixing() { $obj = new MarkupFixer(); $html = "

FooBar

FooBar

FooBar

"; $this->assertEquals( '

FooBar

FooBar

FooBar

', $obj->fix($html, 1, 3) ); } // --------------------------------------------------------------- public function testFixUsesTitleAttributeWhenAvailable() { $obj = new MarkupFixer(); $html = "

No ID

Existing ID

Ignored

"; $this->assertEquals( '

No ID

Existing ID

Ignored

', $obj->fix($html, 1, 2) ); } // --------------------------------------------------------------- public function testFixUsesTitleAttributeWhenAvailableiWithOutTabs() { $obj = new MarkupFixer(); $html = "

No ID

Existing ID

Ignored

"; $this->assertEquals( '

No ID

Existing ID

Ignored

', $obj->fix($html, 1, 2) ); } }