getDbVersion() public method

public getDbVersion ( ) : string
return string version of mongo database
Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Welcome to the setup of lxHive!</info>');
     $helper = $this->getHelper('question');
     $question = new Question('Enter a name for this lxHive instance: ', 'Untitled');
     $name = $helper->ask($input, $output, $question);
     $connectionSuccesful = false;
     while (!$connectionSuccesful) {
         $question = new Question('Enter the URI of your MongoDB installation (default: "mongodb://127.0.0.1"): ', 'mongodb://127.0.0.1');
         $mongoHostname = $helper->ask($input, $output, $question);
         $client = new Client($mongoHostname);
         try {
             $mongoVersion = $client->getDbVersion();
             $output->writeln('Connection succesful, MongoDB version ' . $mongoVersion . '.');
             $connectionSuccesful = true;
         } catch (\MongoConnectionException $e) {
             $output->writeln('Connection unsuccesful, please try again.');
         }
     }
     $question = new Question('Enter the name of your MongoDB database (default: "lxHive"): ', 'lxHive');
     $mongoDatabase = $helper->ask($input, $output, $question);
     $currentConfig = Yaml::parse(file_get_contents(__DIR__ . '/../Config/Config.template.yml'));
     $mergingArray = ['name' => $name, 'database' => ['host_uri' => $mongoHostname, 'db_name' => $mongoDatabase]];
     $newConfig = array_merge($currentConfig, $mergingArray);
     $yamlData = Yaml::dump($newConfig);
     file_put_contents(__DIR__ . '/../Config/Config.yml', $yamlData);
     $output->writeln('<info>DB setup complete!</info>');
 }
Exemplo n.º 2
0
 public function testGetDbVersion()
 {
     $version = $this->client->getDbVersion();
     $this->assertEquals(1, preg_match('#^[0-9]+(\\.[0-9]+(\\.[0-9]+(-[0-9A-Za-z\\-]+(\\+[0-9A-Za-z\\-]+)?)?)?)?$#', $version));
 }