public function testLoad()
 {
     $this->reader->expects($this->once())->method('read')->with($this->equalTo(self::CONFIG_FILE));
     $this->reader->method('getConfig')->will($this->returnValue($this->config));
     $config = $this->loader->load();
     $this->assertSame($this->config, $config);
 }
 public function testLoadWithoutCachedData()
 {
     $this->cacheConfig->expects($this->exactly(2))->method('getCacheManager')->willReturn($this->cache);
     $this->cacheConfig->expects($this->exactly(2))->method('getKey')->willReturn(new Key('potato'));
     $this->cacheConfig->expects($this->once())->method('getTtl')->willReturn(5001);
     $this->trainCacherMockWithLoadReturnValue(null);
     $this->reader->expects($this->once())->method('read')->will($this->returnValue($this->config));
     $this->cache->expects($this->once())->method('get')->will($this->returnValue($this->config));
     $this->reader->method('getConfig')->will($this->returnValue($this->config));
     $this->assertSame($this->config, $this->loader->load());
 }
 public function testPerformanceWithCacheForDifferentReaders()
 {
     echo "Setting readers with cache\n";
     $readers = [FIXTURES_PATH . "/test.php" => new PhpReader(), FIXTURES_PATH . "/test.ini" => new IniReader(), FIXTURES_PATH . "/test.json" => new JsonReader(), FIXTURES_PATH . "/test.yml" => new YamlReader()];
     $cyclesCount = [15000];
     foreach ($readers as $filename => $reader) {
         $loader = new ConfigLoader($filename, $reader, new CacheConfig(new Cache(), pathinfo($filename, PATHINFO_BASENAME), 60000));
         foreach ($cyclesCount as $cycles) {
             $start = microtime(true);
             for ($i = $cycles; $i > 0; $i--) {
                 $loader->load();
             }
             echo "\n{$cycles} cycles executed in " . (microtime(true) - $start) . " seconds for " . get_class($reader) . " with cache \n";
         }
     }
 }