tm = $this->make('e107TinyMceParser'); } catch (Exception $e) { $this->fail("Couldn't load e107TinyMceParser object"); } } public function testToHtmlOnPlain() { $test = 'Plain text paragraph 1 Plain text "paragraph" 2 Plain text paragraph 3 '; $actual = $this->tm->toHTML($test); $expected = 'Plain text paragraph 1

Plain text "paragraph" 2

Plain text paragraph 3
'; $this->assertEquals($expected, $actual, "Plain text line-breaks to HTML failed in the TinyMce editor." ); } public function testToHtmlOnBbcode() { $test = '[b]Bold text[/b] paragraph 2 paragraph 3'; $actual = $this->tm->toHTML($test); $expected = "Bold text

paragraph 2

paragraph 3"; $this->assertEquals($expected, $actual, "Bbcode to HTML failed in the TinyMce editor." ); } /** * Test parsing of input from user via TinyMce. */ public function testToDB() { $this->tm->setHtmlClass(e_UC_ADMIN); $test_1 = ' 2 '; $actual_1 = $this->tm->toDB($test_1); $expected_1 = '[html] 2[/html]'; // echo $actual; $this->assertEquals($expected_1, $actual_1); $test_2 = '

E107 AboutSome text

E107 AboutSome other text

'; $actual_2 = $this->tm->toDB($test_2); $expected_2 = '[html]

[img class=bbcode-img-right&width=300]{e_MEDIA_IMAGE}2017-11/e107_about.png[/img]Some text

[img class=bbcode-img-left&width=600]{e_MEDIA_IMAGE}2017-11/e107_about.png[/img]Some other text

[/html]'; $this->assertEquals($expected_2, $actual_2); $test_3 = "

Nikdy nehovor, že niečo nejde, pretože sa vždy nájde blbec, čo to urobí.

"; $actual_3 = $this->tm->toDB($test_3); $expected_3 = "[html]

Nikdy nehovor, že niečo nejde, pretože sa vždy nájde blbec, čo to urobí.

[/html]"; $this->assertEquals($expected_3, $actual_3); $result3 = $this->tm->toHTML($actual_3); $this->assertEquals($test_3, $result3); } /** * Simulate TinyMce usage by a user without access to post HTML. */ function testToDBUser() { $text = "An example,

Thank you for your purchase.
Your order reference number is: #{ORDER_DATA: order_ref}

Merchant Customer
{ORDER_MERCHANT_INFO}

Billing address

{ORDER_DATA: cust_firstname} {ORDER_DATA: cust_lastname}

"; global $_E107; $_E107['phpunit'] = true; // enable the user of check_class(); $this->tm->setHtmlClass(e_UC_NOBODY); $result = $this->tm->toDB($text); $_E107['phpunit'] = false; } function testtoDBOnScriptTags() { $this->tm->setHtmlClass(e_UC_ADMIN); // test parsing of scripts. $string = '

'; $result = $this->tm->toDB($string); $this->assertSame('[html]'.$string.'[/html]', $result); $result = $this->tm->toHTML($string); $this->assertSame($string, $result); } public function testParsingofTable() { // ----------- $string = "Hello {ORDER_DATA: cust_firstname} {ORDER_DATA: cust_lastname},

Thank you for your purchase.
Your order reference number is: #{ORDER_DATA: order_ref}

Merchant Customer
{ORDER_MERCHANT_INFO}

Billing address

{ORDER_DATA: cust_firstname} {ORDER_DATA: cust_lastname}
{ORDER_DATA: cust_company}
{ORDER_DATA: cust_address}
{ORDER_DATA: cust_city} {ORDER_DATA: cust_state} {ORDER_DATA: cust_zip}
{ORDER_DATA: cust_country}

Shipping address

{ORDER_DATA: ship_firstname} {ORDER_DATA: ship_lastname}
{ORDER_DATA: ship_company}
{ORDER_DATA: ship_address}
{ORDER_DATA: ship_city} {ORDER_DATA: ship_state} {ORDER_DATA: ship_zip}
{ORDER_DATA: ship_country}
"; $this->tm->setHtmlClass(254); $result = $this->tm->toDB($string); $this->assertSame('[html]'.$string.'[/html]', $result); $result = $this->tm->toHTML($string); $this->assertSame($string, $result); } }