/**
  * @dataProvider dataResources
  */
 function testResources($resource, $locale, $id)
 {
     $ms = \Fulfil\MessageSet\SimpleTemplate::create($resource, $locale);
     $ms->default = uniqid('', true);
     $out = $ms->format(new \Fulfil\Message(['id' => $id]));
     $this->assertNotEquals($ms->default, $out, "Default message triggered for resource {$resource}, locale {$locale}, id {$id}");
 }
Exemple #2
0
<?php

require __DIR__ . '/config.php';
$ctx = new \Fulfil\Context();
$check = new \Fulfil\Schema(['props' => ['a' => new \Fulfil\Schema(['props' => ['a' => new \Fulfil\Check\All(['name' => 'Woohoo', 'checks' => [new \Fulfil\Check\String_(['lengthMin' => 3])]])]]), 'b' => new \Fulfil\Check\String_(['required' => true, 'lengthMin' => 3, 'lengthMax' => 5]), 'c' => new \Fulfil\Check\String_(['required' => true, 'lengthMin' => 3])]]);
$in = ['a' => ['a' => 'ab'], 'b' => 'de', 'c' => 'ab'];
$check->apply($in, $ctx);
$ms = \Fulfil\MessageSet\SimpleTemplate::create('user', 'en', 'The value was invalid');
$ms->addTemplates(['reason' => ['check.required' => 'A value was required', 'string.lengthBetween' => 'Must be between {{min}} and {{max}} character(s), but only {{len}} were entered']]);
dump($ms->formatContext($ctx));
dump($ms->formatContextPaths($ctx, ['a.a', 'b']));
$ms = new \Fulfil\MessageSet\Developer();
dump($ms->formatContext($ctx));
dump($ms->formatContextPaths($ctx, ['a.a', 'b']));