예제 #1
0
 /**
  *  @expectedException Faker\Exception
  *  @expectedExceptionMessage Unknown Locale at::tmp
  */
 public function testLoadingLocaleRegisteredNotExist()
 {
     LocaleFactory::registerExtension('tmp', '\\Faker\\Locale\\Tmp');
     $this->assertTrue(LocaleFactory::hasExtension('tmp'));
     $string_factory = SimpleString::create('');
     $factory = new LocaleFactory($string_factory);
     $locale = $factory->create('tmp');
 }
예제 #2
0
 /**
  *  Will inject a locale into composite, which locale is
  *  decided by the composite locale option.
  *
  *  @access public
  *  @para CompositeInterface $composite
  */
 public function visitLocaleInjector(CompositeInterface $node)
 {
     if ($node instanceof TypeInterface) {
         # whats the locale
         $locale = $node->getOption('locale');
         if (empty($locale)) {
             throw new CompositeException($node, 'Locale is empty');
         } else {
             # fetch flywight from factory
             $locale = $this->factory->create($locale);
         }
         # assign to the composite
         $node->setLocale($locale);
     }
     return $node;
 }