public function testNumber() { $s = new Stringizer(0); $this->assertEquals(false, $s->toBoolean()); $s = new Stringizer(1); $this->assertEquals(true, $s->toBoolean()); }
public function testTrimRight() { $s = new Stringizer(" キラキラしたfizzخالد الشمعة "); $this->assertEquals(" キラキラしたfizzخالد الشمعة", $s->trimRight()); $s = new Stringizer(" Fizz Buzz "); $this->assertEquals(" Fizz Buzz", $s->trimRight()); }
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()); }
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()); }
public function testValidMultiByteNoMatch() { $s = new Stringizer("ȘŦŗÍñĝìzĕŕ"); $this->assertEquals("ȘŦŗÍñĝìzĕŕ", $s->chopLeft("ȘŦŗÍñĝXXX")); $s = new Stringizer("<div>こんにちは"); $this->assertEquals("<div>こんにちは", $s->chopLeft("<span>")); }
public function testInValidEmails() { $s = new Stringizer("*****@*****.**"); $this->assertEquals(false, $s->isEmail()); $s = new Stringizer("x@x@.org"); $this->assertEquals(false, $s->isEmail()); }
/** * * * 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()); }
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("れ")); }
public function testInValidHasUppercase() { $s = new Stringizer("ABcD"); $this->assertEquals(false, $s->hasUppercase()); $s = new Stringizer("sÑÃ"); $this->assertEquals(false, $s->hasUppercase()); }
public function testInValidHasLowercase() { $s = new Stringizer("Abcdedfghijklmnopqrstuvwxyz"); $this->assertEquals(false, $s->hasLowercase()); $s = new Stringizer("sTŗiñĝìzĕŕ"); $this->assertEquals(false, $s->hasLowercase()); }
public function testSplitValidButNoDelimiterMatch() { $s = new Stringizer("Fizz Buzz"); $array = $s->split(","); $this->assertEquals(1, count($array)); $this->assertEquals("Fizz Buzz", $array[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>")); }
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)); }
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()); }
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()); }
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)); }
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")); }
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()); }
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()); }
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()); }
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()); }
public function execute() { $s = new Stringizer($this->getValue()); if ($s->startsWith($this->prefix)) { return $this->getValue(); } else { return $this->prefix . $this->getValue(); } }
public function execute() { $s = new Stringizer($this->getValue()); if ($s->endsWith($this->suffix)) { return $this->getValue(); } else { return $this->getValue() . $this->suffix; } }
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()); }
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)); }