Пример #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);
 }
Пример #2
0
<?php

use Mobileka\MosaicArray\MosaicArray;
return MosaicArray::make(['firstCase' => ['allowedScopes' => ['scope', 'anotherScope'], 'result' => ['scope' => ['alias' => 'scope'], 'anotherScope' => ['alias' => 'anotherScope']]], 'secondCase' => ['allowedScopes' => ['scope' => ['alias' => 'scopeAlias', 'keys' => ['firstKey', 'secondKey'], 'type' => 'int']], 'result' => ['scope' => ['alias' => 'scopeAlias', 'keys' => ['firstKey', 'secondKey'], 'type' => 'int']]], 'thirdCase' => ['allowedScopes' => ['scope' => ['type' => 'boolean']], 'result' => ['scope' => ['alias' => 'scope', 'type' => 'boolean']]]]);