public function setUp() { file_put_contents($this->dbPath, ''); $sqliteConfig = new SqliteConfig($this->dbPath); $this->photoRepository = new SqlitePhotoRepository($sqliteConfig); $this->photoRepository->initialize(); $this->thumbRepository = new SqlitePhotoThumbRepository($sqliteConfig); $this->thumbRepository->initialize(); $httpUrl = new HttpUrl('http://test'); $this->photoId = new PhotoId(); $this->photo = new Photo($this->photoId, new ResourceId('test'), new PhotoName('test'), $httpUrl, new PhotoAltCollection(), new Position()); $this->thumbId = new ThumbId(); $this->thumb = new PhotoThumb($this->thumbId, $this->photoId, $httpUrl, new PhotoThumbSize(1, 1)); $this->photoRepository->save($this->photo); $this->thumbRepository->save($this->thumb); }
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; } }
/** * @test */ public function ensureUniquePhotoIdWorks() { $photoId = new PhotoId($this->photo->id()); $uniquePhotoId = $this->repository->ensureUniquePhotoId($photoId); $this->assertTrue($photoId->id() !== $uniquePhotoId->id()); }