[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace dokuwiki\test\Form; 4 5 use dokuwiki\Form; 6 use DOMWrap\Document; 7 8 class ButtonElementTest extends \DokuWikiTest 9 { 10 11 function testSimple() 12 { 13 $form = new Form\Form(); 14 $form->addButton('foo', 'Hello <b>World</b>')->val('bam')->attr('type', 'submit'); 15 16 $html = $form->toHTML(); 17 $pq = (new Document())->html($html); 18 19 $input = $pq->find('button[name=foo]'); 20 $this->assertTrue($input->count() == 1); 21 $this->assertEquals('bam', $input->attr('value')); 22 $this->assertEquals('submit', $input->attr('type')); 23 $this->assertEquals('Hello <b>World</b>', $input->text()); // tags were escaped 24 25 $b = $input->find('b'); // no tags found 26 $this->assertTrue($b->count() == 0); 27 } 28 29 function testHtml() 30 { 31 $form = new Form\Form(); 32 $form->addButtonHTML('foo', 'Hello <b>World</b>')->val('bam')->attr('type', 'submit'); 33 34 $html = $form->toHTML(); 35 $pq = (new Document())->html($html); 36 37 $input = $pq->find('button[name=foo]'); 38 $this->assertTrue($input->count() == 1); 39 $this->assertEquals('bam', $input->attr('value')); 40 $this->assertEquals('submit', $input->attr('type')); 41 $this->assertEquals('Hello World', $input->text()); // tags are stripped here 42 43 $b = $input->find('b'); // tags found 44 $this->assertTrue($b->count() == 1); 45 } 46 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body