Пример #1
0
 public function testIfParamatersMatcherWillMatch()
 {
     $matcher = new ParametersMatcher();
     $matcher->setPlugins(new MatcherConfig(['addendum' => new Addendum(), 'reflection' => new ReflectionClass($this)]));
     $string = "('Maslosoft\\AddendumTest\\Models\\ModelWithLabels', true)";
     $value = [];
     $matcher->matches($string, $value);
     $this->assertSame('Maslosoft\\AddendumTest\\Models\\ModelWithLabels', $value['value'][0]);
     $this->assertSame(true, $value['value'][1]);
 }
 public function testIfMixedDefinitionParametersWillMatch()
 {
     $matcher = new ParametersMatcher();
     $matcher->setPlugins(new MatcherConfig(['addendum' => new Addendum(), 'reflection' => new ReflectionClass($this)]));
     // Named values
     $namedMatch = ['(foo = 2, bar = 3)' => ['foo' => 2, 'bar' => 3], '(foo = 2, 3)' => ['foo' => 2, 0 => 3]];
     foreach ($namedMatch as $match => $value) {
         $msg = sprintf("Should match `%s` with named values of `%s`: `%s`", $match, implode('`, `', array_keys($value)), var_export($value, true));
         $matched = null;
         $this->assertTrue((bool) $matcher->matches($match, $matched), $msg);
         $this->assertSame($value, $matched['value'], $msg);
     }
 }