예제 #1
0
 public function testInsert()
 {
     $string = new Str('Keep Objective');
     $this->expectsException(function () use($string) {
         $string->insert('string', '30');
     }, Exception::class, null, Exception::INVALID_PARAMETER);
     $this->expectsException(function () use($string) {
         $string->insert([], []);
     }, Exception::class, null, Exception::INVALID_PARAMETER);
     $this->expectsException(function () use($string) {
         $string->insert(['array'], 30);
     }, Exception::class, null, Exception::INVALID_PARAMETER);
     $string = new Str('Objective');
     $extendedString = $string->insert('Keep', 0);
     $this->isInstanceOf(Str::class, $extendedString);
     $this->assertEquals('KeepObjective', $extendedString->getInternalValue());
     $string = (new Str('Keep'))->insert('Objective', 99);
     $this->assertEquals('KeepObjective', $string->getInternalValue());
     $string = (new Str('Keep'))->insert(new Str('Objective'), -2);
     $this->assertEquals('KeObjectiveep', $string->getInternalValue());
     $string = (new Str('Keep'))->insert('Objective', 3);
     $this->assertEquals('KeeObjectivep', $string->getInternalValue());
 }