| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635 |
- <?php
- /**
- * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
- * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
- *
- * Licensed under The MIT License
- * For full copyright and license information, please see the LICENSE.txt
- * Redistributions of files must retain the above copyright notice
- *
- * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
- * @link https://cakephp.org CakePHP(tm) Project
- * @since 1.2.0
- * @license https://opensource.org/licenses/mit-license.php MIT License
- */
- namespace Cake\Test\TestCase\View\Helper;
- use Cake\Core\Configure;
- use Cake\Core\Plugin;
- use Cake\TestSuite\TestCase;
- use Cake\View\Helper\TextHelper;
- use Cake\View\View;
- /**
- * TextHelperTestObject
- */
- class TextHelperTestObject extends TextHelper
- {
- public function attach(StringMock $string)
- {
- $this->_engine = $string;
- }
- public function engine()
- {
- return $this->_engine;
- }
- }
- /**
- * StringMock class
- */
- class StringMock
- {
- }
- /**
- * TextHelperTest class
- */
- class TextHelperTest extends TestCase
- {
- /**
- * @var \Cake\View\Helper\TextHelper
- */
- public $Text;
- /**
- * setUp method
- *
- * @return void
- */
- public function setUp()
- {
- parent::setUp();
- $this->View = new View();
- $this->Text = new TextHelper($this->View);
- $this->_appNamespace = Configure::read('App.namespace');
- static::setAppNamespace();
- }
- /**
- * tearDown method
- *
- * @return void
- */
- public function tearDown()
- {
- unset($this->Text, $this->View);
- static::setAppNamespace($this->_appNamespace);
- parent::tearDown();
- }
- /**
- * test String class methods are called correctly
- *
- * @return void
- */
- public function testTextHelperProxyMethodCalls()
- {
- $methods = [
- 'stripLinks', 'excerpt', 'toList'
- ];
- $String = $this->getMockBuilder(__NAMESPACE__ . '\StringMock')
- ->setMethods($methods)
- ->getMock();
- $Text = new TextHelperTestObject($this->View, ['engine' => __NAMESPACE__ . '\StringMock']);
- $Text->attach($String);
- foreach ($methods as $method) {
- $String->expects($this->at(0))->method($method);
- $Text->{$method}('who', 'what', 'when', 'where', 'how');
- }
- $methods = [
- 'highlight', 'truncate'
- ];
- $String = $this->getMockBuilder(__NAMESPACE__ . '\StringMock')
- ->setMethods($methods)
- ->getMock();
- $Text = new TextHelperTestObject($this->View, ['engine' => __NAMESPACE__ . '\StringMock']);
- $Text->attach($String);
- foreach ($methods as $method) {
- $String->expects($this->at(0))->method($method);
- $Text->{$method}('who', ['what']);
- }
- $methods = [
- 'tail'
- ];
- $String = $this->getMockBuilder(__NAMESPACE__ . '\StringMock')
- ->setMethods($methods)
- ->getMock();
- $Text = new TextHelperTestObject($this->View, ['engine' => __NAMESPACE__ . '\StringMock']);
- $Text->attach($String);
- foreach ($methods as $method) {
- $String->expects($this->at(0))->method($method);
- $Text->{$method}('who', 1, ['what']);
- }
- }
- /**
- * test engine override
- *
- * @return void
- */
- public function testEngineOverride()
- {
- $Text = new TextHelperTestObject($this->View, ['engine' => 'TestAppEngine']);
- $this->assertInstanceOf('TestApp\Utility\TestAppEngine', $Text->engine());
- Plugin::load('TestPlugin');
- $Text = new TextHelperTestObject($this->View, ['engine' => 'TestPlugin.TestPluginEngine']);
- $this->assertInstanceOf('TestPlugin\Utility\TestPluginEngine', $Text->engine());
- Plugin::unload('TestPlugin');
- }
- /**
- * testAutoLink method
- *
- * @return void
- */
- public function testAutoLink()
- {
- $text = 'The AWWWARD show happened today';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($text, $result);
- $text = 'This is a test text';
- $expected = 'This is a test text';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = 'Text with a partial www.cakephp.org URL and test@cakephp.org email address';
- $result = $this->Text->autoLink($text);
- $expected = 'Text with a partial <a href="http://www.cakephp.org">www.cakephp.org</a> URL and <a href="mailto:test@cakephp\.org">test@cakephp\.org</a> email address';
- $this->assertRegExp('#^' . $expected . '$#', $result);
- $text = 'This is a test text with URL http://www.cakephp.org';
- $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = 'This is a test text with URL http://www.cakephp.org and some more text';
- $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a> and some more text';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = "This is a test text with URL http://www.cakephp.org\tand some more text";
- $expected = "This is a test text with URL <a href=\"http://www.cakephp.org\">http://www.cakephp.org</a>\tand some more text";
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = 'This is a test text with URL http://www.cakephp.org(and some more text)';
- $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = 'This is a test text with URL (http://www.cakephp.org/page/4) in brackets';
- $expected = 'This is a test text with URL (<a href="http://www.cakephp.org/page/4">http://www.cakephp.org/page/4</a>) in brackets';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = 'This is a test text with URL [http://www.cakephp.org/page/4] in square brackets';
- $expected = 'This is a test text with URL [<a href="http://www.cakephp.org/page/4">http://www.cakephp.org/page/4</a>] in square brackets';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = 'This is a test text with URL [http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3] in square brackets';
- $expected = 'This is a test text with URL [<a href="http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3">http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3</a>] in square brackets';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = 'This is a test text with URL ;http://www.cakephp.org/page/4; semi-colon';
- $expected = 'This is a test text with URL ;<a href="http://www.cakephp.org/page/4">http://www.cakephp.org/page/4</a>; semi-colon';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = 'This is a test text with URL (http://www.cakephp.org/page/4/other(thing)) brackets';
- $expected = 'This is a test text with URL (<a href="http://www.cakephp.org/page/4/other(thing)">http://www.cakephp.org/page/4/other(thing)</a>) brackets';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- }
- /**
- * Test mixing URLs and Email addresses in one confusing string.
- *
- * @return void
- */
- public function testAutoLinkMixed()
- {
- $text = 'Text with a url/email http://example.com/store?email=mark@example.com and email.';
- $expected = 'Text with a url/email <a href="http://example.com/store?email=mark@example.com">' .
- 'http://example.com/store?email=mark@example.com</a> and email.';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- }
- /**
- * test autoLink() and options.
- *
- * @return void
- */
- public function testAutoLinkOptions()
- {
- $text = 'This is a test text with URL http://www.cakephp.org';
- $expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>';
- $result = $this->Text->autoLink($text, ['class' => 'link']);
- $this->assertEquals($expected, $result);
- $text = 'This is a test text with URL http://www.cakephp.org';
- $expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link" id="MyLink">http://www.cakephp.org</a>';
- $result = $this->Text->autoLink($text, ['class' => 'link', 'id' => 'MyLink']);
- $this->assertEquals($expected, $result);
- }
- /**
- * Test escaping for autoLink
- *
- * @return void
- */
- public function testAutoLinkEscape()
- {
- $text = 'This is a <b>test</b> text with URL http://www.cakephp.org';
- $expected = 'This is a <b>test</b> text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>';
- $result = $this->Text->autoLink($text);
- $this->assertEquals($expected, $result);
- $text = 'This is a <b>test</b> text with URL http://www.cakephp.org';
- $expected = 'This is a <b>test</b> text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>';
- $result = $this->Text->autoLink($text, ['escape' => false]);
- $this->assertEquals($expected, $result);
- $text = 'test <ul>
- <li>lorem: http://example.org?some</li>
- <li>ipsum: http://othersite.com/abc</li>
- </ul> test';
- $expected = 'test <ul>
- <li>lorem: <a href="http://example.org?some">http://example.org?some</a></li>
- <li>ipsum: <a href="http://othersite.com/abc">http://othersite.com/abc</a></li>
- </ul> test';
- $result = $this->Text->autoLink($text, ['escape' => false]);
- $this->assertEquals($expected, $result);
- }
- /**
- * Data provider for autoLinking
- *
- * @return array
- */
- public static function autoLinkProvider()
- {
- return [
- [
- 'This is a test text',
- 'This is a test text',
- ],
- [
- 'This is a test that includes (www.cakephp.org)',
- 'This is a test that includes (<a href="http://www.cakephp.org">www.cakephp.org</a>)',
- ],
- [
- 'This is a test that includes www.cakephp.org:8080',
- 'This is a test that includes <a href="http://www.cakephp.org:8080">www.cakephp.org:8080</a>',
- ],
- [
- 'This is a test that includes http://de.wikipedia.org/wiki/Kanton_(Schweiz)#fragment',
- 'This is a test that includes <a href="http://de.wikipedia.org/wiki/Kanton_(Schweiz)#fragment">http://de.wikipedia.org/wiki/Kanton_(Schweiz)#fragment</a>',
- ],
- [
- 'This is a test that includes www.wikipedia.org/wiki/Kanton_(Schweiz)#fragment',
- 'This is a test that includes <a href="http://www.wikipedia.org/wiki/Kanton_(Schweiz)#fragment">www.wikipedia.org/wiki/Kanton_(Schweiz)#fragment</a>',
- ],
- [
- 'This is a test that includes Http://example.com/test.php?foo=bar text',
- 'This is a test that includes <a href="Http://example.com/test.php?foo=bar">Http://example.com/test.php?foo=bar</a> text',
- ],
- [
- 'This is a test that includes http://example.com/test.php?foo=bar text',
- 'This is a test that includes <a href="http://example.com/test.php?foo=bar">http://example.com/test.php?foo=bar</a> text',
- ],
- [
- 'This is a test that includes www.example.com/test.php?foo=bar text',
- 'This is a test that includes <a href="http://www.example.com/test.php?foo=bar">www.example.com/test.php?foo=bar</a> text',
- ],
- [
- 'Text with a partial www.cakephp.org URL',
- 'Text with a partial <a href="http://www.cakephp.org">www.cakephp.org</a> URL',
- ],
- [
- 'Text with a partial WWW.cakephp.org URL',
- 'Text with a partial <a href="http://WWW.cakephp.org">WWW.cakephp.org</a> URL',
- ],
- [
- 'Text with a partial WWW.cakephp.org ©, URL',
- 'Text with a partial <a href="http://WWW.cakephp.org">WWW.cakephp.org</a> &copy, URL',
- ],
- [
- 'Text with a url www.cot.ag/cuIb2Q and more',
- 'Text with a url <a href="http://www.cot.ag/cuIb2Q">www.cot.ag/cuIb2Q</a> and more',
- ],
- [
- 'Text with a url http://www.does--not--work.com and more',
- 'Text with a url <a href="http://www.does--not--work.com">http://www.does--not--work.com</a> and more',
- ],
- [
- 'Text with a url http://www.not--work.com and more',
- 'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more',
- ],
- [
- 'Text with a url http://www.sub_domain.domain.pl and more',
- 'Text with a url <a href="http://www.sub_domain.domain.pl">http://www.sub_domain.domain.pl</a> and more',
- ],
- [
- 'Text with a partial www.küchenschöhn-not-working.de URL',
- 'Text with a partial <a href="http://www.küchenschöhn-not-working.de">www.küchenschöhn-not-working.de</a> URL'
- ],
- [
- 'Text with a partial http://www.küchenschöhn-not-working.de URL',
- 'Text with a partial <a href="http://www.küchenschöhn-not-working.de">http://www.küchenschöhn-not-working.de</a> URL'
- ],
- [
- "Text with partial www.cakephp.org\r\nwww.cakephp.org urls and CRLF",
- "Text with partial <a href=\"http://www.cakephp.org\">www.cakephp.org</a>\r\n<a href=\"http://www.cakephp.org\">www.cakephp.org</a> urls and CRLF"
- ],
- [
- 'https://nl.wikipedia.org/wiki/Exploit_(computerbeveiliging)',
- '<a href="https://nl.wikipedia.org/wiki/Exploit_(computerbeveiliging)">https://nl.wikipedia.org/wiki/Exploit_(computerbeveiliging)</a>'
- ],
- [
- 'http://dev.local/threads/search?search_string=this+is+a+test',
- '<a href="http://dev.local/threads/search?search_string=this+is+a+test">http://dev.local/threads/search?search_string=this+is+a+test</a>'
- ],
- [
- 'http://www.ad.nl/show/giel-beelen-heeft-weinig-moeite-met-rijontzegging~acd8b6ed',
- '<a href="http://www.ad.nl/show/giel-beelen-heeft-weinig-moeite-met-rijontzegging~acd8b6ed">http://www.ad.nl/show/giel-beelen-heeft-weinig-moeite-met-rijontzegging~acd8b6ed</a>'
- ],
- [
- 'https://sevvlor.com/page%20not%20found',
- '<a href="https://sevvlor.com/page%20not%20found">https://sevvlor.com/page%20not%20found</a>'
- ],
- [
- 'https://fakedomain.ext/path/#!topic/test',
- '<a href="https://fakedomain.ext/path/#!topic/test">https://fakedomain.ext/path/#!topic/test</a>'
- ],
- [
- 'https://fakedomain.ext/path/#!topic/test;other;tag',
- '<a href="https://fakedomain.ext/path/#!topic/test;other;tag">https://fakedomain.ext/path/#!topic/test;other;tag</a>'
- ],
- [
- 'This is text,https://fakedomain.ext/path/#!topic/test,tag, with a comma',
- 'This is text,<a href="https://fakedomain.ext/path/#!topic/test,tag">https://fakedomain.ext/path/#!topic/test,tag</a>, with a comma'
- ],
- [
- 'This is text https://fakedomain.ext/path/#!topic/path!',
- 'This is text <a href="https://fakedomain.ext/path/#!topic/path">https://fakedomain.ext/path/#!topic/path</a>!'
- ]
- ];
- }
- /**
- * testAutoLinkUrls method
- *
- * @dataProvider autoLinkProvider
- * @return void
- */
- public function testAutoLinkUrls($text, $expected)
- {
- $result = $this->Text->autoLinkUrls($text);
- $this->assertEquals($expected, $result);
- }
- /**
- * Test the options for autoLinkUrls
- *
- * @return void
- */
- public function testAutoLinkUrlsOptions()
- {
- $text = 'Text with a partial www.cakephp.org URL';
- $expected = 'Text with a partial <a href="http://www.cakephp.org" \s*class="link">www.cakephp.org</a> URL';
- $result = $this->Text->autoLinkUrls($text, ['class' => 'link']);
- $this->assertRegExp('#^' . $expected . '$#', $result);
- $text = 'Text with a partial WWW.cakephp.org © URL';
- $expected = 'Text with a partial <a href="http://WWW.cakephp.org"\s*>WWW.cakephp.org</a> © URL';
- $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
- $this->assertRegExp('#^' . $expected . '$#', $result);
- }
- /**
- * Test autoLinkUrls with the escape option.
- *
- * @return void
- */
- public function testAutoLinkUrlsEscape()
- {
- $text = 'Text with a partial <a href="http://www.example.com">http://www.example.com</a> link';
- $expected = 'Text with a partial <a href="http://www.example.com">http://www.example.com</a> link';
- $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
- $this->assertEquals($expected, $result);
- $text = 'Text with a partial <a href="http://www.example.com">www.example.com</a> link';
- $expected = 'Text with a partial <a href="http://www.example.com">www.example.com</a> link';
- $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
- $this->assertEquals($expected, $result);
- $text = 'Text with a partial <a href="http://www.cakephp.org">link</a> link';
- $expected = 'Text with a partial <a href="http://www.cakephp.org">link</a> link';
- $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
- $this->assertEquals($expected, $result);
- $text = 'Text with a partial <iframe src="http://www.cakephp.org" /> link';
- $expected = 'Text with a partial <iframe src="http://www.cakephp.org" /> link';
- $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
- $this->assertEquals($expected, $result);
- $text = 'Text with a partial <iframe src="http://www.cakephp.org" /> link';
- $expected = 'Text with a partial <iframe src="http://www.cakephp.org" /> link';
- $result = $this->Text->autoLinkUrls($text, ['escape' => true]);
- $this->assertEquals($expected, $result);
- $text = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more';
- $expected = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more';
- $result = $this->Text->autoLinkUrls($text, ['escape' => true]);
- $this->assertEquals($expected, $result);
- $text = 'Text with a url www.not-working-www.com and more';
- $expected = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more';
- $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
- $this->assertEquals($expected, $result);
- $text = 'Text with a url http://www.not-working-www.com and more';
- $expected = 'Text with a url <a href="http://www.not-working-www.com">http://www.not-working-www.com</a> and more';
- $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
- $this->assertEquals($expected, $result);
- $text = 'Text with a url http://www.www.not-working-www.com and more';
- $expected = 'Text with a url <a href="http://www.www.not-working-www.com">http://www.www.not-working-www.com</a> and more';
- $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
- $this->assertEquals($expected, $result);
- }
- /**
- * Test autoLinkUrls with query strings.
- *
- * @return void
- */
- public function testAutoLinkUrlsQueryString()
- {
- $text = 'Text with a partial http://www.cakephp.org?product_id=123&foo=bar link';
- $expected = 'Text with a partial <a href="http://www.cakephp.org?product_id=123&foo=bar">http://www.cakephp.org?product_id=123&foo=bar</a> link';
- $result = $this->Text->autoLinkUrls($text);
- $this->assertEquals($expected, $result);
- }
- /**
- * Data provider for autoLinkEmail.
- *
- * @return array
- */
- public function autoLinkEmailProvider()
- {
- return [
- [
- 'This is a test text',
- 'This is a test text',
- ],
- [
- 'email@example.com address',
- '<a href="mailto:email@example.com">email@example.com</a> address',
- ],
- [
- 'email@example.com address',
- '<a href="mailto:email@example.com">email@example.com</a> address',
- ],
- [
- '(email@example.com) address',
- '(<a href="mailto:email@example.com">email@example.com</a>) address',
- ],
- [
- 'Text with email@example.com address',
- 'Text with <a href="mailto:email@example.com">email@example.com</a> address',
- ],
- [
- "Text with o'hare._-bob@example.com address",
- 'Text with <a href="mailto:o'hare._-bob@example.com">o'hare._-bob@example.com</a> address',
- ],
- [
- 'Text with düsentrieb@küchenschöhn-not-working.de address',
- 'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address',
- ],
- [
- 'Text with me@subdomain.küchenschöhn.de address',
- 'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address',
- ],
- [
- 'Text with email@example.com address',
- 'Text with <a href="mailto:email@example.com" class="link">email@example.com</a> address',
- ['class' => 'link'],
- ],
- [
- '<p>mark@example.com</p>',
- '<p><a href="mailto:mark@example.com">mark@example.com</a></p>',
- ['escape' => false]
- ],
- [
- 'Some mark@example.com Text',
- 'Some <a href="mailto:mark@example.com">mark@example.com</a> Text',
- ['escape' => false]
- ],
- ];
- }
- /**
- * testAutoLinkEmails method
- *
- * @param string $text The text to link
- * @param string $expected The expected results.
- * @dataProvider autoLinkEmailProvider
- * @return void
- */
- public function testAutoLinkEmails($text, $expected, $attrs = [])
- {
- $result = $this->Text->autoLinkEmails($text, $attrs);
- $this->assertEquals($expected, $result);
- }
- /**
- * test invalid email addresses.
- *
- * @return void
- */
- public function testAutoLinkEmailInvalid()
- {
- $result = $this->Text->autoLinkEmails('this is a myaddress@gmx-de test');
- $expected = 'this is a myaddress@gmx-de test';
- $this->assertEquals($expected, $result);
- }
- /**
- * testAutoParagraph method
- *
- * @return void
- */
- public function testAutoParagraph()
- {
- $text = 'This is a test text';
- $expected = <<<TEXT
- <p>This is a test text</p>
- TEXT;
- $result = $this->Text->autoParagraph($text);
- $text = 'This is a <br/> <BR> test text';
- $expected = <<<TEXT
- <p>This is a </p>
- <p> test text</p>
- TEXT;
- $result = $this->Text->autoParagraph($text);
- $this->assertTextEquals($expected, $result);
- $result = $this->Text->autoParagraph($text);
- $text = 'This is a <BR id="test"/><br class="test"> test text';
- $expected = <<<TEXT
- <p>This is a </p>
- <p> test text</p>
- TEXT;
- $result = $this->Text->autoParagraph($text);
- $this->assertTextEquals($expected, $result);
- $text = <<<TEXT
- This is a test text.
- This is a line return.
- TEXT;
- $expected = <<<TEXT
- <p>This is a test text.<br />
- This is a line return.</p>
- TEXT;
- $result = $this->Text->autoParagraph($text);
- $this->assertTextEquals($expected, $result);
- $text = <<<TEXT
- This is a test text.
- This is a new line.
- TEXT;
- $expected = <<<TEXT
- <p>This is a test text.</p>
- <p>This is a new line.</p>
- TEXT;
- $result = $this->Text->autoParagraph($text);
- $this->assertTextEquals($expected, $result);
- }
- }
|