public function testCountTypes()
 {
     $countPerType = 3;
     $this->assertSame(0, $this->mappings->countTypes());
     $this->index->expects($this->exactly(2))->method('countTypes')->willReturn($countPerType);
     $this->mappings->setIndices(array($this->index, $this->index));
     $this->assertSame($countPerType + $countPerType, $this->mappings->countTypes());
 }
 /**
  * Loads the mappings that are located in the filesystem of stored backup
  *
  * @param string $filepath
  * @return Mappings
  * @throws \Exception
  * @author Daniel Wendlandt
  */
 public function loadMappings($filepath)
 {
     $schemaFolderPath = $filepath . DIRECTORY_SEPARATOR . self::DIR_SCHEMA;
     if (!$this->filesytsem->exists($schemaFolderPath)) {
         throw new \Exception('Schema folder does not exist in ' . $filepath);
     }
     /** @var Finder $finder */
     $finder = new $this->finder();
     $indices = array();
     /** @var SplFileInfo $file */
     foreach ($finder->files()->in($schemaFolderPath)->name('*' . self::FILE_EXTENSION) as $file) {
         $indexName = $file->getRelativePath();
         if (!isset($indices[$indexName])) {
             $index = new Mappings\Index();
             $index->setName($indexName);
             $indices[$indexName] = $index;
         }
         /** @var Mappings\Index $index */
         $index = $indices[$indexName];
         //perform type;
         $type = new Mappings\Type();
         $type->setName($file->getBasename(self::FILE_EXTENSION));
         $type->setSchema(json_decode($file->getContents(), true));
         $index->addType($type);
     }
     $mappings = new Mappings();
     $mappings->setIndices($indices);
     return $mappings;
 }