예제 #1
0
 /**
  * @covers Mobileka\MosaicArray\MosaicArray::pregKeys
  */
 public function test_gets_an_array_of_target_arrays_keys_matching_a_regex()
 {
     $ma = new MosaicArray($this->target);
     // should not be found
     $result = $ma->pregKeys('/^\\d{5}$/');
     assertNull($result);
     $expect = 'Mosaic Soft';
     $result = $ma->pregKeys('/^\\d{5}$/', 'Mosaic Soft');
     assertEquals($expect, $result);
     // keys ending with "s"
     $expect = ['numbers', 'students'];
     $result = $ma->pregKeys('/^.*s$/');
     assertEquals($expect, $result);
     // containing two numbers in a row
     $target = ['5wrong' => '', 'cor55rect' => '', 'corre76ct' => '', 'hello' => 'world'];
     $expect = ['cor55rect', 'corre76ct'];
     $result = MosaicArray::make($target)->pregKeys('/^.*\\d{2}.*$/');
     assertEquals($expect, $result);
 }