public function setUp() { file_put_contents($this->dbPath, ''); $sqliteConfig = new SqliteConfig($this->dbPath); $this->repository = new SqlitePhotoRepository($sqliteConfig); $this->repository->initialize(); $this->photo = new Photo(new PhotoId(), new ResourceId('test'), new PhotoName('test'), new HttpUrl('http://test'), new PhotoAltCollection(), new Position()); $this->repository->save($this->photo); }
protected function execute(InputInterface $input, OutputInterface $output) { switch ($input->getArgument('driver')) { case Repository::REPOSITORY_SQLITE: $config = new SqliteConfig($input->getOption('dbpath')); $sqlitePhotoRepository = new SqlitePhotoRepository($config); $sqlitePhotoThumbRepository = new SqlitePhotoThumbRepository($config); $sqlitePhotoRepository->initialize(); $sqlitePhotoThumbRepository->initialize(); $output->writeln('Sqlite database tables successfully created!'); break; case Repository::REPOSITORY_MYSQL: $config = new MysqlConfig($input->getOption('host'), $input->getOption('dbname'), $input->getOption('user'), $input->getOption('password'), empty($input->getOption('port')) ? 3306 : $input->getOption('port')); $mysqlPhotoRepository = new MysqlPhotoRepository($config); $mysqlPhotoThumbRepository = new MysqlPhotoThumbRepository($config); $mysqlPhotoRepository->initialize(); $mysqlPhotoThumbRepository->initialize(); $output->writeln('Mysql database tables successfully created!'); break; default: throw new InvalidArgumentException(sprintf('Invalid Driver %s', $input->getArgument('driver'))); break; } }