Skip to content

Commit

Permalink
EZP-22563: added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dpobel committed Apr 11, 2014
1 parent 343cb40 commit 9513cc1
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
43 changes: 43 additions & 0 deletions extension/ezoe/tests/ezoexmltext_regression.php
Expand Up @@ -188,6 +188,49 @@ public function testHeaderCustomTag()
self::assertEquals( "h2", $header2->item( 0 )->textContent );
}

/**
* Test for EZP-22563
*
* Make sure break inside header is now supported
*
* @link https://jira.ez.no/browse/EZP-22563
*/
public function testHeaderBreak()
{
$parser = new eZOEInputParser();
$input = '<h1>Franz Ferdinand<br>Love Illumination<br>Right Thoughts, Right Words, Right Action</h1>';
$dom = $parser->process( $input );
self::assertInstanceOf( 'DomDocument', $dom );
$lines = $dom->getElementsByTagName( 'line' );

self::assertEquals( 3, $lines->length );
self::assertEquals( "Franz Ferdinand", $lines->item( 0 )->textContent );
self::assertEquals( "Love Illumination", $lines->item( 1 )->textContent );
self::assertEquals( "Right Thoughts, Right Words, Right Action", $lines->item( 2 )->textContent );
}

/**
* Test for EZP-22563
*
* Make sure an header without break is still parsed without any line
* element.
*
* @link https://jira.ez.no/browse/EZP-22563
*/
public function testHeaderNoBreak()
{
$parser = new eZOEInputParser();
$input = '<h1>Franz Ferdinand - Love Illumination</h1>';
$dom = $parser->process( $input );
self::assertInstanceOf( 'DomDocument', $dom );
$lines = $dom->getElementsByTagName( 'line' );
$header = $dom->getElementsByTagName( 'header' );

self::assertEquals( 0, $lines->length );
self::assertEquals( 1, $header->length );
self::assertEquals( "Franz Ferdinand - Love Illumination", $header->item( 0 )->textContent );
}

/**
* Test for EZP-21986
* Make sure a <u> tag is transformed into the underline custom tag.
Expand Down
Expand Up @@ -61,4 +61,48 @@ public function testHeaderCustomTag()
self::assertEquals( "h2", $header2->item( 0 )->textContent );
}

/**
* Test for EZP-22563
*
* Make sure break inside header is now supported
*
* @link https://jira.ez.no/browse/EZP-22563
*/
public function testHeaderBreak()
{
$parser = new eZSimplifiedXMLInputParser( 0, eZXMLInputParser::ERROR_ALL, eZXMLInputParser::ERROR_ALL, true );
$input = '<header level="1">Franz Ferdinand
Love Illumination
Right Thoughts, Right Words, Right Action</header>';
$dom = $parser->process( $input );
self::assertInstanceOf( 'DomDocument', $dom );
$lines = $dom->getElementsByTagName( 'line' );

self::assertEquals( 3, $lines->length );
self::assertEquals( "Franz Ferdinand", $lines->item( 0 )->textContent );
self::assertEquals( "Love Illumination", $lines->item( 1 )->textContent );
self::assertEquals( "Right Thoughts, Right Words, Right Action", $lines->item( 2 )->textContent );
}

/**
* Test for EZP-22563
*
* Make sure an header without break is still parsed without any line
* element.
*
* @link https://jira.ez.no/browse/EZP-22563
*/
public function testHeaderNoBreak()
{
$parser = new eZSimplifiedXMLInputParser( 0 );
$input = '<header level="1">Franz Ferdinand - Love Illumination</header>';
$dom = $parser->process( $input );
self::assertInstanceOf( 'DomDocument', $dom );
$lines = $dom->getElementsByTagName( 'line' );
$header = $dom->getElementsByTagName( 'header' );

self::assertEquals( 0, $lines->length );
self::assertEquals( 1, $header->length );
self::assertEquals( "Franz Ferdinand - Love Illumination", $header->item( 0 )->textContent );
}
}

0 comments on commit 9513cc1

Please sign in to comment.