示例#1
1
 public function testNumber()
 {
     $s = new Stringizer(0);
     $this->assertEquals(false, $s->toBoolean());
     $s = new Stringizer(1);
     $this->assertEquals(true, $s->toBoolean());
 }
示例#2
0
 public function testTrimRight()
 {
     $s = new Stringizer("      キラキラしたfizzخالد الشمعة   ");
     $this->assertEquals("      キラキラしたfizzخالد الشمعة", $s->trimRight());
     $s = new Stringizer("    Fizz Buzz   ");
     $this->assertEquals("    Fizz Buzz", $s->trimRight());
 }
示例#3
0
 public function testInValidIp()
 {
     $s = new Stringizer("0.0.0.x");
     $this->assertEquals(false, $s->isIpv4());
     $s = new Stringizer("257.1.1.1");
     $this->assertEquals(false, $s->isIpv4());
 }
 public function testUppercaseWords()
 {
     $s = new Stringizer("fizz");
     $this->assertEquals("Fizz", $s->uppercaseWords());
     $s = new Stringizer("fizz buzz foo bar");
     $this->assertEquals("Fizz Buzz Foo Bar", $s->uppercaseWords());
 }
 /**
  * Remove non Ascii characters
  */
 public function testConvertAccents()
 {
     $s = new Stringizer("FizzöBuzz Fizz Buzz Fizz Buzzé");
     $this->assertEquals("FizzoeBuzz Fizz Buzz Fizz Buzze", $s->replaceAccents());
     $s = new Stringizer("ȘŦŗÍñĝìzĕŕ");
     $this->assertEquals("STrIngizer", $s->replaceAccents());
 }
示例#6
0
 public function testInValidIp()
 {
     $s = new Stringizer("xx");
     $this->assertEquals(false, $s->isIpv6());
     $s = new Stringizer("2001:cdba:0000:0000:0000:0000:3257:9652x");
     $this->assertEquals(false, $s->isIpv6());
 }
示例#7
0
 public function testValidMultiByteNoMatch()
 {
     $s = new Stringizer("ȘŦŗÍñĝìzĕŕ");
     $this->assertEquals("ȘŦŗÍñĝìzĕŕ", $s->chopLeft("ȘŦŗÍñĝXXX"));
     $s = new Stringizer("<div>こんにちは");
     $this->assertEquals("<div>こんにちは", $s->chopLeft("<span>"));
 }
示例#8
0
 public function testInValidEmails()
 {
     $s = new Stringizer("*****@*****.**");
     $this->assertEquals(false, $s->isEmail());
     $s = new Stringizer("x@x@.org");
     $this->assertEquals(false, $s->isEmail());
 }
示例#9
0
 /**
  * *
  * Simple Java output hash code for string value "Hello, World"
  *
  *
  * public class HelloWorld {
  * public static void main(String[] args) {
  *
  * System.out.println( ("Hello, World").hashCode());
  * }
  * }
  */
 public function testValidStartsWith()
 {
     $s = new Stringizer("Hello, World");
     $this->assertEquals("-505841268", $s->hashCode());
     $s = new Stringizer("Hello, World");
     $this->assertNotEquals("bad-match", $s->hashCode());
 }
示例#10
0
 public function testInValidFirst()
 {
     $s = new Stringizer("myapp");
     $this->assertNotEquals("my", $s->last(3));
     $s = new Stringizer("ȘŦŗÍñĝìzĕŕ");
     $this->assertNotEquals("ȘŦŗÍñĝ", $s->last(5));
 }
 public function testContainsCountValidMultibyte()
 {
     $s = new Stringizer("文字列のそれ");
     $this->assertEquals(1, $s->containsCount("の"));
     $s = new Stringizer("文字列のそれ 文字列のそれ 文字列のそれ 文字列のそれ");
     $this->assertEquals(4, $s->containsCount("れ"));
 }
示例#12
0
 public function testInValidHasUppercase()
 {
     $s = new Stringizer("ABcD");
     $this->assertEquals(false, $s->hasUppercase());
     $s = new Stringizer("sÑÃ");
     $this->assertEquals(false, $s->hasUppercase());
 }
示例#13
0
 public function testInValidHasLowercase()
 {
     $s = new Stringizer("Abcdedfghijklmnopqrstuvwxyz");
     $this->assertEquals(false, $s->hasLowercase());
     $s = new Stringizer("sTŗiñĝìzĕŕ");
     $this->assertEquals(false, $s->hasLowercase());
 }
示例#14
0
 public function testSplitValidButNoDelimiterMatch()
 {
     $s = new Stringizer("Fizz Buzz");
     $array = $s->split(",");
     $this->assertEquals(1, count($array));
     $this->assertEquals("Fizz Buzz", $array[0]);
 }
示例#15
0
 public function testValidMultiByte()
 {
     $s = new Stringizer("<div>ȘŦŗÍñĝìzĕŕ</div>");
     $this->assertEquals("ȘŦŗÍñĝìzĕŕ", $s->between("<div>", "</div>"));
     $s = new Stringizer("<div>こんにちは</div>");
     $this->assertEquals("こんにちは", $s->between("<div>", "</div>"));
 }
示例#16
0
 public function testUrlSantize()
 {
     $s = new Stringizer("http://jason��lam604.co�m");
     // Unsantized should fail
     $this->assertEquals(false, $s->isUrl());
     // Santize should pass
     $this->assertEquals(true, $s->isUrl(true));
 }
示例#17
0
 public function testEncoding()
 {
     $s = new Stringizer("Fizz Buzz");
     $s->setEncoding("iso-8859-1");
     $this->assertEquals("iso-8859-1", $s->getEncoding());
     $s->setEncoding("UTF-8");
     $this->assertEquals("UTF-8", $s->getEncoding());
 }
示例#18
0
 public function testInValidDecimal()
 {
     $s = new Stringizer("123.0x");
     $this->assertEquals(false, $s->isDecimal());
     $s = new Stringizer("123.0.");
     $this->assertEquals(false, $s->isDecimal());
     $s = new Stringizer("1 23");
     $this->assertEquals(false, $s->isDecimal());
 }
 public function testValidMultiByte()
 {
     $s = new Stringizer(" ȘŦŗÍñĝìzĕŕ       こんにちは     ");
     $this->assertEquals("ȘŦŗÍñĝìzĕŕ こんにちは", $s->collapseWhitespace());
     $s = new Stringizer(" Ș Ŧ ŗ Í ñ ĝ ì z ĕ ŕ こ ん に ち は ");
     $this->assertEquals("Ș Ŧ ŗ Í ñ ĝ ì z ĕ ŕ こ ん に ち は", $s->collapseWhitespace());
     $s = new Stringizer("ȘŦŗÍñĝ\n\nìzĕŕ \n\t    \r");
     $this->assertEquals("ȘŦŗÍñĝ ìzĕŕ", $s->collapseWhitespace());
 }
示例#20
0
 public function testInValidAlphaHasMultiByte()
 {
     $s = new Stringizer("こ");
     $this->assertEquals("こ", $s->repeat(1));
     $s = new Stringizer("こ");
     $this->assertEquals("こここここ", $s->repeat(5));
     $s = new Stringizer("こんにちは");
     $this->assertEquals("こんにちはこんにちは", $s->repeat(2));
 }
示例#21
0
 public function testValidIndexOfCaseInsenitive()
 {
     // Case Sensitive
     $s = new Stringizer("Fizz Buzz Foo Bar");
     $this->assertEquals(FALSE, $s->lastIndexOf("foo"));
     // Case-InSensitive
     $s = new Stringizer("Fizz Buzz Foo Bar");
     $this->assertEquals(10, $s->lastIndexOfCaseInsensitive("foo"));
 }
示例#22
0
 public function testValidStartsWith()
 {
     $s = new Stringizer("文字列のそれ");
     $this->assertEquals(true, $s->startsWith("文"));
     $s = new Stringizer("文字列のそれ");
     $this->assertEquals(false, $s->startsWith("文文文文"));
     $s = new Stringizer("Fizz Buzz");
     $this->assertEquals(true, $s->startsWith("Fizz B"));
 }
 public function testUppercaseFirst()
 {
     $s = new Stringizer("fizz");
     $this->assertEquals("Fizz", $s->uppercaseFirst());
     $s = new Stringizer("fizz buzz FOO bar");
     $this->assertEquals("Fizz buzz foo bar", $s->uppercaseFirst());
     $s = new Stringizer("ABCDEFG");
     $this->assertEquals("Abcdefg", $s->uppercaseFirst());
 }
示例#24
0
 public function testDasherize()
 {
     $s = new Stringizer("dataRate");
     $this->assertEquals("data-rate", $s->dasherize());
     $s = new Stringizer("backgroundImage");
     $this->assertEquals("background-image", $s->dasherize());
     $s = new Stringizer("HelloWorldThisIsCamelized");
     $this->assertEquals("-hello-world-this-is-camelized", $s->dasherize());
 }
示例#25
0
 public function testNoChangeForMultiByte()
 {
     $s = new Stringizer("こ");
     $this->assertEquals("こ", $s->swapCase());
     $s = new Stringizer("こんにちは");
     $this->assertEquals("こんにちは", $s->swapCase());
     $s = new Stringizer("helloこんにちはWORLD");
     $this->assertEquals("HELLOこんにちはworld", $s->swapCase());
 }
示例#26
0
 public function testCamelToSnake()
 {
     $s = new Stringizer("helloWorld");
     $this->assertEquals("hello_world", $s->camelToSnake());
     $s = new Stringizer("MyFunctionName");
     $this->assertEquals("_my_function_name", $s->camelToSnake());
     $s = new Stringizer("helloSŦŗÍñĝìzĕŕ");
     $this->assertEquals("hello_sŦŗÍñĝìzĕŕ", $s->camelToSnake());
 }
示例#27
0
 public function execute()
 {
     $s = new Stringizer($this->getValue());
     if ($s->startsWith($this->prefix)) {
         return $this->getValue();
     } else {
         return $this->prefix . $this->getValue();
     }
 }
示例#28
0
 public function execute()
 {
     $s = new Stringizer($this->getValue());
     if ($s->endsWith($this->suffix)) {
         return $this->getValue();
     } else {
         return $this->getValue() . $this->suffix;
     }
 }
示例#29
0
 public function testCamelize()
 {
     $s = new Stringizer("data_rate");
     $this->assertEquals("dataRate", $s->camelize());
     $s = new Stringizer("background-image");
     $this->assertEquals("backgroundImage", $s->camelize());
     $s = new Stringizer("--flag-off");
     $this->assertEquals("flagOff", $s->camelize());
     $s = new Stringizer("__constant_value__");
     $this->assertEquals("constantValue", $s->camelize());
 }
示例#30
0
 public function testValid()
 {
     $s = new Stringizer("Foo Bar Fizz Buzz");
     $this->assertEquals("B", $s->charAt(4));
     $s = new Stringizer("ȘŦŗÍñĝìzĕŕ");
     $this->assertEquals("Ŧ", $s->charAt(1));
     $s = new Stringizer("こんにちは");
     $this->assertEquals("こ", $s->charAt(0));
     $s = new Stringizer("こんにちは");
     $this->assertEquals("", $s->charAt(10));
 }