BootstrapTest.php 3.1 KB

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