diff --git a/tests/DoctumTest.php b/tests/DoctumTest.php index 8ecbc8b2..4433b635 100644 --- a/tests/DoctumTest.php +++ b/tests/DoctumTest.php @@ -10,6 +10,7 @@ use Doctum\RemoteRepository\GitHubRemoteRepository; use Doctum\Store\JsonStore; use Doctum\Version\Version; +use LogicException; /** * @author William Desportes @@ -106,6 +107,64 @@ public function testBasicNoGitCustomNameIntegration(): void ], $project->getVersions()); } + public function testBasicGitIntegrationMissingCacheDir(): void + { + $iterator = Finder::create() + ->files() + ->name('*.php') + ->exclude('stubs') + ->exclude('database') + ->exclude('bootstrap') + ->exclude('storage') + ->in($dir = __DIR__); + + $versions = GitVersionCollection::create($dir) + ->add('master', 'Main Branch') + ->add('blob', 'Fish Branch'); + + $doctum = new Doctum($iterator, [ + 'title' => 'API', + 'versions' => $versions, + 'build_dir' => __DIR__ . '/build/%version%', + 'default_opened_level' => 2, + 'remote_repository' => new GitHubRemoteRepository('RepoName', dirname($dir)), + ]); + $this->expectExceptionMessage( + 'The "cache_dir" setting must have the "%version%" placeholder as the project has more than one version.' + ); + $this->expectException(LogicException::class); + $doctum->getProject(); + } + + public function testBasicGitIntegrationMissingBuildDir(): void + { + $iterator = Finder::create() + ->files() + ->name('*.php') + ->exclude('stubs') + ->exclude('database') + ->exclude('bootstrap') + ->exclude('storage') + ->in($dir = __DIR__); + + $versions = GitVersionCollection::create($dir) + ->add('master', 'Main Branch') + ->add('blob', 'Fish Branch'); + + $doctum = new Doctum($iterator, [ + 'title' => 'API', + 'versions' => $versions, + 'cache_dir' => __DIR__ . '/cache/%version%', + 'default_opened_level' => 2, + 'remote_repository' => new GitHubRemoteRepository('RepoName', dirname($dir)), + ]); + $this->expectExceptionMessage( + 'The "build_dir" setting must have the "%version%" placeholder as the project has more than one version.' + ); + $this->expectException(LogicException::class); + $doctum->getProject(); + } + public function testCliOnlyVersion(): void { $iterator = Finder::create()