public function set($name, $rotator, array $options = array()) { if (!$rotator instanceof RotatorInterface) { $rotator = $this->factory->create($rotator, $options); } $this->rotators[$name] = $rotator; return $this; }
/** * @expectedException \Giftcards\Encryption\Factory\WrongTypeBuiltException */ public function testCreateWhereBadInstaceReturned() { $options = array($this->getFaker()->unique()->word => $this->getFaker()->unique()->word, $this->getFaker()->unique()->word => $this->getFaker()->unique()->word, $this->getFaker()->unique()->word => $this->getFaker()->unique()->word); $defaults = array($this->getFaker()->unique()->word => $this->getFaker()->unique()->word, $this->getFaker()->unique()->word => $this->getFaker()->unique()->word); $resolvedOptions = array_merge($options, $defaults); $object = new \stdClass(); $this->builder2->shouldReceive('configureOptionsResolver')->once()->with('Symfony\\Component\\OptionsResolver\\OptionsResolver')->andReturnUsing(function (OptionsResolver $resolver) use($options, $defaults) { $resolver->setRequired(array_keys($options))->setDefaults($defaults); })->getMock()->shouldReceive('build')->once()->with($resolvedOptions)->andReturn($object)->getMock(); $this->factory->create('builder2', $options); }
/** * @param $source * @param array $options * @param null $prefix * @param bool|false $addCircularGuard * @return $this * * Add a new key source either an instance of the interface or a name and options. i nal cases a prefix can * be given and a boollean stating if they hsould be wrapped in a circular guard */ public function add($source, array $options = array(), $prefix = null, $addCircularGuard = false) { if (!$source instanceof SourceInterface) { if (!$prefix && $prefix !== false) { $prefix = $source; } $source = $this->factory->create($source, $options); } if ($prefix) { $source = new PrefixKeyNameSource($prefix, $source); } if ($addCircularGuard) { $source = new CircularGuardSource($source); } $this->sources[] = $source; return $this; }