Example #1
0
 /**
  * @dataProvider dataProviderForTestSplit
  */
 public function testSplit($str, $pattern, $expected, $exception, $code)
 {
     $string = new Str($str);
     if ($exception) {
         $this->expectsException(function () use($string, $pattern) {
             $string->split($pattern, Str::REGEXP);
         }, $exception, null, $code);
     } else {
         // check returned object
         $result = $string->split($pattern, Str::REGEXP);
         $this->isInstanceOf(Collection::class);
         $this->assertEquals(Str::class, $result->getType());
         // check returned values
         $values = $result->toArray();
         $this->assertCount(count($expected), $values);
         foreach ($values as $i => $value) {
             $this->assertEquals($expected[$i], $value);
         }
     }
 }