PHPUnit_TestCase( $name ); } // all the methods of HTML class are static, // so we don't need any setUp() and tearDown() methods here /** * Test the general HTML::element method */ function testElement() { $this->assertEquals( "", HTML::element( "foo" ) ); $this->assertEquals( "", HTML::element( "Foo", "" ) ); $this->assertEquals( "bar", HTML::element( "foo", "bar" ) ); $this->assertEquals( "bar", HTML::element( "foo", "bar", array() ) ); $this->assertEquals( 'bar', HTML::element( "foo", "bar", array( "attr" => "value" ) ) ); $this->assertEquals( '', HTML::element( "foo", null, array( "attr1" => "value1", "attr2" => "value2" ) ) ); // test element inside element $this->assertEquals( '', HTML::element( "foo", HTML::element( "bar", HTML::element( "baz" ) ) ) ); } /** * Test method for creating links */ function testA() { // simple link $this->assertEquals( 'example', HTML::a( "http://www.example.com", "example" ) ); // link with title $this->assertEquals( 'John', HTML::a( "mailto:john@example.com", "John", "send e-mail to John" ) ); } /** * Test method for creating abbreviations */ function testAbbr() { // simple abbr $this->assertEquals( 'PHP', HTML::abbr( "PHP" ) ); // abbr with title $this->assertEquals( 'PHP', HTML::abbr( "PHP", "PHP Hypertext Preprocessor" ) ); } /** * Test method for creating strong emphasis */ function testStrong() { $this->assertEquals( 'Hei!', HTML::strong( "Hei!" ) ); } /** * Test method for creating error messages */ function testError() { $this->assertEquals( '

Error on line #128

', HTML::error( "Error on line #128" ) ); $this->assertEquals( 'Error on line #128', HTML::error( "Error on line #128", false ) ); } /** * Test method for creating notice messages */ function testNotice() { $this->assertEquals( '

Operation completed with success.

', HTML::notice( "Operation completed with success." ) ); $this->assertEquals( 'Operation completed with success.', HTML::notice( "Operation completed with success.", false ) ); } /** * Test method for creating paragraphs */ function testP() { $this->assertEquals( '

Hello, world!

', HTML::p( "Hello, world!" ) ); } /** * Test methods for creating headings */ function testH() { $this->assertEquals( '

Heading 1

', HTML::h1( "Heading 1" ) ); $this->assertEquals( '

Heading 2

', HTML::h2( "Heading 2" ) ); $this->assertEquals( '

Heading 3

', HTML::h3( "Heading 3" ) ); } /** * Test method for list items */ function testLi() { $this->assertEquals( '
  • Hello, world!
  • ', HTML::li( "Hello, world!", array("class" => "first-child") ) ); } /** * Test method for creating multiple elements */ function testMultiElement() { $this->assertEquals( '

    line 1

    line 2

    ', HTML::multiElement( "p", array("line 1", "line 2") ) ); } /** * Test method for unordered list */ function testUl() { $this->assertEquals( '', HTML::ul( "Item 1", "Item 2", "Item 3" ) ); } /** * Test method for ordered list */ function testOl() { $this->assertEquals( '
    1. Item 1
    2. Item 2
    3. Item 3
    ', HTML::ol( "Item 1", "Item 2", "Item 3" ) ); } /** * Test methods for definition list */ function testDl() { $this->assertEquals( '
    Hello, world!
    A canonical first program.
    ', HTML::dl( HTML::dt("Hello, world!"), HTML::dd("A canonical first program.") ) ); } /** * Test methods for actionList */ function testActionList() { $this->assertEquals( '', HTML::backLink( "foo", "bar", STANDALONE ) ); $this->assertEquals( '
  • bar
  • ', HTML::backLink( "foo", "bar" ) ); $this->assertEquals( '', HTML::newLink( "foo", "bar", STANDALONE ) ); $this->assertEquals( '
  • bar
  • ', HTML::newLink( "foo", "bar" ) ); $this->assertEquals( '', HTML::newFolderLink( "foo", "bar", STANDALONE ) ); $this->assertEquals( '
  • bar
  • ', HTML::newFolderLink( "foo", "bar" ) ); $this->assertEquals( HTML::actionList( HTML::actionLink("foo", "bar", "new") ), HTML::newLink( "foo", "bar", STANDALONE ) ); } /** * Test methods for error pages */ function testErrorPages() { $this->assertEquals( '

    Error!

    Foo is bar. Sorry.

    ', HTML::errorPage( "Foo is bar. Sorry." ) ); $this->assertEquals( '

    Access denied!

    No more beer for you.

    ', HTML::accessDeniedPage( "No more beer for you." ) ); } } ?>