HEADcourier-fixdev-browser-capabilitiespdorelease-0.8
|
Last change
on this file since b138a9b was
b138a9b,
checked in by alecpl <alec@…>, 16 months ago
|
- Add two small tests for html2text converter
|
-
Property mode set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * Test class to test html2text class |
|---|
| 5 | * |
|---|
| 6 | * @package Tests |
|---|
| 7 | */ |
|---|
| 8 | class rcube_test_html2text extends UnitTestCase |
|---|
| 9 | { |
|---|
| 10 | |
|---|
| 11 | function __construct() |
|---|
| 12 | { |
|---|
| 13 | $this->UnitTestCase("HTML-to-Text conversion tests"); |
|---|
| 14 | |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | function test_html2text() |
|---|
| 18 | { |
|---|
| 19 | $data = array( |
|---|
| 20 | 0 => array( |
|---|
| 21 | 'title' => 'Test entry', |
|---|
| 22 | 'in' => '', |
|---|
| 23 | 'out' => '', |
|---|
| 24 | ), |
|---|
| 25 | 1 => array( |
|---|
| 26 | 'title' => 'Basic HTML entities', |
|---|
| 27 | 'in' => '"&', |
|---|
| 28 | 'out' => '"&', |
|---|
| 29 | ), |
|---|
| 30 | 2 => array( |
|---|
| 31 | 'title' => 'HTML entity string', |
|---|
| 32 | 'in' => '&quot;', |
|---|
| 33 | 'out' => '"', |
|---|
| 34 | ), |
|---|
| 35 | 3 => array( |
|---|
| 36 | 'title' => 'HTML entity in STRONG tag', |
|---|
| 37 | 'in' => '<strong>ś</strong>', // Å |
|---|
| 38 | 'out' => 'Å', // upper Å |
|---|
| 39 | ), |
|---|
| 40 | 4 => array( |
|---|
| 41 | 'title' => 'STRONG tag to upper-case conversion', |
|---|
| 42 | 'in' => '<strong>Å</strong>', |
|---|
| 43 | 'out' => 'Å', |
|---|
| 44 | ), |
|---|
| 45 | ); |
|---|
| 46 | |
|---|
| 47 | $ht = new html2text(null, false, false); |
|---|
| 48 | |
|---|
| 49 | foreach ($data as $item) { |
|---|
| 50 | $ht->set_html($item['in']); |
|---|
| 51 | $res = $ht->get_text(); |
|---|
| 52 | $this->assertEqual($item['out'], $res, $item['title']); |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.