Example #1
0
 public function build()
 {
     $mainSource = new ChainSource();
     if ($this->fallbacks) {
         $mainSource->add(new CircularGuardSource(new FallbackSource($this->fallbacks, $mainSource)));
     }
     if ($this->map) {
         $mainSource->add(new CircularGuardSource(new MappingSource($this->map, $mainSource)));
     }
     if ($this->combined) {
         $mainSource->add(new CircularGuardSource(new CombiningSource($this->combined, $mainSource)));
     }
     foreach ($this->sources as $source) {
         $mainSource->add($source);
     }
     if ($this->cache) {
         $mainSource = new CachingSource($this->cache, $mainSource);
     }
     return $mainSource;
 }
Example #2
0
 public function testBuildWithCircularGuards()
 {
     $factoryName = $this->getFaker()->unique()->word;
     $factoryOptions = 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);
     $source3 = \Mockery::mock('Giftcards\\Encryption\\Key\\SourceInterface');
     $this->factory->shouldReceive('create')->once()->with($factoryName, $factoryOptions)->andReturn($source3);
     $this->builder->add($this->source1)->add($this->source2, array(), false, true)->add($factoryName, $factoryOptions, null, true);
     $source = new ChainSource();
     $source->add($this->source1)->add(new CircularGuardSource($this->source2))->add(new CircularGuardSource(new PrefixKeyNameSource($factoryName, $source3)));
     $this->assertEquals($source, $this->builder->build());
 }