/**
     * Refreshes database.
     *
     * @return void
     * @throws \LogicException When "$this->io" wasn't set upfront.
     */
    public function refresh()
    {
        if (!isset($this->io)) {
            throw new \LogicException('The "$this->io" must be set prior to calling "$this->refresh()".');
        }
        //ReflectionEngine::$maximumCachedFiles = 10;
        ReflectionEngine::init($this->detectClassLocator());
        $sql = 'UPDATE Files
				SET Found = 0';
        $this->db->perform($sql);
        $files = array();
        $this->io->write('Searching for files ... ');
        foreach ($this->getFinders() as $finder) {
            $files = array_merge($files, array_keys(iterator_to_array($finder)));
        }
        $file_count = count($files);
        $this->io->writeln(array('<info>' . $file_count . ' found</info>', ''));
        $progress_bar = $this->io->createProgressBar($file_count + 2);
        $progress_bar->setMessage('');
        $progress_bar->setFormat('%message%' . PHP_EOL . '%current%/%max% [%bar%] <info>%percent:3s%%</info> %elapsed:6s%/%estimated:-6s% <info>%memory:-10s%</info>');
        $progress_bar->start();
        foreach ($files as $file) {
            $progress_bar->setMessage('Processing File: <info>' . $this->removeProjectPath($file) . '</info>');
            $progress_bar->display();
            $this->processFile($file);
            $progress_bar->advance();
        }
        $sql = 'SELECT Id
				FROM Files
				WHERE Found = 0';
        $deleted_files = $this->db->fetchCol($sql);
        if ($deleted_files) {
            $progress_bar->setMessage('Deleting Files ...');
            $progress_bar->display();
            $sql = 'SELECT Id
					FROM Classes
					WHERE FileId IN (:file_ids)';
            $deleted_classes = $this->db->fetchCol($sql, array('file_ids' => $deleted_files));
            foreach ($deleted_classes as $deleted_class_id) {
                $this->deleteClass($deleted_class_id);
            }
            $progress_bar->advance();
        }
        $progress_bar->setMessage('Processing Class Relations ...');
        $progress_bar->display();
        $this->processClassRawRelations();
        $progress_bar->advance();
        $progress_bar->finish();
        $progress_bar->clear();
    }
 public function testWrite()
 {
     $this->output->write('text', true, OutputInterface::OUTPUT_NORMAL)->shouldBeCalled();
     $this->io->write('text', true, OutputInterface::OUTPUT_NORMAL);
 }