CorujaStringManipulationTest.php
Go to the documentation of this file.00001 <?php
00002 require_once 'PHPUnit/Framework.php';
00003
00004 require_once dirname( __FILE__ ).'/../../../_start.php';
00005
00010 class CorujaStringManipulationTest extends PHPUnit_Framework_TestCase
00011 {
00016 protected $object;
00017
00024 protected function setUp()
00025 {
00026 $this->object = new CorujaStringManipulation;
00027 }
00028
00035 protected function tearDown()
00036 {
00037 }
00038
00042 public function testStrToBool()
00043 {
00044 $this->assertFalse(
00045 CorujaStringManipulation::strToBool("")
00046 );
00047 }
00048
00052 public function testStrToBool2()
00053 {
00054 $this->assertFalse(
00055 CorujaStringManipulation::strToBool("false")
00056 );
00057 }
00058
00062 public function testStrToBool3()
00063 {
00064 $this->assertFalse(
00065 CorujaStringManipulation::strToBool("FaLsE")
00066 );
00067 }
00068
00072 public function testStrToBool4()
00073 {
00074 $this->assertFalse(
00075 CorujaStringManipulation::strToBool("0")
00076 );
00077 }
00078
00082 public function testStrToBool5()
00083 {
00084 $this->assertTrue(
00085 CorujaStringManipulation::strToBool("a0a")
00086 );
00087 }
00088
00092 public function testStrToBool6()
00093 {
00094 $this->assertTrue(
00095 CorujaStringManipulation::strToBool("true")
00096 );
00097 }
00098
00102 public function testStrToBool7()
00103 {
00104 $this->assertTrue(
00105 CorujaStringManipulation::strToBool("1")
00106 );
00107 }
00108
00113 public function testStrToBool8()
00114 {
00115 CorujaStringManipulation::strToBool(null);
00116 }
00117
00122 public function testStrToBool9()
00123 {
00124 CorujaStringManipulation::strToBool(123);
00125 }
00126
00131 public function testStrToBool10()
00132 {
00133 CorujaStringManipulation::strToBool(array());
00134 }
00135
00140 public function testStrToBool11()
00141 {
00142 CorujaStringManipulation::strToBool(new stdClass());
00143 }
00144
00149 public function testStrToBool12()
00150 {
00151 CorujaStringManipulation::strToBool(false);
00152 }
00153
00157 public function testForceInt()
00158 {
00159 $this->assertEquals(
00160 1234,
00161 CorujaStringManipulation::forceInt("a1b2c3d4")
00162 );
00163 }
00164
00168 public function testForceInt2()
00169 {
00170 $this->assertEquals(
00171 0,
00172 CorujaStringManipulation::forceInt("")
00173 );
00174 }
00175
00179 public function testForceInt3()
00180 {
00181 $this->assertEquals(
00182 0,
00183 CorujaStringManipulation::forceInt("a0a")
00184 );
00185 }
00186
00190 public function testForceInt4()
00191 {
00192 $this->assertEquals(
00193 1,
00194 CorujaStringManipulation::forceInt("001")
00195 );
00196 }
00197
00201 public function testForceInt5()
00202 {
00203 $this->assertEquals(
00204 0,
00205 CorujaStringManipulation::forceInt("abc")
00206 );
00207 }
00208
00212 public function testForceInt6()
00213 {
00214 $this->assertEquals(
00215 10,
00216 CorujaStringManipulation::forceInt("a-10")
00217 );
00218 }
00219
00223 public function testForceInt7()
00224 {
00225 $this->assertEquals(
00226 -10,
00227 CorujaStringManipulation::forceInt("-10")
00228 );
00229 }
00230
00234 public function testForceInt8()
00235 {
00236 $this->assertEquals(
00237 -10,
00238 CorujaStringManipulation::forceInt("--10")
00239 );
00240 }
00241
00245 public function testForceInt9()
00246 {
00247 $this->assertEquals(
00248 -10,
00249 CorujaStringManipulation::forceInt("-a-b-1-0-")
00250 );
00251 }
00252
00257 public function testForceInt10()
00258 {
00259 CorujaStringManipulation::forceInt(null);
00260 }
00261
00266 public function testForceInt11()
00267 {
00268 CorujaStringManipulation::forceInt(123);
00269 }
00270
00275 public function testForceInt12()
00276 {
00277 CorujaStringManipulation::forceInt(array());
00278 }
00279
00284 public function testForceInt13()
00285 {
00286 CorujaStringManipulation::forceInt(new stdClass());
00287 }
00288
00293 public function testForceInt14()
00294 {
00295 CorujaStringManipulation::forceInt(false);
00296 }
00297
00301 public function testCamelCaseToUnderlineCase()
00302 {
00303 $this->assertEquals(
00304 "TEST",
00305 CorujaStringManipulation::camelCaseToUnderlineCase("test")
00306 );
00307 }
00308
00312 public function testCamelCaseToUnderlineCase2()
00313 {
00314 $this->assertEquals(
00315 "SOMETHING_COOL",
00316 CorujaStringManipulation::camelCaseToUnderlineCase("somethingCool")
00317 );
00318 }
00319
00323 public function testCamelCaseToUnderlineCase3()
00324 {
00325 $this->assertEquals(
00326 "",
00327 CorujaStringManipulation::camelCaseToUnderlineCase("")
00328 );
00329 }
00330
00334 public function testCamelCaseToUnderlineCase4()
00335 {
00336 $this->assertEquals(
00337 "1SOMETHING2_COOL3",
00338 CorujaStringManipulation::camelCaseToUnderlineCase("1something2Cool3")
00339 );
00340 }
00341
00345 public function testCamelCaseToUnderlineCase5()
00346 {
00347 $this->assertEquals(
00348 "111SOMETHING2222_COOL333",
00349 CorujaStringManipulation::camelCaseToUnderlineCase("111something2222Cool333")
00350 );
00351 }
00352
00357 public function testCamelCaseToUnderlineCase6()
00358 {
00359 CorujaStringManipulation::camelCaseToUnderlineCase(null);
00360 }
00361
00366 public function testCamelCaseToUnderlineCase7()
00367 {
00368 CorujaStringManipulation::camelCaseToUnderlineCase(123);
00369 }
00370
00375 public function testCamelCaseToUnderlineCase8()
00376 {
00377 CorujaStringManipulation::camelCaseToUnderlineCase(array());
00378 }
00379
00384 public function testCamelCaseToUnderlineCase9()
00385 {
00386 CorujaStringManipulation::camelCaseToUnderlineCase(new stdClass());
00387 }
00388
00393 public function testCamelCaseToUnderlineCase10()
00394 {
00395 CorujaStringManipulation::camelCaseToUnderlineCase(false);
00396 }
00397
00398 }
00399 ?>