public function testLocate() { $string = new Str('Hello Php World'); $this->assertFalse($string->locate('AA')); $this->assertFalse($string->locate('L', 0, Str::CASE_SENSITIVE)); $this->assertEquals(10, $string->locate('W')); $this->assertEquals(13, $string->locate('l', 5)); $this->expectsException(function () use($string) { $string->locate([]); }, Exception::class, null, Exception::INVALID_PARAMETER); $this->expectsException(function () use($string) { $string->locate('ss', 'aa'); }, Exception::class, null, Exception::INVALID_PARAMETER); $this->expectsException(function () use($string) { $string->locate('test', -2); }, Exception::class, null, Exception::INVALID_PARAMETER); $this->assertEquals(13, $string->locate('l', 0, Str::FROM_END)); $this->assertEquals(8, $string->locate('P', 0, Str::FROM_END)); $this->assertEquals(6, $string->locate('P', 0, Str::FROM_END | Str::CASE_SENSITIVE)); }