BootstrapTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. $this->assertEquals($string[2], $is);
  47. }
  48. $is = startsWith('Auto', 'aut', true);
  49. $this->assertEquals(false, $is);
  50. }
  51. /**
  52. * BootstrapTest::testEndsWith()
  53. *
  54. * @return void
  55. */
  56. public function testEndsWith() {
  57. $strings = [
  58. [
  59. 'auto',
  60. 'to',
  61. true,
  62. ],
  63. [
  64. 'auto',
  65. 'ut',
  66. false,
  67. ],
  68. [
  69. 'auto',
  70. 'To',
  71. true,
  72. ],
  73. [
  74. 'auto',
  75. 'Ut',
  76. false,
  77. ],
  78. ];
  79. foreach ($strings as $string) {
  80. $is = endsWith($string[0], $string[1]);
  81. $this->assertEquals($string[2], $is);
  82. }
  83. $is = endsWith('Auto', 'To', true);
  84. $this->assertEquals(false, $is);
  85. }
  86. /**
  87. * BootstrapTest::testContains()
  88. *
  89. * @return void
  90. */
  91. public function testContains() {
  92. $strings = [
  93. [
  94. 'auto',
  95. 'to',
  96. true,
  97. ],
  98. [
  99. 'auto',
  100. 'ut',
  101. true,
  102. ],
  103. [
  104. 'auto',
  105. 'To',
  106. true,
  107. ],
  108. [
  109. 'auto',
  110. 'ot',
  111. false,
  112. ],
  113. ];
  114. foreach ($strings as $string) {
  115. $is = contains($string[0], $string[1]);
  116. $this->assertEquals($string[2], $is);
  117. }
  118. $is = contains('Auto', 'To', true);
  119. $this->assertEquals(false, $is);
  120. }
  121. /**
  122. * @return void
  123. */
  124. public function testEnt() {
  125. //$this->assertEquals($expected, $is);
  126. }
  127. /**
  128. * @return void
  129. */
  130. public function testEntDec() {
  131. //$this->assertEquals($expected, $is);
  132. }
  133. /**
  134. * @return void
  135. */
  136. public function testReturns() {
  137. //$this->assertEquals($expected, $is);
  138. }
  139. /**
  140. * BootstrapTest::testExtractPathInfo()
  141. *
  142. * @return void
  143. */
  144. public function testExtractPathInfo() {
  145. $result = extractPathInfo('somefile.jpg', 'ext');
  146. $this->assertEquals('jpg', $result);
  147. $result = extractPathInfo('somefile.jpg', 'base');
  148. $this->assertEquals('somefile.jpg', $result);
  149. $result = extractPathInfo('somefile.jpg', 'file');
  150. $this->assertEquals('somefile', $result);
  151. $result = extractPathInfo('somefile.jpg?foo=bar#something', 'ext', true);
  152. $this->assertEquals('jpg', $result);
  153. }
  154. /**
  155. * BootstrapTest::testExtractFileInfo()
  156. *
  157. * @return void
  158. */
  159. public function testExtractFileInfo() {
  160. $result = extractFileInfo('/some/path/to/filename.ext', 'file');
  161. $this->assertEquals('filename', $result);
  162. $result = extractFileInfo('/some/path/to/filename.x.y.z.ext', 'file');
  163. $this->assertEquals('filename.x.y.z', $result);
  164. }
  165. }