TextHelperTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <?php
  2. /**
  3. * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
  12. * @since 1.2.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase\View\Helper;
  16. use Cake\Core\App;
  17. use Cake\Core\Configure;
  18. use Cake\Core\Plugin;
  19. use Cake\TestSuite\TestCase;
  20. use Cake\View\Helper\TextHelper;
  21. use Cake\View\View;
  22. /**
  23. * Class TextHelperTestObject
  24. *
  25. */
  26. class TextHelperTestObject extends TextHelper
  27. {
  28. public function attach(StringMock $string)
  29. {
  30. $this->_engine = $string;
  31. }
  32. public function engine()
  33. {
  34. return $this->_engine;
  35. }
  36. }
  37. /**
  38. * StringMock class
  39. *
  40. */
  41. class StringMock
  42. {
  43. }
  44. /**
  45. * TextHelperTest class
  46. *
  47. */
  48. class TextHelperTest extends TestCase
  49. {
  50. /**
  51. * setUp method
  52. *
  53. * @return void
  54. */
  55. public function setUp()
  56. {
  57. parent::setUp();
  58. $this->View = new View();
  59. $this->Text = new TextHelper($this->View);
  60. $this->_appNamespace = Configure::read('App.namespace');
  61. Configure::write('App.namespace', 'TestApp');
  62. }
  63. /**
  64. * tearDown method
  65. *
  66. * @return void
  67. */
  68. public function tearDown()
  69. {
  70. unset($this->Text, $this->View);
  71. Configure::write('App.namespace', $this->_appNamespace);
  72. parent::tearDown();
  73. }
  74. /**
  75. * test String class methods are called correctly
  76. *
  77. * @return void
  78. */
  79. public function testTextHelperProxyMethodCalls()
  80. {
  81. $methods = [
  82. 'stripLinks', 'excerpt', 'toList'
  83. ];
  84. $String = $this->getMock(__NAMESPACE__ . '\StringMock', $methods);
  85. $Text = new TextHelperTestObject($this->View, ['engine' => __NAMESPACE__ . '\StringMock']);
  86. $Text->attach($String);
  87. foreach ($methods as $method) {
  88. $String->expects($this->at(0))->method($method);
  89. $Text->{$method}('who', 'what', 'when', 'where', 'how');
  90. }
  91. $methods = [
  92. 'highlight', 'truncate'
  93. ];
  94. $String = $this->getMock(__NAMESPACE__ . '\StringMock', $methods);
  95. $Text = new TextHelperTestObject($this->View, ['engine' => __NAMESPACE__ . '\StringMock']);
  96. $Text->attach($String);
  97. foreach ($methods as $method) {
  98. $String->expects($this->at(0))->method($method);
  99. $Text->{$method}('who', ['what']);
  100. }
  101. $methods = [
  102. 'tail'
  103. ];
  104. $String = $this->getMock(__NAMESPACE__ . '\StringMock', $methods);
  105. $Text = new TextHelperTestObject($this->View, ['engine' => __NAMESPACE__ . '\StringMock']);
  106. $Text->attach($String);
  107. foreach ($methods as $method) {
  108. $String->expects($this->at(0))->method($method);
  109. $Text->{$method}('who', 1, ['what']);
  110. }
  111. }
  112. /**
  113. * test engine override
  114. *
  115. * @return void
  116. */
  117. public function testEngineOverride()
  118. {
  119. $Text = new TextHelperTestObject($this->View, ['engine' => 'TestAppEngine']);
  120. $this->assertInstanceOf('TestApp\Utility\TestAppEngine', $Text->engine());
  121. Plugin::load('TestPlugin');
  122. $Text = new TextHelperTestObject($this->View, ['engine' => 'TestPlugin.TestPluginEngine']);
  123. $this->assertInstanceOf('TestPlugin\Utility\TestPluginEngine', $Text->engine());
  124. Plugin::unload('TestPlugin');
  125. }
  126. /**
  127. * testAutoLink method
  128. *
  129. * @return void
  130. */
  131. public function testAutoLink()
  132. {
  133. $text = 'This is a test text';
  134. $expected = 'This is a test text';
  135. $result = $this->Text->autoLink($text);
  136. $this->assertEquals($expected, $result);
  137. $text = 'Text with a partial www.cakephp.org URL and test@cakephp.org email address';
  138. $result = $this->Text->autoLink($text);
  139. $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';
  140. $this->assertRegExp('#^' . $expected . '$#', $result);
  141. $text = 'This is a test text with URL http://www.cakephp.org';
  142. $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>';
  143. $result = $this->Text->autoLink($text);
  144. $this->assertEquals($expected, $result);
  145. $text = 'This is a test text with URL http://www.cakephp.org and some more text';
  146. $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a> and some more text';
  147. $result = $this->Text->autoLink($text);
  148. $this->assertEquals($expected, $result);
  149. $text = "This is a test text with URL http://www.cakephp.org\tand some more text";
  150. $expected = "This is a test text with URL <a href=\"http://www.cakephp.org\">http://www.cakephp.org</a>\tand some more text";
  151. $result = $this->Text->autoLink($text);
  152. $this->assertEquals($expected, $result);
  153. $text = 'This is a test text with URL http://www.cakephp.org(and some more text)';
  154. $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)';
  155. $result = $this->Text->autoLink($text);
  156. $this->assertEquals($expected, $result);
  157. $text = 'This is a test text with URL (http://www.cakephp.org/page/4) in brackets';
  158. $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';
  159. $result = $this->Text->autoLink($text);
  160. $this->assertEquals($expected, $result);
  161. $text = 'This is a test text with URL [http://www.cakephp.org/page/4] in square brackets';
  162. $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';
  163. $result = $this->Text->autoLink($text);
  164. $this->assertEquals($expected, $result);
  165. $text = 'This is a test text with URL [http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3] in square brackets';
  166. $expected = 'This is a test text with URL [<a href="http://www.example.com?aParam[]=value1&amp;aParam[]=value2&amp;aParam[]=value3">http://www.example.com?aParam[]=value1&amp;aParam[]=value2&amp;aParam[]=value3</a>] in square brackets';
  167. $result = $this->Text->autoLink($text);
  168. $this->assertEquals($expected, $result);
  169. $text = 'This is a test text with URL ;http://www.cakephp.org/page/4; semi-colon';
  170. $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';
  171. $result = $this->Text->autoLink($text);
  172. $this->assertEquals($expected, $result);
  173. $text = 'This is a test text with URL (http://www.cakephp.org/page/4/other(thing)) brackets';
  174. $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';
  175. $result = $this->Text->autoLink($text);
  176. $this->assertEquals($expected, $result);
  177. }
  178. /**
  179. * Test mixing URLs and Email addresses in one confusing string.
  180. *
  181. * @return void
  182. */
  183. public function testAutoLinkMixed()
  184. {
  185. $text = 'Text with a url/email http://example.com/store?email=mark@example.com and email.';
  186. $expected = 'Text with a url/email <a href="http://example.com/store?email=mark@example.com">' .
  187. 'http://example.com/store?email=mark@example.com</a> and email.';
  188. $result = $this->Text->autoLink($text);
  189. $this->assertEquals($expected, $result);
  190. }
  191. /**
  192. * test autoLink() and options.
  193. *
  194. * @return void
  195. */
  196. public function testAutoLinkOptions()
  197. {
  198. $text = 'This is a test text with URL http://www.cakephp.org';
  199. $expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>';
  200. $result = $this->Text->autoLink($text, ['class' => 'link']);
  201. $this->assertEquals($expected, $result);
  202. $text = 'This is a test text with URL http://www.cakephp.org';
  203. $expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link" id="MyLink">http://www.cakephp.org</a>';
  204. $result = $this->Text->autoLink($text, ['class' => 'link', 'id' => 'MyLink']);
  205. $this->assertEquals($expected, $result);
  206. }
  207. /**
  208. * Test escaping for autoLink
  209. *
  210. * @return void
  211. */
  212. public function testAutoLinkEscape()
  213. {
  214. $text = 'This is a <b>test</b> text with URL http://www.cakephp.org';
  215. $expected = 'This is a &lt;b&gt;test&lt;/b&gt; text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>';
  216. $result = $this->Text->autoLink($text);
  217. $this->assertEquals($expected, $result);
  218. $text = 'This is a <b>test</b> text with URL http://www.cakephp.org';
  219. $expected = 'This is a <b>test</b> text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>';
  220. $result = $this->Text->autoLink($text, ['escape' => false]);
  221. $this->assertEquals($expected, $result);
  222. $text = 'test <ul>
  223. <li>lorem: http://example.org?some</li>
  224. <li>ipsum: http://othersite.com/abc</li>
  225. </ul> test';
  226. $expected = 'test <ul>
  227. <li>lorem: <a href="http://example.org?some">http://example.org?some</a></li>
  228. <li>ipsum: <a href="http://othersite.com/abc">http://othersite.com/abc</a></li>
  229. </ul> test';
  230. $result = $this->Text->autoLink($text, ['escape' => false]);
  231. $this->assertEquals($expected, $result);
  232. }
  233. /**
  234. * Data provider for autoLinking
  235. *
  236. * @return array
  237. */
  238. public static function autoLinkProvider()
  239. {
  240. return [
  241. [
  242. 'This is a test text',
  243. 'This is a test text',
  244. ],
  245. [
  246. 'This is a test that includes (www.cakephp.org)',
  247. 'This is a test that includes (<a href="http://www.cakephp.org">www.cakephp.org</a>)',
  248. ],
  249. [
  250. 'This is a test that includes www.cakephp.org:8080',
  251. 'This is a test that includes <a href="http://www.cakephp.org:8080">www.cakephp.org:8080</a>',
  252. ],
  253. [
  254. 'This is a test that includes http://de.wikipedia.org/wiki/Kanton_(Schweiz)#fragment',
  255. '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>',
  256. ],
  257. [
  258. 'This is a test that includes www.wikipedia.org/wiki/Kanton_(Schweiz)#fragment',
  259. 'This is a test that includes <a href="http://www.wikipedia.org/wiki/Kanton_(Schweiz)#fragment">www.wikipedia.org/wiki/Kanton_(Schweiz)#fragment</a>',
  260. ],
  261. [
  262. 'This is a test that includes http://example.com/test.php?foo=bar text',
  263. 'This is a test that includes <a href="http://example.com/test.php?foo=bar">http://example.com/test.php?foo=bar</a> text',
  264. ],
  265. [
  266. 'This is a test that includes www.example.com/test.php?foo=bar text',
  267. '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',
  268. ],
  269. [
  270. 'Text with a partial www.cakephp.org URL',
  271. 'Text with a partial <a href="http://www.cakephp.org">www.cakephp.org</a> URL',
  272. ],
  273. [
  274. 'Text with a partial WWW.cakephp.org URL',
  275. 'Text with a partial <a href="http://WWW.cakephp.org">WWW.cakephp.org</a> URL',
  276. ],
  277. [
  278. 'Text with a partial WWW.cakephp.org &copy, URL',
  279. 'Text with a partial <a href="http://WWW.cakephp.org">WWW.cakephp.org</a> &amp;copy, URL',
  280. ],
  281. [
  282. 'Text with a url www.cot.ag/cuIb2Q and more',
  283. 'Text with a url <a href="http://www.cot.ag/cuIb2Q">www.cot.ag/cuIb2Q</a> and more',
  284. ],
  285. [
  286. 'Text with a url http://www.does--not--work.com and more',
  287. 'Text with a url <a href="http://www.does--not--work.com">http://www.does--not--work.com</a> and more',
  288. ],
  289. [
  290. 'Text with a url http://www.not--work.com and more',
  291. 'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more',
  292. ],
  293. [
  294. 'Text with a url http://www.sub_domain.domain.pl and more',
  295. 'Text with a url <a href="http://www.sub_domain.domain.pl">http://www.sub_domain.domain.pl</a> and more',
  296. ],
  297. [
  298. 'Text with a partial www.küchenschöhn-not-working.de URL',
  299. 'Text with a partial <a href="http://www.küchenschöhn-not-working.de">www.küchenschöhn-not-working.de</a> URL'
  300. ],
  301. [
  302. 'Text with a partial http://www.küchenschöhn-not-working.de URL',
  303. 'Text with a partial <a href="http://www.küchenschöhn-not-working.de">http://www.küchenschöhn-not-working.de</a> URL'
  304. ],
  305. ];
  306. }
  307. /**
  308. * testAutoLinkUrls method
  309. *
  310. * @dataProvider autoLinkProvider
  311. * @return void
  312. */
  313. public function testAutoLinkUrls($text, $expected)
  314. {
  315. $result = $this->Text->autoLinkUrls($text);
  316. $this->assertEquals($expected, $result);
  317. }
  318. /**
  319. * Test the options for autoLinkUrls
  320. *
  321. * @return void
  322. */
  323. public function testAutoLinkUrlsOptions()
  324. {
  325. $text = 'Text with a partial www.cakephp.org URL';
  326. $expected = 'Text with a partial <a href="http://www.cakephp.org" \s*class="link">www.cakephp.org</a> URL';
  327. $result = $this->Text->autoLinkUrls($text, ['class' => 'link']);
  328. $this->assertRegExp('#^' . $expected . '$#', $result);
  329. $text = 'Text with a partial WWW.cakephp.org &copy; URL';
  330. $expected = 'Text with a partial <a href="http://WWW.cakephp.org"\s*>WWW.cakephp.org</a> &copy; URL';
  331. $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
  332. $this->assertRegExp('#^' . $expected . '$#', $result);
  333. }
  334. /**
  335. * Test autoLinkUrls with the escape option.
  336. *
  337. * @return void
  338. */
  339. public function testAutoLinkUrlsEscape()
  340. {
  341. $text = 'Text with a partial <a href="http://www.example.com">http://www.example.com</a> link';
  342. $expected = 'Text with a partial <a href="http://www.example.com">http://www.example.com</a> link';
  343. $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
  344. $this->assertEquals($expected, $result);
  345. $text = 'Text with a partial <a href="http://www.example.com">www.example.com</a> link';
  346. $expected = 'Text with a partial <a href="http://www.example.com">www.example.com</a> link';
  347. $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
  348. $this->assertEquals($expected, $result);
  349. $text = 'Text with a partial <a href="http://www.cakephp.org">link</a> link';
  350. $expected = 'Text with a partial <a href="http://www.cakephp.org">link</a> link';
  351. $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
  352. $this->assertEquals($expected, $result);
  353. $text = 'Text with a partial <iframe src="http://www.cakephp.org" /> link';
  354. $expected = 'Text with a partial <iframe src="http://www.cakephp.org" /> link';
  355. $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
  356. $this->assertEquals($expected, $result);
  357. $text = 'Text with a partial <iframe src="http://www.cakephp.org" /> link';
  358. $expected = 'Text with a partial &lt;iframe src=&quot;http://www.cakephp.org&quot; /&gt; link';
  359. $result = $this->Text->autoLinkUrls($text, ['escape' => true]);
  360. $this->assertEquals($expected, $result);
  361. $text = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more';
  362. $expected = 'Text with a url &lt;a href=&quot;http://www.not-working-www.com&quot;&gt;www.not-working-www.com&lt;/a&gt; and more';
  363. $result = $this->Text->autoLinkUrls($text, ['escape' => true]);
  364. $this->assertEquals($expected, $result);
  365. $text = 'Text with a url www.not-working-www.com and more';
  366. $expected = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more';
  367. $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
  368. $this->assertEquals($expected, $result);
  369. $text = 'Text with a url http://www.not-working-www.com and more';
  370. $expected = 'Text with a url <a href="http://www.not-working-www.com">http://www.not-working-www.com</a> and more';
  371. $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
  372. $this->assertEquals($expected, $result);
  373. $text = 'Text with a url http://www.www.not-working-www.com and more';
  374. $expected = 'Text with a url <a href="http://www.www.not-working-www.com">http://www.www.not-working-www.com</a> and more';
  375. $result = $this->Text->autoLinkUrls($text, ['escape' => false]);
  376. $this->assertEquals($expected, $result);
  377. }
  378. /**
  379. * Test autoLinkUrls with query strings.
  380. *
  381. * @return void
  382. */
  383. public function testAutoLinkUrlsQueryString()
  384. {
  385. $text = 'Text with a partial http://www.cakephp.org?product_id=123&foo=bar link';
  386. $expected = 'Text with a partial <a href="http://www.cakephp.org?product_id=123&amp;foo=bar">http://www.cakephp.org?product_id=123&amp;foo=bar</a> link';
  387. $result = $this->Text->autoLinkUrls($text);
  388. $this->assertEquals($expected, $result);
  389. }
  390. /**
  391. * Data provider for autoLinkEmail.
  392. *
  393. * @return void
  394. */
  395. public function autoLinkEmailProvider()
  396. {
  397. return [
  398. [
  399. 'This is a test text',
  400. 'This is a test text',
  401. ],
  402. [
  403. 'email@example.com address',
  404. '<a href="mailto:email@example.com">email@example.com</a> address',
  405. ],
  406. [
  407. 'email@example.com address',
  408. '<a href="mailto:email@example.com">email@example.com</a> address',
  409. ],
  410. [
  411. '(email@example.com) address',
  412. '(<a href="mailto:email@example.com">email@example.com</a>) address',
  413. ],
  414. [
  415. 'Text with email@example.com address',
  416. 'Text with <a href="mailto:email@example.com">email@example.com</a> address',
  417. ],
  418. [
  419. "Text with o'hare._-bob@example.com address",
  420. 'Text with <a href="mailto:o&#039;hare._-bob@example.com">o&#039;hare._-bob@example.com</a> address',
  421. ],
  422. [
  423. 'Text with düsentrieb@küchenschöhn-not-working.de address',
  424. 'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address',
  425. ],
  426. [
  427. 'Text with me@subdomain.küchenschöhn.de address',
  428. 'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address',
  429. ],
  430. [
  431. 'Text with email@example.com address',
  432. 'Text with <a href="mailto:email@example.com" class="link">email@example.com</a> address',
  433. ['class' => 'link'],
  434. ],
  435. [
  436. '<p>mark@example.com</p>',
  437. '<p><a href="mailto:mark@example.com">mark@example.com</a></p>',
  438. ['escape' => false]
  439. ],
  440. [
  441. 'Some&nbsp;mark@example.com&nbsp;Text',
  442. 'Some&nbsp;<a href="mailto:mark@example.com">mark@example.com</a>&nbsp;Text',
  443. ['escape' => false]
  444. ],
  445. ];
  446. }
  447. /**
  448. * testAutoLinkEmails method
  449. *
  450. * @param string $text The text to link
  451. * @param string $expected The expected results.
  452. * @dataProvider autoLinkEmailProvider
  453. * @return void
  454. */
  455. public function testAutoLinkEmails($text, $expected, $attrs = [])
  456. {
  457. $result = $this->Text->autoLinkEmails($text, $attrs);
  458. $this->assertEquals($expected, $result);
  459. }
  460. /**
  461. * test invalid email addresses.
  462. *
  463. * @return void
  464. */
  465. public function testAutoLinkEmailInvalid()
  466. {
  467. $result = $this->Text->autoLinkEmails('this is a myaddress@gmx-de test');
  468. $expected = 'this is a myaddress@gmx-de test';
  469. $this->assertEquals($expected, $result);
  470. }
  471. /**
  472. * testAutoParagraph method
  473. *
  474. * @return void
  475. */
  476. public function testAutoParagraph()
  477. {
  478. $text = 'This is a test text';
  479. $expected = <<<TEXT
  480. <p>This is a test text</p>
  481. TEXT;
  482. $result = $this->Text->autoParagraph($text);
  483. $text = 'This is a <br/> <BR> test text';
  484. $expected = <<<TEXT
  485. <p>This is a </p>
  486. <p> test text</p>
  487. TEXT;
  488. $result = $this->Text->autoParagraph($text);
  489. $this->assertTextEquals($expected, $result);
  490. $result = $this->Text->autoParagraph($text);
  491. $text = 'This is a <BR id="test"/><br class="test"> test text';
  492. $expected = <<<TEXT
  493. <p>This is a </p>
  494. <p> test text</p>
  495. TEXT;
  496. $result = $this->Text->autoParagraph($text);
  497. $this->assertTextEquals($expected, $result);
  498. $text = <<<TEXT
  499. This is a test text.
  500. This is a line return.
  501. TEXT;
  502. $expected = <<<TEXT
  503. <p>This is a test text.<br />
  504. This is a line return.</p>
  505. TEXT;
  506. $result = $this->Text->autoParagraph($text);
  507. $this->assertTextEquals($expected, $result);
  508. $text = <<<TEXT
  509. This is a test text.
  510. This is a new line.
  511. TEXT;
  512. $expected = <<<TEXT
  513. <p>This is a test text.</p>
  514. <p>This is a new line.</p>
  515. TEXT;
  516. $result = $this->Text->autoParagraph($text);
  517. $this->assertTextEquals($expected, $result);
  518. }
  519. }