BootstrapTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?php
  2. namespace Tools\Test\TestCase;
  3. use Cake\Controller\Controller;
  4. use Cake\Network\Request;
  5. use Cake\Network\Response;
  6. use Cake\Routing\Router;
  7. use DateTime;
  8. use Tools\TestSuite\TestCase;
  9. use Tools\View\RssView;
  10. /**
  11. * RssViewTest
  12. */
  13. class BootstrapTest extends TestCase {
  14. /**
  15. * @return void
  16. */
  17. public function testIsEmpty() {
  18. $result = isEmpty(new DateTime(date(FORMAT_DB_DATE)));
  19. $this->assertFalse($result);
  20. }
  21. /**
  22. * BootstrapTest::testStartsWith()
  23. *
  24. * return void
  25. */
  26. public function testStartsWith() {
  27. $strings = [
  28. [
  29. 'auto',
  30. 'au',
  31. true
  32. ],
  33. [
  34. 'auto',
  35. 'ut',
  36. false
  37. ],
  38. [
  39. 'Auto',
  40. 'au',
  41. true
  42. ],
  43. [
  44. 'auto',
  45. 'Ut',
  46. false
  47. ],
  48. ];
  49. foreach ($strings as $string) {
  50. $is = startsWith($string[0], $string[1]);
  51. //pr(returns($is). ' - expected '.returns($string[2]));
  52. $this->assertEquals($string[2], $is);
  53. }
  54. $is = startsWith('Auto', 'aut', true);
  55. $this->assertEquals(false, $is);
  56. }
  57. /**
  58. * BootstrapTest::testEndsWith()
  59. *
  60. * @return void
  61. */
  62. public function testEndsWith() {
  63. $strings = [
  64. [
  65. 'auto',
  66. 'to',
  67. true
  68. ],
  69. [
  70. 'auto',
  71. 'ut',
  72. false
  73. ],
  74. [
  75. 'auto',
  76. 'To',
  77. true
  78. ],
  79. [
  80. 'auto',
  81. 'Ut',
  82. false
  83. ],
  84. ];
  85. foreach ($strings as $string) {
  86. $is = endsWith($string[0], $string[1]);
  87. //pr(returns($is). ' - expected '.returns($string[2]));
  88. $this->assertEquals($string[2], $is);
  89. }
  90. $is = endsWith('Auto', 'To', true);
  91. $this->assertEquals(false, $is);
  92. }
  93. /**
  94. * BootstrapTest::testContains()
  95. *
  96. * @return void
  97. */
  98. public function testContains() {
  99. $strings = [
  100. [
  101. 'auto',
  102. 'to',
  103. true
  104. ],
  105. [
  106. 'auto',
  107. 'ut',
  108. true
  109. ],
  110. [
  111. 'auto',
  112. 'To',
  113. true
  114. ],
  115. [
  116. 'auto',
  117. 'ot',
  118. false
  119. ],
  120. ];
  121. foreach ($strings as $string) {
  122. $is = contains($string[0], $string[1]);
  123. //pr(returns($is). ' - expected '.returns($string[2]));
  124. $this->assertEquals($string[2], $is);
  125. }
  126. $is = contains('Auto', 'To', true);
  127. $this->assertEquals(false, $is);
  128. }
  129. public function testEnt() {
  130. //$this->assertEquals($expected, $is);
  131. }
  132. public function testEntDec() {
  133. //$this->assertEquals($expected, $is);
  134. }
  135. public function testReturns() {
  136. //$this->assertEquals($expected, $is);
  137. }
  138. /**
  139. * BootstrapTest::testExtractPathInfo()
  140. *
  141. * @return void
  142. */
  143. public function testExtractPathInfo() {
  144. $result = extractPathInfo('somefile.jpg', 'ext');
  145. $this->assertEquals('jpg', $result);
  146. $result = extractPathInfo('somefile.jpg', 'base');
  147. $this->assertEquals('somefile.jpg', $result);
  148. $result = extractPathInfo('somefile.jpg', 'file');
  149. $this->assertEquals('somefile', $result);
  150. $result = extractPathInfo('somefile.jpg?foo=bar#something', 'ext', true);
  151. $this->assertEquals('jpg', $result);
  152. }
  153. /**
  154. * BootstrapTest::testExtractFileInfo()
  155. *
  156. * @return void
  157. */
  158. public function testExtractFileInfo() {
  159. $result = extractFileInfo('/some/path/to/filename.ext', 'file');
  160. $this->assertEquals('filename', $result);
  161. $result = extractFileInfo('/some/path/to/filename.x.y.z.ext', 'file');
  162. $this->assertEquals('filename.x.y.z', $result);
  163. }
  164. }