/**
  * @param string $type
  * @return array
  */
 public function findByType($type)
 {
     $addDumpsToDatabase = $this->addDumpsToDatabaseCallback();
     if (!array_key_exists((string) $type, $databases = $this->config->getDumpConfiguration())) {
         return array();
     }
     return array_map($addDumpsToDatabase, $databases[$type]);
 }
 /**
  * @param Configuration $config
  */
 public function __construct(Configuration $config)
 {
     foreach ($config->getDumpConfiguration() as $databases) {
         foreach ($databases as $database) {
             $this->createDumper($database);
         }
     }
 }
 public function tearDown()
 {
     parent::tearDown();
     foreach ($this->configuration->getDumpConfiguration() as $databases) {
         foreach ($databases as $database) {
             $finder = new Finder();
             $finder->files()->ignoreDotFiles(true)->in($dir = $database->getPath());
             foreach ($finder as $file) {
                 unlink($file);
             }
             rmdir($dir);
         }
     }
 }
 public function testGetDumpConfiguration()
 {
     $dumpConfig = $this->sut->getDumpConfiguration();
     $this->assertInternalType('array', $dumpConfig);
     $this->assertArrayHasKey(Database::TYPE_MYSQL, $dumpConfig);
     // -> mysql
     $mysqlConfig = $dumpConfig[Database::TYPE_MYSQL];
     $this->assertCount(3, $mysqlConfig);
     $this->assertContainsOnlyInstancesOf('SPF\\DatabaseDumpProvider\\Model\\Database', $mysqlConfig);
     $this->assertContainsOnlyInstancesOf('SPF\\DatabaseDumpProvider\\Model\\MysqlDatabase', $mysqlConfig);
     // ->-> cms_development
     /**
      * @var Database
      */
     $firstMysqlDb = array_shift($mysqlConfig);
     $this->assertSame($firstMysqlDb->getName(), 'cms_development');
     $this->assertContains('/mysql/cms_development', $firstMysqlDb->getPath());
     $this->assertSame(Database::COMPRESSION_TYPE_BZIP2, $firstMysqlDb->getCompressionType());
     $this->assertSame(Database::COMPRESSION_LEVEL_HIGH, $firstMysqlDb->getCompressionLevel());
     $this->assertSame('root', $firstMysqlDb->getUser());
     $this->assertSame('1234', $firstMysqlDb->getPassword());
     // ->-> database_dump_provider
     /**
      * @var Database
      */
     $secondMysqlDb = array_shift($mysqlConfig);
     $this->assertSame($secondMysqlDb->getName(), 'database_dump_provider');
     $this->assertContains('/mysql/database_dump_provider', $secondMysqlDb->getPath());
     $this->assertSame(Database::COMPRESSION_TYPE_GZIP, $secondMysqlDb->getCompressionType());
     $this->assertSame(Database::COMPRESSION_LEVEL_LOW, $secondMysqlDb->getCompressionLevel());
     $this->assertSame('foo', $secondMysqlDb->getUser());
     $this->assertNull($secondMysqlDb->getPassword());
     // ->-> default_config_test
     /**
      * @var Database
      */
     $thirdMysqlDb = array_shift($mysqlConfig);
     $this->assertSame($thirdMysqlDb->getName(), 'default_config_test');
     $this->assertContains('/mysql/default_config_test', $thirdMysqlDb->getPath());
     $this->assertSame(Database::COMPRESSION_TYPE_BZIP2, $thirdMysqlDb->getCompressionType());
     $this->assertSame(Database::COMPRESSION_LEVEL_MED, $thirdMysqlDb->getCompressionLevel());
     $this->assertSame('root', $thirdMysqlDb->getUser());
     $this->assertNull($thirdMysqlDb->getPassword());
 }