BootstrapTest.php 3.0 KB

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